Working with dynamic content

Relevant for: GUI tests and components

How can I create and run tests or components on objects that change dynamically from viewing to viewing?

Sometimes the content of objects in an application changes due to dynamic content. You can create dynamic descriptions of these objects so that UFT One will recognize them when it runs the test or component using regular expressions, the Description object, repository parameters, or SetTOProperty steps.

Back to top

How can I check that an object or child object exists (or does not exist)?

Some objects are created in an application only after you perform an operation. For example, a link in one window sometimes creates another window. The newly created window may be an independent object, or a child of the original window.

Before you perform operations on an object created during a run session, you may want to verify that the object already exists.

Use the Exist property to check whether the object exists in the application. This property looks for an object in the application that matches the test object's description. For example:

If Window("Main").ActiveX("Slider").Exist Then
. .  .

Alternatively, you can 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.

Set oDesc = Description.Create
oDesc("Class Name").Value = "Window"
Set coll = Desktop.ChildObjects(oDesc)
For i = 0 to coll.count -1
        msgbox coll(i).GetROProperty("text")
Next
  • After you use the ChildObjects method to retrieve an object, UFT One accesses the object directly in the application and does not save a description for the object. Therefore, you must use the object immediately after retrieving it, before anything in the application changes.

  • The Exist property searches for objects based on their description, and is therefore not relevant for objects retrieved by the ChildObjects method. (The Exist property always returns true when called for such objects).

For more details on the Exist property and ChildObjects method, see the Common Methods and Properties section of the UFT One Object Model Reference for GUI Testing.

Back to top

How does UFT One record on dynamically generated URLs and Web pages?

UFT One actually clicks links as they are displayed on the page. Therefore, UFT One 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 UFT One records the "IMG" HTML tag, and the name of the image. This enables UFT One to find this image in the future and click on it.

Back to top

How does UFT One handle tabs in browsers?

UFT One provides several methods that you can use with the Browser test object to manage tabs in your Web browser.

  • OpenNewTab opens a new tab in the current Web browser.

  • IsSiblingTab indicates whether a specified tab is a sibling of the current tab object in the same browser window.

  • Close closes the current tab if more than one tab exists, and closes the browser window if the browser contains only one tab.

  • CloseAllTabs closes all tabs in a browser and closes the browser window.

For more details on these Browser-related methods, see the Web section of the UFT One Object Model Reference for GUI Testing.

Back to top

See also: