You are on page 1of 15

RegisterUserFunc Statement Enables you to add new methods to test object classes or change the behavior of an existing test

object method during a run session. When you use this statement, QuickTest uses your user-defined function as a meth od of the specified test object class for the remainder of the run session, or u ntil you unregister the method. If the specified method name does not already exist for the test object class, i t becomes a new method for the test object class. If the method name is a define d QuickTest method for the test object class, your definition (temporarily) over rides the existing functionality of the specified method. ============= Important Information A registered method applies only to the test or library file in which you regist er it (or to any tests calling an action containing a RegisterUserFunc statement ). For tests, if you register a function within a reusable action, it is recommende d that you unregister the method at the end of the action. (See UnregisterUserFu nc Statement.) QuickTest clears all function registrations at the beginning of each run session . When QuickTest runs a registered method, it sends the test object as the first a rgument. For this reason, any user-defined function that you register as a test object method must have at least one argument, which receives the test object. If you register a user-defined function to override an existing test object meth od, then after the test object argument, the function must have the same number of arguments as the method it overrides. For more information on user-defined functions, see the HP QuickTest Professiona l User Guide. ========================= TOClass String The test object class for which you want to register the method . You cannot register a method for a QuickTest reserved object (such as Recover, R eporter, and the other objects listed in the Utility Objects section of the HP Q uickTest Professional Object Model Reference). MethodName String The method you want to register. The method name cannot cont ain spaces. FunctionName String The name of your user-defined function. The function can b e located in your action or in any library file associated with your test or com ponent. SetAsDefault Boolean Optional. Indicates whether the registered function is us ed as the default operation for the test object. Default = False Note: When you select a test object in the Keyword View or Step Generator, the d efault operation is automatically displayed in the Operation column (Keyword Vie w) or Operation box (Step Generator). For more information, see the HP QuickTest Professional User Guide. Examples The following example uses the RegisterUserFunc method to create a new Copy meth od for the WinEdit test object that copies all the text in an edit box to the Wi ndows Clipboard. Sub Copy (edit) Edit.Click 3, 3 Edit.SetSelection 0, Len(Edit.GetROProperty("text")) Edit.Type micCtrlDwn + "c" + micCtrlUp End Sub RegisterUserFunc "WinEdit", "Copy", "Copy"

' Now you can call the new method Dialog("Login").WinEdit("Agent Name:").Copy The following example uses the RegisterUserFunc method to modify the behavior of the WebEdit.Set method as defined in the MySet function. The new behavior enabl es the Set method to retrieve and report the default value of the edit box befor e the new value is entered. Function MySet (obj, x) dim y y = obj.GetROProperty("value") Reporter.ReportEvent micDone, "previous value", y MySet=obj.Set(x) End Function RegisterUserFunc "WebEdit", "Set", "MySet" Browser("MercuryTours").Page("FindFlights").WebEdit("Country").Set "Canada" UnRegisterUserFunc "WebEdit", "Set" ******************************************* ExecuteFile Statement Executes the VBScript statements in the specified file. After the file runs, the definitions (functions, subroutines, classes, etc.) in the file are available f rom the global scope of the action's script. Note: You cannot debug a file that is called using an ExecuteFile statement, or any of the functions contained in the file. In addition, when debugging a test t hat contains an ExecuteFile statement, the execution marker may not be correctly displayed. ******************************************** LoadFunctionLibrary Statement Loads the specified function library when this step runs. Important Information The function library is loaded only when the step runs (and not when the test or component opens). Therefore: The function library is not listed in the following (except during the run sessi on): The Resources pane in QuickTest. The Missing Resources pane in QuickTest. The Comments tab in the QuickTest To Do pane. The Dependencies tab in the Quality Center Test Resources module. This can affect test or component maintenance because the function library can p otentially be modified or deleted without anyone realizing that it is called by this test or component. Conversely, when performing maintenance on a test or com ponent, this function library can be overlooked because it is not clearly visibl e as a resource. If a function in the function library has the same name as a function in an asso ciated function library (defined in the Folders pane of the Options dialog box), the function in the dynamically loaded function library is used. Similarly, if more than one function library is loaded dynamically, and these fu nction libraries each contain a function with the same name, QuickTest uses the function in the last loaded function library. If a dynamically loaded function library defines and initializes a global variab le or a class, the value remains in effect for the remainder of the run session or until a new value is defined, whichever comes first. Run performance can be affected because the function library is loaded during th

e run session (and not when the test is opened). At the end of a run session, all of the function libraries that were dynamically loaded are unloaded. You can view the steps that ran during the run session in the Run Results window. Syntax LoadFunctionLibrary(Path) Argument Type Description Path String The path (or paths) of the function library to load. You can specify one or more absolute file system paths, relative paths, or Quali ty Center paths for both tests and components. If you specify multiple paths, se parate them using a comma delimiter. Return Value Variant. Example 1: The following example loads function libraries and runs functions. Dim strCurrentLibPath Const strFrenchLibPath = "[QualityCenter\Resources] Resources\QTP Resources\Fren ch\" Const strEnglishLibPath = "[QualityCenter\Resources] Resources\QTP Resources\Eng lish\" Const strDefaultLibPath = "[QualityCenter\Resources] Resources\QTP Resources\Def ault\" ' Determine the function libraries to load during the run session If Environment.Value("Language") = "French" then strCurrentLibPath = strFrenchLibPath else if Environment.Value("Language") = "English" then strCurrentLibPath = strEnglishLibPath Else strCurrentLibPath = strDefaultLibPath End if ' Load the relevant function libraries for the current environment's language LoadFunctionLibrary strCurrentLibPath + "DialogCrashChecks.qfl", strCurrentLibPa th + "DialogL18NChecks.qfl" ' Perform a set of window object checks using the PerformDialogCrashChecks func tion from the DialogCrashChecks.qfl function library loaded in the previous step PerformDialogCrashChecks Window("MyApplication") ' Perform a set of window object checks using the PerformL18NDialogChecks funct ion from the DialogL18NChecks.qfl function library loaded previously PerformL18NDialogChecks Window("MyApplication") *************************************** Print Statement Description Displays information in the QuickTest Print Log window during the run session. T he QuickTest Print Log window remains open while the run session continues, unti l you close it. For more information, see the HP QuickTest Professional User Guide. Syntax Print (Message) Argument Type Description

Message String String expression displayed as the message in the QuickTest Pri nt Log window. Example The following example iterates all the items in the Flight Table dialog (in the sample Flight application) and uses the Print utility statement to print the con tent of each item to the QuickTest Print Log window. Set FlightsList = Window("Flight Reservation").Dialog("Flights Table").WinList(" From") For i = 1 to FlightsList.GetItemsCount Print FlightsList.GetItem(i - 1) Next ********************************* GetTextLocation Method Description Checks whether a specified text string is contained in a specified window area. If the text string is located, the location coordinates are also returned. Important Information The text to capture must be visible in the application window when the step runs . This method returns True only if the TextToFind argument value is found within a single line in the specified area. The text search restarts on each line of tex t. If the TextToFind argument value includes a space, then this method searches for that text as whole words, regardless of the value set in the MatchWholeWordOnly argument. For example, if you search for "a b" and the text "bla bla" exists, t he method will still return False. However, if the MatchWholeWordOnly argument i s set to False, then a search for "la" in an area where "bla bla" exists, would return True. If the text is found (return value = True) and if the Left, Top, Right, and Bott om arguments are supplied as variables, then the method also returns the exact c oordinates of the specified text to the supplied arguments (the returned coordin ates overwrite the supplied ones). The results of this method may be different depending on the settings selected i n the Text Recognition pane of the Options dialog box (Tools menu > Options item > General node > Text Recognition node). The results of this method may be different in different run sessions depending on the operating system version you are using, service packs you have installed, other installed toolkits, the APIs used in your application, and so on. Therefo re, when possible, it is highly recommended to use alternative ways retrieve the value of the text (or equivalent) property from an object in your application i nstead of using the GetText method, as described in the Important Information se ction of the TextUtil Object. Syntax TextUtil.GetTextLocation(TextToFind, hWnd, Left, Top, Right, Bottom[, MatchWhole WordOnly]) Argument Type Description TextToFind String The text string you want to locate. hWnd Number The handle to a run-time object's window. Notes: If hWnd is not 0, then the coordinate arguments apply to the specified window. I f hWnd is 0, the coordinates apply to the screen. The value 0 is not supported when running steps on Vista or on any 64-bit operat

ing system. Left, Top, Right, Bottom InOut, Number These arguments define the search area within the window or screen. Set all coordinates to -1 to search for the text st ring within the entire window or screen. The method returns the coordinates of t he rectangle containing the first instance of the text into these variables if t he text is found. MatchWholeWordOnly Boolean Optional. If True, the method searches for occurren ces that are whole words only and not part of a larger word. If False, the metho d does not restrict the results to occurrences that are whole words only. Default value = True Return Value Boolean Example The following example searches for the word Mercury within the entire screen and clicks it if the word is found. l = -1 t = -1 r = -1 b = -1 Succeeded = TextUtil.GetTextLocation("16",0,l,t,r,b) If Not Succeeded Then MsgBox "Text not found" else x = (l+r) / 2 y = (t+b) / 2 Set dr = CreateObject("Mercury.DeviceReplay") dr.MouseClick x, y, 0 End If ******************************************* 'step1=Browser("collaborative sourcing").Page("collaborative sourcing").Frame("f raLeftFrame").Link("Page Settings").MouseOpr (3,5, "mousemove") Public Function MouseOprations(ByRef objRef, intX, intY, strOpr) MouseOprations=False If isObject(objRef) Then objRef.Highlight wait 1 x=objRef.getROProperty("abs_x") y=objRef.getROProperty("abs_y") Set objMouse=CreateObject("Mercury.DeviceReplay") Select Case LCase(Trim(strOpr)) Case "clk" objMouse.MouseClick x+Cint(intX), y+CInt(intY), Left_Mouse_Bu tton MouseOprations=True Case "rightclk" objMouse.MouseMove x+Cint(intX), y+CInt(intY) objMouse.MouseClick x+Cint(intX), y+CInt(intY), Right_Mo use_Button MouseOprations=True Case "dblclk" objMouse.MouseDblClick x+Cint(intX), y+CInt(intY), Left _Mouse_Button MouseOprations=True Case "mousemove" objMouse.MouseMove x+Cint(intX), y+CInt(intY) wait 1

MouseOprations=True End Select Set objMouse=Nothing End If End Function RegisterUserFunc "WebButton", "MouseOpr", "MouseOprations" RegisterUserFunc "Image", "MouseOpr", "MouseOprations" RegisterUserFunc "WebEdit", "MouseOpr", "MouseOprations" RegisterUserFunc "WebCheckBox", "MouseOpr", "MouseOprations" ========================================= UnregisterUserFunc Statement Description Instructs QuickTests to stop using the current registration of the method. If th e unregistered method is a defined QuickTest method for the object, the function ality of the method returns to the standard QuickTest functionality. Note: If you register a function within a reusable action, it is recommended tha t you unregister the method at the end of the action. For more information on unregistering user-defined functions, see the HP QuickTe st Professional User Guide. Syntax UnRegisterUserFunc TOClass, MethodName Argument Type Description TOClass String The test object class for which you want to unregister the meth od. MethodName String The method you want to unregister. Example Suppose that the FindFlights Web page contained a Country edit box, and by defau lt, the box contained the value USA. The following example registers the Set met hod to use the MySet function in order to report the default value of the edit b ox to the run results before the new value is entered. After using the registere d method in a WebEdit.Set statement for the Country edit box, the UnRegisterUser Func method is used to return the Set method to the standard QuickTest functiona lity. Function MySet (obj, x) dim y y = obj.GetROProperty("value") Reporter.ReportEvent micDone, "previous value", y MySet=obj.Set(x) End Function RegisterUserFunc "WebEdit", "Set", "MySet" Browser("MercuryTours").Page("FindFlights").WebEdit("Country").Set "Canada" UnRegisterUserFunc "WebEdit", "Set" ========================= QuickTest Automation Object Model Overview You can use the QuickTest Professional automation object model to write scripts that automate your QuickTest operations. The QuickTest automation object model p rovides objects, methods, and properties that enable you to control QuickTest fr om another application. Using the objects, methods, and properties exposed by the QuickTest automation o bject model, you can write scripts that configure QuickTest options and run test

s or components instead of performing these operations manually using the QuickT est interface. Automation scripts are especially useful for performing the same tasks multiple times or on multiple tests or components, or for quickly configuring QuickTest a ccording to your needs for a particular environment or application. What is Automation? Automation is a Microsoft technology that makes it possible to access software o bjects inside one application from other applications. These objects can be crea ted and manipulated using a scripting or programming language such as VBScript o r VC++. Automation enables you to control the functionality of an application pr ogrammatically. What is the QuickTest Automation Object Model? An object model is a structural representation of software objects (classes) tha t comprise the implementation of a system or application. An object model define s a set of classes and interfaces, together with their properties, methods and e vents, and their relationships. The QuickTest automation object model is a set of objects, methods, and properti es that enable you to control essentially all of the configuration and run funct ionality provided via the QuickTest interface. Although a one-on-one comparison cannot always be made, most dialog boxes in QuickTest have a corresponding autom ation object, most options in dialog boxes can be set and/or retrieved using the corresponding object property, and most menu commands and other operations have corresponding automation methods. You can use the objects, methods, and properties exposed by the QuickTest automa tion object model, along with standard programming elements such as loops and co nditional statements to design your script. Automation scripts are especially useful for performing the same tasks multiple times or on multiple tests or components, or for quickly configuring QuickTest a ccording to your needs for a particular environment or application. Example: You can create and run an automation script from Microsoft Visual Basic that loa ds the required add-ins for a test or component, starts QuickTest in visible mod e, opens the test or component, configures settings that correspond to those in the Options, Test or Business Component Settings, and Record and Run Settings di alog boxes, runs the test or component, and then saves the test or component. You can then add a simple loop to your script so that your single script can per form the operations described above for multiple tests or components. You can also create an initialization script that opens QuickTest with specific configuration settings. You can then instruct all of your testers to open QuickT est using this automation script to ensure that all of your testers are always w orking with the same configuration. =============================================== Extern Object Description Enables you to declare calls to external procedures from an external dynamic-lin k library (DLL). Declare Method Description Declares references to external procedures in a dynamic-link library (DLL).

After you use the Declare method for a method, you can use the Extern object to call the declared method. Syntax Extern.Declare(RetType, MethodName, LibName, Alias [, ArgType(s)]) Argument Type Description RetType String Data type of the value returned by the method. For available da ta types, see Extern.Declare Data Types. Note: String value types (micString and micWideString) are not supported as retu rn values. To return a string value, use a string out argument in the called procedure. In the Extern.Declare statement, use micVoid for the RetType argument and micByR ef + micString (or other relevant string type) for the ArgType argument. For a c omplete example, see Returning a String Value Using an Extern.Declare Statement. MethodName String Any valid procedure name. LibName String Name of the DLL or code resource that contains the declared pro cedure. Alias String Name of the procedure in the DLL or code resource. Note: DLL entry points are case sensitive. If Alias is an empty string, MethodName is used as the Alias. ArgType(s) String A list of data types representing the data types of the argu ments that are passed to the procedure when it is called. For available data typ es, see Extern.Declare Data Types. Note: For out arguments, use the micByRef flag. Example The following example uses the Extern.Declare and Extern.<declared method> metho ds to change the title of the Notepad window. 'Declare FindWindow method Extern.Declare micHwnd, "FindWindow", "user32.dll", "FindWindowA", micString, mi cString 'Declare SetWindowText method Extern.Declare micLong, "SetWindowText", "user32.dll", "SetWindowTextA", micHwnd , micString 'Get HWND of the Notepad window hwnd = Extern.FindWindow("Notepad", vbNullString) if hwnd = 0 then MsgBox "Notepad window not found" end if 'Change the title of the notepad window res = Extern.SetWindowText(hwnd, "kuku") The following example retrieves information from an external INI file using GetP rivateProfileString, and uses it in the test. Note the use of the micByRef flag to indicate the out argument. Extern.Declare micInteger,"GetPrivateProfileStringA", "kernel32.dll","GetPrivate ProfileStringA", micString, micString, micString, micString+micByRef, micInteger , micString

Dim key, i, key2 key = String(32, "-") i = Extern.GetPrivateProfileStringA("WREnv","addons","xxx", key, 32, "wrun.ini") key2 = Left(key,i) msgbox key & ";" & key2 & ";" & CStr(i) The following example checks when the cursor is displayed as an hour glass. extern.Declare micLong,"GetForegroundWindow","user32.dll","GetForegroundWindow" extern.Declare micLong,"AttachThreadInput","user32.dll","AttachThreadInput",micL ong,micLong,micLong extern.Declare micLong,"GetWindowThreadProcessId","user32.dll", "GetWindowThreadProcessId",micLong,micLong extern.Declare micLong,"GetCurrentThreadId","kernel32.dll","GetCurrentThreadId" extern.Declare micLong,"GetCursor","user32.dll","GetCursor" function get_cursor() hwnd = extern.GetForegroundWindow() pid = extern.GetWindowThreadProcessId(hWnd, NULL) thread_id=extern.GetCurrentThreadId() extern.AttachThreadInput pid,thread_id,True get_cursor=extern.GetCursor() extern.AttachThreadInput pid,thread_id,False end function Msgbox get_cursor() *********************************************** ChildObjects Method Returns the collection of child objects contained within the object. Important Information This method returns a null value for any object that is not a parent object ******************************** Check Method Description Checks whether the actual value of an item matches the expected value. Important Information You create checkpoints and define the property checks for the checkpoint using o ne of the Insert Checkpoint options. For more information, refer to the QuickTes t Professional User's Guide. If you want to retrieve the return value of a checkpoint, you must add parenthes es around the name of the checkpoint in the statement. For example: a = Browser("MyBrowser").Page("MyPage").Check ( CheckPoint("MyProperty")) Syntax object.Check (Verify) Argument Description object A test object of type Browser. Verify Required. A Variant value. The checkpoint object that contains the expected values to be compared and verif ied during the test run. returns boolean value ========================================= CheckProperty Method Checks whether the specified object property achieves the specified value within the specified timeout. If the expected and actual values do not match, an error is reported and the tes t or component status is changed to failed. Note: For test run synchronization, or whenever you do not want to fail the test

if the expected and actual values do not match, use the WaitProperty method. You can also use comparison objects to perform more complex value comparisons. F or example, you can instruct QuickTest to check whether a specific property valu e is greater than the specified value. An example of the syntax required when using a comparison object is: Object.Chec kProperty "items count",micGreaterThan(8) object.CheckProperty (PropertyName, PropertyValue, [TimeOut]) A Boolean value. Returns TRUE if the property achieves the value, and FALSE if the timeout is reached before the property achieves the value. A TRUE return value reports a Passed step to the run results; a FALSE return val ue reports a Failed step to the run results. Check Whether Text is Entered in an Edit Box : Browser("Nested Lists").Page("Page").WebEdit("Name").Set "Mercury" Browser("Nested Lists").Page("Page").WebEdit("Name").CheckProperty "value", "Mer cury" ================================================= WaitProperty Method Waits until the specified object property achieves the specified value or exceed s the specified timeout before continuing to the next step. Tip: This method is useful for test run synchronization. Unlike the Exist method , the WaitProperty method enables you to synchronize the test run based on a spe cific object property. For example, you can instruct QuickTest to wait for a par ticular string to appear in a static text control: ' Wait up to 30 seconds for the string "Ready" to appear in the "Status" text co ntrol. Window("Test").Static("Status:").WaitProperty "text", "Ready", 30000 You can also use comparison objects to perform more complex value comparisons. F or example, you can instruct QuickTest to wait until a specific property value i s greater than the specified value. An example of the syntax required when using a comparison object is: Object.Wait Property "items count",micGreaterThan(8) Wait Up to 4 Seconds For a Link to Be Ready If Browser("index").Page("index").Link("All kind of").WaitProperty("attribute/re adyState", "complete", 4000) Then Browser("index").Page("index").Link("All kind of").Click End If ========================================== Object Property : Accesses the native methods and properties of the browser. This property is not supported when working with Browser objects in Mozilla Fire fox. The Document Object Model (DOM) is a set of objects that correspond to the eleme nts you see on a Web page. You can modify the appearance and behavior of an HTM L element by altering a DOM object's properties and calling its methods. When you use the QuickTest Object property for a Web object, you actually get a reference to the DOM object. This means that any operation that you can perform on a DOM object, you can also perform by running a <WebTestObject>.Object statem ent on the Web object. For example, you can use the links property of the Intern et Explorer document object to retrieve a link collection. The Web Object property can be used only for supported versions of Internet Expl orer and Mozilla Firefox. **************************************

pwd = "GetPasswordfromSomewhere" e_pwd = Crypt.Encrypt(pwd) Browser("dfgd").Dialog("pass").WinEdit("pwd").SetSecure e_pwd ===================================================== Create Method Returns a Properties Object (Collection) in which you can add a set of propertie s and values in order to create the description of an object during a run sessio n. You can then use this object in place of a test object name in a step. ============================== Environment Object Enables you to work with environment variables. You can set or retrieve the value of environment variables using the Environment object. You can retrieve the value of any environment variable. You can set the value of only user-defined, environment variables. To set the value of a user-defined, environment variable: Environment (VariableName) = NewValue To retrieve the value of a loaded environment variable: CurrValue = Environment (VariableName) The following example creates a new internal user-defined variable named MyVaria ble with a value of 10, and then retrieves the variable value and stores it in t he MyValue variable. Environment.Value("MyVariable")=10 MyValue=Environment.Value("MyVariable") ====================================== Timer Property Accesses the timer with the specified name from the MercuryTimers collection obj ect, or creates a new timer with this name if the timer does not yet exist. Important Information The Timer property is the default property for the MercuryTimers collection obje ct. Set MyTimer = MercuryTimers.Timer(TimerName) Argument Type Description TimerName String The name of the specific timer. Notes: You can omit the word Timer in the syntax, because Timer is the default property for the MercuryTimers collection object. Instead of returning the internal timer object to the MyTimer variable, you can perform MercuryTimer methods directly on the returned object within the same sta tement, as shown in the following example. The following example uses two MercuryTimer objects (Timer1 and Timer2) to measu re elapsed time in milliseconds, send a report to the run results, convert the t ime from milliseconds to seconds, and set a transaction. MercuryTimers("Timer1").Start 'Start measuring time using Timer1. Wait 1 MercuryTimers("Timer1").Stop 'After one second, stop Timer1. MercuryTimers("Timer2").Start 'Start measuring time usingTimer2. 'Two seconds later, restart Timer1 (which will continue to measure time from 'the time it stopped while Timer2 continues uninterrupted).

Wait 2 MercuryTimers("Timer1").Continue 'Three seconds later, stop both timers and send a report to the test 'results specifying the elapsed time for each of the timer objects '(Timer1 ~4000 ms; Timer2 ~5000 ms). Wait 3 Reporter.ReportEvent micDone, "Elapsed Time", "Timer1: " & MercuryTimers("Timer1 ").Stop() & "ms, Timer2: " & MercuryTimers("Timer2").Stop() & "ms" 'Set a transaction manually for each of the timer objects. Convert the 'elapsed time for each of the timer objects from milliseconds to seconds so 'the elapsed time will be reported correctly in the transaction. Services.SetTransaction "Timer1",MercuryTimers("Timer1").ElapsedTime / 1000,Pass Services.SetTransaction "Timer2",MercuryTimers("Timer2").ElapsedTime / 1000,Pass ************************************** Reset Method Returns the elapsed time in milliseconds and resets the timer to zero. If the timer is already running, the Reset method stops it before resetting the time to zero. Syntax retTime = MercuryTimers.Timer(TimerName).Reset or retTime = MercuryTimers(TimerName).Reset Note: You can omit the Timer property in the syntax, because Timer is the defaul t property for the MercuryTimers collection object. Return Value A Number. The elapsed time in milliseconds. Example The following example resets the stopped MercuryTimer object, Timer1. MercuryTimers("Timer1").Start 'Start measuring time using Timer1. Wait 1 MercuryTimers("Timer1").Stop 'After one second, stop Timer1. 'Two seconds later, reset Timer1 so it will start to measure time from zero Wait 2 msgbox MercuryTimers("Timer1").Reset '''returns number of milli seconds elaps ed. ========================= ElapsedTime Property Returns the total accumulated time in milliseconds since the timer started. Important Information The ElapsedTime property is the default property for the MercuryTimer object. Syntax retTime = MercuryTimers.Timer(TimerName).ElapsedTime or retTime = MercuryTimers(TimerName).ElapsedTime or retTime = MercuryTimers.Timer(TimerName) or retTime = MercuryTimers(TimerName) Note: You can omit the Timer property and/or ElapsedTime property in the syntax,

because Timer is the default property for the MercuryTimers collection object, and ElapsedTime is the default property of the MercuryTimer object. Return Value A Number. The total accumulated time in milliseconds since the timer started. Example The following example returns the elapsed time in milliseconds for the MercuryTi mer object named Timer1. It then sends a report to the run results, convert the time from milliseconds to seconds, and sets a transaction. MercuryTimers("Timer1").Start 'Start measuring time using Timer1. 'Three seconds later, stop Timer1 and send a report to the test 'results specifying the elapsed time in milliseconds (~3000 ms). Wait 3 Reporter.ReportEvent micDone, "Elapsed Time", "Timer1: " & MercuryTimers("Timer1 ").Stop() & "ms" 'Set a transaction manually and convert the elapsed time from milliseconds to 'seconds so the elapsed time will be reported correctly in the transaction. Services.SetTransaction "Timer1",MercuryTimers("Timer1").ElapsedTime / 1000,Pass =================================== Continue Method Description Continues running the timer from the time it stopped (without resetting it). Important Information If the timer is already running, the Continue method does not affect it. Syntax MercuryTimers.Timer(TimerName).Continue or MercuryTimers(TimerName).Continue Note: You can omit the Timer property in the syntax, because Timer is the defaul t property for the MercuryTimers collection object. Example The following example continues the stopped MercuryTimer object, Timer1, from th e time it stopped. MercuryTimers("Timer1").Start 'Start measuring time using Timer1. Wait 1 MercuryTimers("Timer1").Stop 'After one second, stop Timer1. 'Two seconds later, restart Timer1 (which will continue to measure time from 'the time it stopped). Wait 2 MercuryTimers("Timer1").Continue ============================================= ReportEvent Method Description Reports an event to the run results. Syntax Reporter.ReportEvent EventStatus, ReportStepName, Details [, ImageFilePath] Argument Type Description EventStatus Number or pre-defined constant Status of the Run Results step: 0 or micPass: Causes the status of this step to be passed and sends the specifie d message to the Run Results window. 1 or micFail: Causes the status of this step to be failed and sends the specifie d message to the Run Results window. When this step runs, the test or component fails.

2 or micDone: Sends a message to the Run Results window without affecting the pa ss/fail status of the test or component. 3 or micWarning: Sends a warning message to the Run Results window, but does not cause the test or component to stop running, and does not affect the pass/fail status of the test or component. ReportStepName String Name of the step displayed in the Run Results window. Details String Description of the Run Results event. The string will be displa yed in the step details frame in the Run Results window. ImageFilePath String Optional. Path and filename of the image to be displayed in the Captured Data pane of the Run Results window. Images in the following for mats can be displayed: BMP, PNG, JPEG, and GIF. Notes: Images cannot be loaded from Quality Center. Including large images in the run results may impact performance. If an image is specified as a relative path, QuickTest will first search the Res ults folder for the image and then the search paths specified in the Folders pan e of the Options dialog box. Examples The following examples use the ReportEvent method to report a failed step. Reporter.ReportEvent 1, "Custom Step", "The user-defined step failed." or Reporter.ReportEvent micFail, "Custom Step", "The user-defined step failed." The following example uses the ReportEvent method to include a captured bitmap i n the run results. Browser("Browser").Page("WebPage").Image("MyLogo").CaptureBitmap("MyLogo.bmp") Reporter.ReportEvent micDone, "Display Logo", "This is my logo", "MyLogo.bmp" ================================== strScreenCapPath = Environment.value("SystemTempDir") & "\" & strTestName & "_" & strDateTime & "_" & replace(Timer, ".", "") & "_StepNo_" & intStepNo & ".png" Desktop.CaptureBitmap strScreenCapPath ======================= ThinkTime Method :Pauses the execution during a test run to simulate the time a real user pauses between actions. Services.ThinkTime Seconds

You might also like