Working with Dynamic Content

Q: How can I record and run components on objects that change dynamically from viewing to viewing?

Sometimes the content of objects in a Web page or application changes due to dynamic content. You can create dynamic descriptions of these objects so that QuickTest will recognize them when it runs the test.

Q: How can I check that a child window exists (or does not exist)?

Sometimes a link in one window creates another window.

You can use the Exist property to check whether or not a window exists. For example:

Browser("Window_name").Exist

You can also use the ChildObjects method to retrieve all child objects (or the subset of child objects that match a certain description) on the Desktop or within any other parent object.

For more information on the Exist property and ChildObjects method, refer to the QuickTest Professional Object Model Reference.

Q: How does QuickTest record on dynamically generated URLs and Web pages?

QuickTest actually clicks links as they are displayed on the page. Therefore, QuickTest records how to find a particular object, such as a link on the page, rather than the object itself. For example, if the link to a dynamically generated URL is an image, then QuickTest records the "IMG" HTML tag, and the name of the image. This enables QuickTest to find this image in the future and click on it.

Working with Function Libraries

Q: Can I store functions and subroutines in a function library?

You can create one or more VBScript function libraries containing your functions, and then use them in any component.

You can register your functions as methods for QuickTest test objects. Your registered methods can override the functionality of an existing test object method for the duration of a run session, or you can register a new method for a test object class.

Recording and Running Tests

  • How does QuickTest capture user processes in Web pages?

QuickTest hooks the Microsoft Internet Explorer browser. As the user navigates the Web-based application, QuickTest records the user actions. (For information about modifying which user actions are recorded. QuickTest can then run the component by running the steps as they originally occurred.

  • How can I record on objects or environments not supported by QuickTest?

You can do this in a number of ways:

    • By default, QuickTest supports several developmental environments. You can also enable support for additional environments, such as Java, Oracle, .NET, SAP Solutions, Siebel, PeopleSoft, terminal emulators, and Web services, by installing and loading any of the external add-ins that are available for QuickTest Professional.
    • You can map objects of an unidentified or custom class to standard Windows classes.

Identifying an Object Using the Index Property

While learning an object, QuickTest can assign a value to the test object's Index property to uniquely identify the object. The value is based on the order in which the object appears within the source code. The first occurrence is 0.

Index property values are object-specific. Therefore, if you use Index:=3 to describe a WebEdit test object, QuickTest searches for the fourth WebEdit object in the page. However, if you use Index:=3 to describe a WebElement object, QuickTest searches for the fourth Web object on the page—regardless of the type—because the WebElement object applies to all Web objects.

For example, suppose a page contains the following objects:

  • an image with the name Apple
  • an image with the name UserName
  • a WebEdit object with the name UserName
  • an image with the name Password
  • a WebEdit object with the name Password

The following statement refers to the third item in the list, as this is the first WebEdit object on the page with the name UserName:

WebEdit("Name:=UserName", "Index:=0")

In contrast, the following statement refers to the second item in the list, as that is the first object of any type (WebElement) with the name UserName:

WebElement("Name:=UserName", "Index:=0")

Configuring Object Identification

QuickTest has a predefined set of properties that it learns for each test object. If these mandatory property values are not sufficient to uniquely identify an object you record or add, QuickTest can add some assistive properties and/or an ordinal identifier to create a unique description.

Mandatory properties are properties that QuickTest always learns for a particular test object class.

Assistive properties are properties that QuickTest learns only if the mandatory properties that QuickTest learns for a particular object in your application are not sufficient to create a unique description. If several assistive properties are defined for an object class, then QuickTest learns one assistive property at a time, and stops as soon as it creates a unique description for the object. If QuickTest does learn assistive properties, those properties are added to the test object description.

Note: If the combination of all defined mandatory and assistive properties is not sufficient to create a unique test object description, QuickTest also learns the value for the selected ordinal identifier.

When you run a component, QuickTest searches for the object that matches the description it learned (without the ordinal identifier). If it cannot find any object that matches the description, or if it finds more than one object that matches, QuickTest uses the Smart Identification mechanism (if enabled) to identify the object. In many cases, a Smart Identification definition can help QuickTest identify an object, if it is present, even when the learned description fails due to changes in one or more property values. The test object description is used together with the ordinal identifier only in cases where the Smart Identification mechanism does not succeed in narrowing down the object candidates to a single object.

You use the Object Identification dialog box (Tools > Object Identification) to configure the mandatory, assistive, and ordinal identifier properties that QuickTest uses to learn descriptions of the objects in your application, and to enable and configure the Smart Identification mechanism.

The Object Identification dialog box also enables you to configure new user-defined classes and map them to an existing test object class so that QuickTest can recognize objects from your user-defined classes when you run your component.

Identifying an Object Using the CreationTime Property

While learning a browser object, if QuickTest is unable to uniquely identify the object according to its test object description, it assigns a value to the CreationTime test object property. This value indicates the order in which the browser was opened relative to other open browsers with an otherwise identical description. The first browser that opens receives the value CreationTime = 0.

During the run session, if QuickTest is unable to identify a browser object based solely on its test object description, it examines the order in which the browsers were opened, and then uses the CreationTime property to identify the correct one.

For example, if you record a component on three otherwise identical browsers that are opened at 9:01 pm, 9:03 pm, and 9:05 pm, QuickTest assigns the CreationTime values, as follows: CreationTime = 0 to the 9:01 am browser, CreationTime = 1 to the 9:03 am browser, and CreationTime = 2 to the 9:06 am browser.

At 10:30 pm, when you run your component, suppose the browsers are opened at 10:31 pm, 10:33 pm, and 10:34 pm. QuickTest identifies the browsers, as follows: the 10:31 pm browser is identified with the browser test object with CreationTime = 0, 10:33 pm browser is identified with the test object with CreationTime = 1, 10:34 pm browser is identified with the test object with CreationTime = 2.

If there are several open browsers, the one with the lowest CreationTime is the first one that was opened and the one with the highest CreationTime is the last one that was opened. For example, if there are three or more browsers open, the one with CreationTime = 2 is the third browser that was opened. If seven browsers are opened during a recording session, the browser with CreationTime = 6 is the last browser opened.

If a step was recorded on a browser with a specific CreationTime value, but during a run session there is no open browser with that CreationTime value, the step will run on the browser that has the highest CreationTime value. For example, if a step was recorded on a browser with CreationTime = 6, but during the run session there are only two open browsers, with CreationTime = 0 and CreationTime = 1, then the step runs on the last browser opened, which in this example is the browser with CreationTime=1.

Note: It is possible that at a particular time during a session, the available CreationTime values may not be sequential. For example, if you open six browsers during a record or run session, and then during that session, you close the second and fourth browsers (CreationTime values 1 and 3), then at the end of the session, the open browsers will be those with CreationTime values 0, 2, 4, and 5).

Identifying an Object Using the Location Property

While learning an object, QuickTest can assign a value to the test object's Location property to uniquely identify the object. The value is based on the order in which the object appears within the window, frame, or dialog box, in relation to other objects with identical properties. The first occurrence of the object is 0. Values are assigned in columns from top to bottom, and left to right.

Location property values are object-specific. Therefore, if you use Location:=3 to describe a WinButton test object, QuickTest searches from top to bottom, and left to right for the fourth WinButton object in the page. However, if you use Location:=3 to describe a WinObject object, QuickTest searches from top to bottom, and left to right for the fourth standard object on the page—regardless of the type—because the WinObject object applies to all standard objects.

For example, suppose a dialog box contains the following objects:

  • a button object with the name OK
  • a button object with the name Add/Remove
  • a check box object with the name Add/Remove
  • a button object with the name Help
  • a check box object with the name Check spelling

The following statement refers to the third item in the list, as this is the first check box object on the page with the name Add/Remove.

WinCheckBox("Name:=Add/Remove", "Location:=0")

In contrast, the following statement, refers to the second item in the list, as that is the first object of any type (WinObject) with the name Add/Remove.

WinObject("Name:=Add/Remove", "Location:=0")

Working with Web Browsers

You use a Web browser to record components that check Web objects. Before you begin recording, you must open your browser to the relevant Web page.

Note: By default, the name assigned to the Browser test object in the object repository is always the name assigned to the first page recorded for the browser object. The same test object is used each time you record on a browser with the same ordinal ID in future recording sessions. Therefore, the name used for the browser in the steps you record may not reflect the actual browser name.

QuickTest supports recording components on Microsoft Internet Explorer and running components on the following Web browsers:

Tips:

You can configure the browser to always display your pages using the Firefox engine. (In Netscape Browser, choose Tools > Options > Site Controls, and make sure that the Firefox radio button is selected in the Rendering Engine area.)

You can configure the browser to always display your pages using the Firefox engine by clearing the Automatically use the Internet Explorer Engine check box while installing Netscape Browser.

Working with the Web Add-in

You can use QuickTest's Web Add-in to test your Web pages and applications. You can test Web objects such as hyperlinks, images, image maps, and Viewlink objects.

Before you begin recording on Web sites and applications, you should ensure that you have installed and loaded the Web add-in. You can check whether the Web add-in is installed by choosing Help > About QuickTest Professional. Loaded add-ins are indicated by a check mark in the add-ins list.

You should also set your preferences in the Web tab of the Business Component Settings dialog box, and the Web tab of the Options dialog box. For more information, see Working with Business Component Settings and Setting Global Testing Options.

If QuickTest does not record Web events in a way that matches your needs, you can also configure the events you want to record for each type of Web object. For example, if you want to record events, such as a mouseover that opens a sub-menu, you may need to modify the Web event configuration to recognize such events. For more information, see Configuring Web Event Recording.

Note: If you are recording on a list in a Web page or application, 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). This is because QuickTest only records a step if the value in the list changes.