The Path Editor
As you might know, the RanoreXPath expression is a powerful identifier of UI elements for desktop and Web applications. To learn more about the RanoreXPath have a look at the section 'RanoreXPath'.
How to Access the Path Editor
It's this easy: Everywhere a RanoreXPath is visible in a Ranorex Tool you can edit this RanoreXPath with the path editor.
You can access the path editor by choosing any UI Element in the repository and then clicking the 'Edit button' on the left of the RanoreXPath, or alternatively by pressing the key shortcut <CTRL><E>.
Click the 'Edit' button to open the path editor
Switch to path editor tab
Layout of the Path Editor
Overview of path editor
Additionally you can see the number of identified UI elements using the given RanoreXPath in the status bar. Buttons to refresh and to highlight the identified elements can be found right above the tree view and the original RanoreXPath can be found at the top of Ranorex Spy, right below the modified one.
As you can see, the whole path is shown in this tree structure with each path element being a node of the tree. In the left section of the editor, you can access each of these path elements to alter the attribute comparisons in the right section on which the path is based.
After altering the RanoreXPath, you can review the effects by pressing the refresh and highlight buttons and apply the changes using the 'Apply' button next to the RanoreXPath at the top of Ranorex Spy.
Of course you can change the RanoreXPath by using the 'Track' button, too. To simplify tracking, the tracking area is limited to the parent folder of the selected repository item (grayed out in RanoreXPath at the top of Ranorex Spy), which will be indicated with a yellow border.
Tracking area limited to the KeePass application
The Tree View Section
As described above you can see the whole RanoreXPath you want to edit mapped as a tree structure. For example if you start KeePass and add two entries, one called 'WordPressDemo' and the other called 'GMail' and you track the cell holding the username of 'GMail', you will get the following tree structure in the path editor:
KeePass with one cell being tracked by Ranorex Spy
RanoreXPath structure in path editor for a cell in second row
The Attribute Comparison Section
Concerning KeePass and the data-driven approach (see ) we validated the success of 'Adding an entry' with the validation of the existence of the entry in the grid. Thus we add two sample entries (WordPressDemo and GMail) to KeePass. When Ranorex Spy is used to track the username of the GMail entry (second cell in the second row), the following structure of RanoreXPath results in the path editor window:
Uncheck the index attribute in the row node
Check the column index attribute
/form[@controlname='MainForm']/container[@controlname='m_splitHorizontal'] //table[@controlname='m_lvEntries']/row/cell[@text='Ranorex' and @columnindex='1']
The current path leads to two elements
The underlying path leads to two elements in KeePass
Types of Comparisons
Ranorex provides a set of comparisons which can be used to build up or to modify a RanoreXPath. These comparison operators can be accessed via a drop-down in path editor.
The following types of comparisons are defined for textual comparisons (case sensitive):
- '=': The value of the attribute must be equal to the given value
- '~': The value of the attribute must match the given regular expression
- '!~': The value of the attribute must not match the given regular expression
- ' !=': The value of the attribute must not be equal to the given value
- '>': The value of the attribute must start with the given string
The following types of comparisons are defined for numerical comparisons (starting with Ranorex Version 3.3):
- '>': The (numerical) value of the attribute must be greater than the given value
- '>=': The (numerical) value of the attribute must be greater than or equal to the given value
- '<': The (numerical) value of the attribute must be less than the given value
- '<=': The (numerical) value of the attribute must be less than or equal to the given value
Note Since the > operator is used for textual and for numerical comparisons as well, it depends on the type of the values you are trying to compare; i.e. whether the textual 'Starts with' or the numerical 'Greater than' functionality is used.
Example for Regular Expression
The following example shows how to use a 'regular expression' operator (~).
Matches all entries ending with the text fragment 'rex' using a regular expression
Result from the comparison above
Example for Starts With
The following example shows how to use the 'starts with' operator (>).
Matches all entries that start with 'adm'
Result from the comparison above
Example for Numerical Comparisons
The following examples demonstrates how numerical operators (>, >=, < and <=) can be used in the path Editor.
Matches all rows matching index > 2 and index <= 3
Result from the comparison above
The following relationship operators are available in the context menu of a node.
Available relationship operators in path editor
- child: Refers to all children of the current node
- descendant-or-self: Refers to all descendants (children, grandchildren, etc.) of the current node and the node itself
- ancestor: Refers to all ancestors (parents, grandparents, etc.) of the current node
- self: Refers to the current node
- descendant: Refers to all descendants (children, grandchildren, etc.) of the current node
- parent: Refers to the parent of the current node
- ancestor-or-self: Refers to all ancestors (parents, grandparents, etc.) of the current node and the current node itself
- preceding-sibling: Refers to all siblings before the current node
- following-sibling: Refers to all siblings after the current node
The following example describes,how to change the common parent-child relationship in the path using relationship operators ('Axis'), e.g. if you want to refer to a table row containing any cell with the text 'Amazon'. Using the common, directed way of building up a path, this wouldn't be possible. We start with the path referring to the cell:
We can now move back to the cell's parent using the 'parent' relationship operator. The parent element is a row, therefore we have to add a new level manually using the row adapter.
In the path editor we choose the relationship operator 'parent' in the 'Axis' submenu.
Contextmenu for defining the relationship operator for currently selected node
This path first describes the way to a cell containing the text 'Amazon' and moves up one level of hierarchy to the parent of this cell, which is a row. Highlighting the element leads to the result shown in following figure.
Highlighting the element from the newly created path
Adapters used within a path which are automatically suggested by Ranorex, can also be changed using the context menu.
Changing the adapter to a specific type of element
Optional Path Elements
In some situations it can be useful to mark parts of the path as optional. If you want to refer to the 'Windows' node within the folder tree in KeePass, this node can be located at the root level but, on the other hand, it could also be located in a sub node of the tree.
Windows node located at the root level (left) or...
...in a sub-node of the tree (right) in KeePass
Marking one level of the path as optional
If you start the path editor from an existing repository, there is an additional button for each (selected) attribute comparison. With these buttons you are able to define variables which can be used for data driven object identification.
Buttons for creating a new variable for every selected attribute
Variables can also be created using the 'As new Variable' entry in the dropdown menu
Live View with Dynamic Capabilities and Offline View
One additional thing to mention is that if you are in live view, you get more information delivered about the adapter you are working on than in offline view.
Offline view means working with a snapshot file or working with a repository holding information from a non-running application.
Note A Ranorex Snapshot file is able to keep the entire UI structure, the UI element's attributes and its belonging values as well as screenshots from the desired element and all its child elements. Learn more in the chapter: Creating Ranorex Snapshot Files.
In 'live' view you are additionally able to use the 'verify' and 'highlighting' functionality.
Starting with Ranorex Version 3.3, you are also able to access dynamic capabilities from adapters in live view. The following screenshot shows dynamic capabilities from the mainform of KeePass (WinForms).
Path editor window in live view having dynamic capabilities
Note Dynamic capabilities can only be accessed for certain types of technologies (WinForms, Flash/Flex, Web and Java).