Identifying DOM Elements in Browser-Driven Testing

Within a browser, all visible and invisible elements of a Web page are represented as a hierarchical tree of objects, the Document Objects Model (DOM). To interact with elements of a Web page, Silk Performer uses the concept of object identifiers, so-called locators. Locators are XPath query strings that identify one or more elements of the current DOM. For additional information about XPath, see

All API calls that interact with DOM elements take a locator as an input parameter. For example, the API call BrowserLinkSelect(“//a[@href=’’]”) uses the locator //a[@href=’’] which identifies the first link that has as the value of its href attribute (for example, <a href=””>My Link</a>).

The following table lists all XPath constructs that are supported by Silk Performer:

Supported XPath Construct Sample Description
Attribute a[@href='myLink'] Identifies all DOM Links with the given href attribute that are children of the current context. All DOM attributes are supported.
Index a[1] Identifies the first DOM link that is a child of the current context. Indices are 1-based in XPath.
Logical Operators: and, or, = a[(@href='microfocus' or @caption != 'b') and @id='p']
. .//div[@id='menuItem']/. The" ." refers to the current context (similar to the well known notation in file systems. The example is equivalent to //div[@id='menuItem']/
.. //input[@type='button']/../div Refers to the parent of an object. For example, the sample identifies all divs that contain a button as a direct child.
/ /form Finds all forms that are direct children of the current object. ./form is equivalent to / form and form.
/ /form/input Identifies all input elements that are a child of a form element.
// //input[type='checkbox'] Identifies all check boxes in a hierarchy relative to the current object.
// //div[id='someDiv'//input[type='button'] Identifies all buttons that are a direct or indirect child of a div that is a direct or indirect child of the context.
/ //div Identifies all divisions that are direct or indirect children of the current context.

The following table lists the XPath constructs that Silk Performer does not support.

Unsupported XPath Construct Example
Comparing two attributes to one another a[@caption = @href]
Attribute names on the right side are not supported. Attribute names must be on the left side. a['abc' = @caption]
Combining multiple XPath expressions with and or or. a [@caption = 'abc'] or .//input
More than one set of attribute brackets div[@class = 'abc'] [@id = '123'] (use div[@caption = 'abc' and @id = '123'] instead)
More than one set of index brackets a[1][2]
Wildcards in tag names or attribute names */@c?ption='abc'
Logical operators: not, != a[@href!='someValue'], not[@href='someValue']
Any construct that does not explicitly specify a class or the class wildcard. For example, including a wildcard as part of a class name. //[@caption = 'abc']

The following list shows wildcard examples that match //[@caption ='abc def']: