Object Maps

An object map is a test asset that contains items that associate a logical name (an alias) with a control or a window, rather than the control or window's locator. Once a control is registered in an object map asset, all references to it in visual tests and scripts are made by its alias, rather than by its actual locator name.

You can use object maps to store objects that you are using often in multiple scripts. Multiple tests can reference a single object map item definition, which enables you to update that object map definition once and have Silk Test Workbench update it in all tests that reference the object map definition.

In your scripts, you can mix object map identifiers and locators. This feature enables you to keep your object maps relatively small and easier to manage. You can simply store the commonly used objects in your object maps, and use locators to reference objects that are rarely used.

Tip: To optimally use the functionality that object maps provide, create an individual project in Silk Test Workbench for each application that you want to test.

Example for object maps

The following construct shows a definition for a BrowserWindow where the locator is used:

_desktop.BrowserApplication("cnn_com").BrowserWindow("//BrowserWindow[1]")

The name of the object map asset is cnn_com. The locator that can be substituted by an alias in the object map is the following:

"//BrowserWindow[1]"

The object map entry for the BrowserWindow is BrowserWindow.

The resulting definition of the BrowserWindow in the script is the following:

_desktop.BrowserApplication("cnn_com").BrowserWindow("BrowserWindow")

If the index in the locator changes, you can just change the alias in the object map, instead of having to change every appearance of the locator in your test script. Silk Test Workbench will update all tests that reference the object map definition.

Example for mixing object map identifiers and locators

The following sample code shows how you can mix object map identifiers and locators to specify a rarely used child object of an object stored in an object map:
// VB
Window window = _desktop.Window("MyApplication") // object map id - the application window is used often
MenuItem aboutMenuItem = _desktop.MenuItem("@caption='About'") // locator - the About dialog is only used once
aboutMenuItem.Select()