To create tests that use dynamic object recognition, you must use the Open Agent.
Silk Test Classic supports a subset of the XPath query language to locate UI controls.
The following table lists the constructs that Silk Test Classic supports.
Supported Locator Construct | Sample | Description |
---|---|---|
// | //a |
Identifies objects that are descendants of the current object. The example identifies hyperlinks on a web page. |
/ | /a |
Identifies objects that are direct children of the current object. Objects located on lower hierarchy levels are not recognized. The example identifies hyperlinks on a web page that are direct children of the current object. |
Attribute |
Example 1: //a[@textContents='Home'] Example 2: //div[@textContents='Price: * USD'] |
Identifies objects by a specific attribute. You can use the wildcards * and ?in the attribute value. Example 1 identifies hyperlinks with the text Home, Example 2 uses a wild card to identify a div with a price. |
Index |
Example 1: //a[3] Example 2: //a[@textContents='Home'][2] |
Identifies a specific occurrence of an object if there are multiple ones. Indices are 1-based in locators. Example 1 identifies the third hyperlink and Example 2 identifies the second hyperlink with the text Home. |
Logical Operators:
|
Example 1: //a[@textContents='Remove' or @textContents='Delete'] Example 2: //a[@textContents!='Remove'] Example 3: //a[not(@textContents='Delete' or @id='lnkDelete') and @href='*/delete'] |
Identifies objects by using logical operators to combine attributes. Example 1 identifies hyperlinks that either have the caption Remove or Delete, Example 2 identifies hyperlinks with a text that is not Remove, and Example 3 shows how to combine different logical operators. |
ancestor |
Example 1: //input[@id='username']/ancestor::form Example 2: //input[@id='username']/ancestor::div[@className='container'] |
Identifies ancestors, for example parent, grandparent, and so on, of an object. Example 1 finds the form element that has a child input element with the identifier username, Example 2 finds the div with the class name container that has a has a child input element with the identifier username. |
.. |
Example 1: //input[@id='username']/ancestor::form Example 2: //input[@id='username']/ancestor::div[@className='container'] |
Identifies the parent of an object. Example 1 identifies the parent of the hyperlink with the text Edit and Example 2 identifies a hyperlink with the text Delete that has a sibling hyperlink with the text Edit. |
following-sibling |
Example: //td[@textContents='John']/following-sibling::td[2] |
Identifies siblings after the current object. The example identifies the table cell which is located two cells to the right of the table cell with the text John. |
preceding-sibling |
Example: //td[@textContents='John']/preceding-sibling::td[2] |
Identifies siblings before the current object. The example identifies the table cell which is located two cells to the left of the table cell with the text John. |
* |
Example 1: //*[@textContents='Home'] Example 2: /*/a |
Identifies objects without considering their types, like hyperlink, text field, or button. Example 1 identifies objects with the given text content, regardless of their type, and Example 2 identifies hyperlinks that are second-level descendants of the current object. |
The following table lists the locator constructs that Silk Test Classic does not support.
Unsupported Locator Construct | Example |
---|---|
Comparing two attributes with each other. | //a[@textContents = @id] |
An attribute name on the right side is not supported. An attribute name must be on the left side. | //a['abc' = @id] |
Combining multiple locators with and or or. | //a[@id = 'abc'] or ..//Checkbox |
More than one set of attribute brackets. |
//a[@id = 'abc'] [@textContents = '123'] (use //a [@id = 'abc' and @textContents = '123'] instead) |
More than one set of index brackets. | //a[1][2] |
Any construct that does not explicitly specify a class or the class wildcard, such as including a wildcard as part of a class name. |
//[@id = 'abc']
(use //*[@id = 'abc'] instead) "//*//a[@id='abc']" |