Mobile Studio - Using the Object Spy
The Object Spy allows you to retrieve an XML dump of all elements present on the screen at a given moment.
With the dump, you can then generate XPath queries that are then be used in your testing. The object spy also allows you to inspect the nature of each element by presenting you with a full set of that element's properties.
When using the Object Spy to inspect the Native or Web elements of a specific page, the element tree is a representation of an XML file, with each element representing a node with different properties in the tree module. Continuous Testing gives you the option of using the XPath 1.0 language syntax in order to identify elements in the tree.
XPATH
XPath is a powerful query language for XML trees, which gives the ability to use multiple properties of both the element you are looking for and the elements around it (along with their relative location in the tree) in order to be able to always get the identification you are looking for throughout the automation scripts.
To learn more about the XPath language and how to use its syntax, visit w3schools.
:::Note
The Object Spy does not support regex-based search.
:::
Object Spy
To use the Object Spy you need to open the device in automation mode. For more information see Mobile Studio - Open a Device in Automation Mode.
Select Elements
You can click on any element to select it. Clicking on an element highlights it and show you its properties located in the XML tree:
The screenshot shows the Username field is clicked, hence the corresponding property is automatically selected in the Selected Element.
Obtain the Xpath
Once you click Copy Xpath the XPath is copied to the clipboard and is added to the XPath filter field so as to select the element.
Other than Xpath, object spy provides 2 other ways to identify the the UI Elements.
These are:
1. By ID
2. By AccessibilityId
Once you click Copy ID / AccessibilityId, it will be copied to the clipboard and will be added to the object spy filter.
Using Object Spy Filter
Other than Xpath, you can select and isolate elements by using a simple filters like:
- Filter by ID.
- Filter by Text.
- Filter by Accessibility Id
Change the filter from XPath to ID / Accessibility / Text → Enter the text to search.
Create XPath Using Element Properties
To retrieve several XPath queries of the different properties of an element:
-
Select the property for which you wish to obtain the XPath.
-
Click Add to Filter.
-
Repeat the process for other properties.
Different Types of Dumps
You can make these types of dumps:
- Instrumented Dump - XML dump that is retrieved when spying on an instrumented application
- Non-instrumented Dump
- Web Dump
Not all dumps are available in every app screen. Every screen can contain from only 1 of the dump type to all the three of it.
To check what all dump types are available in the screen, click on the dump selection dropdown. This contain all the dumps available on the screen.
Hide All is not a dump type. It's just an option given to hide all the dump information.