Recording a Test
You can create the main body of a test by recording the typical processes that users perform. QTP records the operations you perform, displays them as steps in the Keyword View, and generates them in a script (in the Expert View).
Note that by default, each test includes a single action, but can include multiple actions. This section describes how to record a test with a single action.
By default, QTP records in the normal recording mode. If you are unable to record on an object in a given environment in the standard recording mode, or if you want to record mouse clicks and keyboard input with the exact x- and y-coordinates, you may want to record on those objects using analog or low-level recording.
Tip: If you have objects that behave like standard objects, but are not recognized by QTP , you can define your objects as virtual objects.
Consider the following when recording a test:
- Before you start to record, close all applications not required for the recording session.
- If you are recording on a Web site, determine the security zone of the site. When you record on a Web browser, the browser may prompt you with security alert dialog boxes. You may choose to disable/enable these dialog boxes.
- Decide how you want to open the application when you record and run your test. You can choose to have QTP open one or more specified applications, or record and run on any application that is already open. The Record and Run Settings dialog box contains tabbed pages corresponding to the add-ins loaded.
- Choose how you want QTP to record and run your test by setting global testing options in the Options dialog box and settings specific to your test in the Test Settings dialog box.
- If you are recording on a Web object, you must make a change to the object's value to make QTP record the step. For example, to record a selection in a WebList object, you must click on the list, scroll to an entry that was not originally showing, and select it. If you want to select the item in the list that is already displayed, you must first select another item in the list (click it), then return to the originally displayed item and select it (click it).
Note: If you are creating a test on Web objects, you can record your test on Microsoft Internet Explorer and run it on another supported browser. QTP supports running tests on the following browsers—Microsoft Internet Explorer, Netscape Browser, Mozilla Firefox, and applications with embedded Web browser controls.
To record a test:
- Open QTP.
- Open a test:
- To create a new test, select File > New > Test, or click the down arrow next to the New button and select Test. Alternatively, click the New button down arrow and select Test.
- To open an existing test, select File > Open > Test or click the down arrow next to the Open button and select Test. In the Open Test dialog box, browse to and select a test and click Open.
For more information, see Managing Your QTP Test.
- Click the Record button or select Automation > Record. If you are recording a new test and have not yet set your record and run settings in the Record and Run Settings dialog box (from Automation > Record and Run Settings), the Record and Run Settings dialog box opens.
After you set the record and run settings for a test, the Record and Run Settings dialog box will not open the next time you start a session in the same test. However, you can select Automation > Record and Run Settings to open the Record and Run Settings dialog box. You can use this option to set or modify your record and run preferences in the following scenarios:
- You have already recorded one or more steps in the test and you want to modify the settings before you continue recording.
- You want to run the test on a different application than the one you previously used.
The tabs available in the Record and Run Settings dialog box depend on the loaded add-ins.
- Set the required options.
- To apply your changes and keep the Record and Run Settings dialog box open, click Apply.
- Click OK to close the Record and Run Settings dialog box and begin recording your test.
- Navigate through your application. QTP records each step you perform and displays it in the Keyword View and Expert View.
- To determine if your application is functioning correctly, you can insert text checkpoints, object checkpoints, and bitmap checkpoints.
- You can parameterize your test to check how it performs the same operations with multiple sets of data, or with data from an external source.
- When you complete your recording session, click the Stop button, select Automation > Stop, or press the Stop command shortcut key.
- To save your test, click the Save button or select File > Save. In the Save QTP Test dialog box, assign a name to the test. QTP suggests a default folder called Tests. For more information, see Saving a Test.