Dynamic Object Recognition

Dynamic object recognition enables you to create test cases that use XPath queries to find and identify objects. Dynamic object recognition uses a Find or FindAll method to identify an object in a test case. For example, the following query finds the first top-level Shell with the caption SWT Test Application:
Desktop.find("/Shell[@caption='SWT Test Application']")

To create tests that use dynamic object recognition, you must use the Open Agent.

Examples of the types of test environments where dynamic object recognition works well include:
  • In any application environment where the graphical user interface is undergoing changes. For example, to test the Check Me check box in a dialog box that belongs to a menu where the menu and the dialog box name are changing, using dynamic object recognition enables you to test the check box without concern for what the menu and dialog box are called. You can then verify the check box name, dialog box name, and menu name to ensure that you have tested the correct component.
  • In a Web application that includes dynamic tables or text. For example, to test a table that displays only when the user points to a certain item on the web page, use dynamic object recognition to have the test case locate the table without regard for which part of the page needs to be clicked in order for the table to display.
  • In an Eclipse environment that uses views. For example, to test an Eclipse environment that includes a view component, use dynamic object recognition to identify the view without regard to the hierarchy of objects that need to open prior to the view.

Using dynamic object recognition compared to using hierarchical object recognition

The benefits of using dynamic object recognition rather than hierarchical object recognition include:
  • Dynamic object recognition uses a subset of the XPath query language, which is a common XML-based language defined by the World Wide Web Consortium, W3C. Hierarchical object recognition is based on the concept of a complete description of the application's object hierarchy and as a result is less flexible than dynamic object recognition.
  • Dynamic object recognition requires a single object rather than an include file that contains window declarations for the objects in the application that you are testing. Using XPath queries, a test case can locate an object using a Find command followed by a supported XPath construct. Hierarchical object recognition uses the include file to identify the objects within the application.

You can create tests for both dynamic and hierarchical object recognition in your test environment. You can use both recognition methods within a single test case if necessary. Use the method best suited to meet your test requirements.

Using dynamic object recognition and window declarations

Silk Test Classic provides an alternative to using Find or FindAll functions in scripts that use dynamic object recognition. By default, when you record a test case with the Open Agent, Silk Test Classic uses locator keywords in an include (.inc) file to create scripts that use dynamic object recognition and window declarations. Using locator keywords with dynamic object recognition enables users to combine the advantages of INC files with the advantages of dynamic object recognition. For example, scripts can use window names in the same manner as traditional, Silk Test Classic tag-based scripts and leverage the power of XPath queries.

Existing test cases that use dynamic object recognition without locator keywords in an INC file will continue to be supported. You can replay these tests, but you cannot record new tests with dynamic object recognition without locator keywords in an INC file. You must manually record test cases that use dynamic object recognition without locator keywords. You can record the XPath query strings to include in test cases by using the Locator Spy dialog box.