Supported XPath Subset

Silk Test Classic supports a subset of the XPath query language. Use a FindAll or a Find command followed by a supported construct to create a test case.

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

The following table lists the constructs that Silk Test Classic supports.
Supported XPath Construct Sample Description
Attribute MenuItem[@caption='abc'] Finds all menu items with the given caption attribute in their object definition that are children of the current context. The following attributes are supported:
  • caption (without caption index)
  • priorlabel (without index)
  • windowid
Index MenuItem[1] Finds the first menu item that is a child of the current context. Indices are 1-based in XPath.
Logical Operators: and, or, not, =, != MenuItem[not(@caption='a' or @windowid!='b') and @priorlabel='p']
. TestApplication.Find(“//Dialog[@caption='Check Box']/././.”) Finds the context on which the Find command was executed. For instance, the sample could have been typed as TestApplication.Find(“//Dialog[@caption='Check Box']”).
.. Desktop.Find(“//PushButton[@caption='Previous']/../PushButton[@caption=’Ok’]”) Finds the parent of an object. For instance, the sample finds a PushButton with the caption “Ok” that has a sibling PushButton with the caption “Previous.”
/ /Shell

Finds all shells that are direct children of the current object.

"./Shell" is equivalent to "/Shell" and "Shell".

/ /Shell/MenuItem Finds all menu items that are a child of the current object.
// //Shell Finds all shells in any hierarchy relative to the current object.
// //Shell//MenuItem Finds all menu items that are direct or indirect children of a Shell that is a direct child of the current object.
// //MenuItem Finds all menu items that are direct or indirect children of the current context.
* *[@caption='c'] Finds all objects with the given caption that are a direct child of the current context.
* .//MenuItem/*/Shell Finds all shells that are a grandchild of a menu item.
The following table lists the XPath constructs that Silk Test Classic does not support.
Unsupported XPath Construct Example
Comparing two attributes with each other. PushButton[@caption = @windowid]
An attribute name on the right side is not supported. An attribute name must be on the left side. PushButton['abc' = @caption]
Combining multiple XPath expressions with 'and' or 'or'. PushButton [@caption = 'abc'] or .//Checkbox
More than one set of attribute brackets. PushButton[@caption = 'abc] [@windowid = '123']

Use PushButton [@caption = 'abc and @windowid = '123'] instead.

More than one set of index brackets. PushButton[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. //[@caption = 'abc']

Use //*[@caption = 'abc'] instead.

"//*Button[@caption='abc']"