The object spy is a feature unique to SeeTest Automation. It allows you to retrieve an XML dump of all the elements that are present on the screen at a given moment. With the dump, you can then generate XPath queries that will then be used in your testing. The object spy also allows you to learn about 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. SeeTest gives the user the option of using XPath 1.0 language syntax in order to identify elements in the tree.
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, please visit w3schools.
Opening the Object Spy
To bring up the object spy, in SeeTest Automation Web Interface, click on the Automation tab and then on the object spy button.
The object spy will then open on the right-hand side of the screen and will immediately highlight and list all the elements that are present on the screen:
Selecting Elements in the Object Spy
You can then click on any element to select it. Clicking on an element will highlight it and show you its properties located in the XML tree:
Obtaining Xpath from the Object Spy
Clicking on "Copy Unique Xpath" saves you the time in figuring out the XPath your self:
Once you click on "Copy Unique Xpath", the XPath is copied to the clipboard, and added to the XPath field at the bottom of the object spy so as to select the element:
You can also select and isolate elements by using a simple text query instead of XPath, Simply change from XPath to text, by clicking on the drop-down at the bottom left-hand side, and enter the text according to which an element will look for:
If you wish to retrieve several XPath queries of the different properties of an element, instead of obtaining the unique XPath you can go with the option of "Add to Filter". Select the property for which you wish to obtain the XPath and click on "Add to Filter". Repeat the process for other properties if necessary:
Different Types of Dump
There are three different types of the dump:
- Instrumented Dump - the XML dump that is retrieved when spying on an instrumented application
- Non-instrumented Dump
- Web Dump
You are testing an instrumented application and want to remove non-instrumented dump (for example the phone's status bar), you can choose to remove the non-instrumented dump. Additionally, if you are testing a hybrid app (one that combines native and web elements) you can remove either of the three in order to minimize the dump and make it easier for you to locate elements.
Toggle the button on and off to hide or show the dump:
Similarly, you can choose which dump to show when testing hybrid applications or when testing mobile websites: