When an action is recorded against an element from a web page or WPF application, Test Studio generates a Find Expression, which is then used to locate that element in the application during execution. The same process is triggered if an element is explicitly added to the Elements repository from the DOM explorer.
The basic component of elements' Find Expressions in Test Studio is the FindClause - this is a name-value pair connected with a comparison operator. The Find Expression consists of at least one FindClause and this can be verified when editing the element.
The 'name' portion of a FindClause pair can be any element's property that a certain technology (i.e. HTML, XAML) recognizes.
Any valid attribute name (id, name, etc.)
TextContent - search for an element in which has text that matches the specified expression.
InnerText - search for an element in which the InnerText matches the specified expression.
InnerMarkup - search for an element in which the InnerMarkup matches the specified expression.
OuterMarkup - search for an element in which the OuterMarkup matches the specified expression.
StartTagContent - search for an element in which the StartTagContent matches the specified expression.
NodeIndexPath - search for an element having the specified NodeIndexPath.
TagName - search for an element in which the TagName matches the specified expression.
TagIndex - search for an element at the specified zero based TagIndex.
XPath - search for an element at the specified XPath expression.
AutomationId - search for an element having an automation ID of a specific value.
TextContent - search for an element containing or not containing some text.
XamlTag - search for an element of a specific type.
XamlTagBase - search for an element that extends a specific type
Name - search for an element having a name of a specific value.
TagIndex - the zero based index value of a specific tag.
XamlPath - Uses a XAML path expression like XamlPath=/radtabcontrol[automationid=Tabs]/grid/raddockpanel/layouttransformcontrol[name=HeaderDockedElement]
Note! When editing an element in active recording session, all available element's properties will be listed and available for direct selection in the Find Expression.
The available comparison operators for each FindClause are: 'is exactly', 'contains', 'does not contain', 'starts with', 'ends with', 'matches the regular expression', 'is missing' and 'exists'.
The find expression of elements in Test Studio is also enhanced with corresponding images - each recorded element gets an image recorded along with its automatically generated find expression. The image will be used as a backup search criteria in case the element's find clauses didn't match any element on the page.
The test execution flow remains unchanged. The enhancement is that when an element fails to be located on page with its find expression within the set Elements Timeout, Test Studio automatically falls back to the element image search and continues as expected if the element is found using the predefined image. The execution results contain warning that the element's find expression didn't match any element on page and it was found by image.
The recorded image for each element can be edited separately from the find expression.
Note! Switching the Elements Edit pane to modify the image settings or recording new image, requires to save any current changes in the same element's Find Expression.
The main idea, when choosing the proper FindClauses and what comparison to apply, is to build a find expression, which points uniquely to a single element in the active application. Test Studio analyze the DOM tree and the structure of elements in it and strives to generate a unique find expression based on the current DOM tree.
For HTML application Test Studio relies on the Find Logic criteria list and its particular order. This can be adjusted on project level.
For hierarchical controls such as TreeViews, Test Studio creates chained find expressions.
Use unique elements' attributes, which are not dynamically generated to ensure a single element in the application will be pointed by this find expression.