Understanding the syntax of recorded script lines makes scripts easier to read. Commands that test objects are composed of identical syntax elements. The syntax elements include a With statement for the application windows, such as the main application window or dialog boxes, followed by a locator or object map item that identifies the class, attribute, and action.
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.
By default, Silk Test Workbench includes object map items in the script context when you record a script.
With _desktop.BrowserApplication("webBrowser") With .BrowserWindow("browserWindow") .DomListBox("quickLinkJumpMenu").Select("Auto Quote") End With End With
The With_ desktop.<application> portion identifies the main application window.
The DomListBox portion in the previous example identifies the class to use.
The ("quickLinkJumpMenu") portion identifies the attribute for the object. In this case, the attribute identifies the list box link menu. While the Select() portion identifies the action or command to perform against the object.
With _desktop.Window("untitledNotepad") .MenuItem("aboutNotepad").Select() With .Dialog("aboutNotepadDialog") .PushButton("ok").Select() End With End With
Object map items are enclosed in parentheses and quotation marks ("") and replace the need to use locator captions.
Within Silk Test Workbench, literal references to identified objects are referred to as locators. By default, Silk Test Workbench includes object map items in the script context when you record a script. If you turn off object maps, locators are included in the script context instead of object map items when you record a script.
With _desktop.BrowserWindow("/BrowserApplication[1]//BrowserWindow") .DomLink("@textContents='Court: Gender pay lawsuit can go to trial'").Select() End With
The With_ desktop.<application> portion identifies the main application window.
The DomLink portion in the first example and the MenuItem portion in the second example identifies the class to use.
The ("@textContents='Court: Gender pay lawsuit can go to trial'") portion identifies the attribute for the object. In this case, the attribute identifies the text content. While the Select() portion identifies the action or command to perform against the object.
With _desktop.Window("@caption='Untitled - Notepad'") .MenuItem("@caption='About Notepad'").Select() With .Dialog("@caption='About Notepad'") .PushButton("@caption='OK'").Select() End With End With
The caption attribute identifies the objects to test. The caption identifies the main application window ("@caption='Untitled - Notepad'") followed by the menu item ("@caption='About Notepad'"), the subsequent dialog box ("@caption='About Notepad'"), and the button ("@caption='OK'") to click.