Find and validate objects with Object Spy

Object Spy helps you create automated tests by providing information about object locators or identifiers. Object Spy provides a quick snapshot of your native app, hybrid app, or website. With Object Spy, you can explore objects on the device screen and view them in the Object Spy pane to the right of the device. The object tree presents a hierarchical view of all objects retrieved from the webpage or app.

Restriction: Objects identified with Object Spy may not be aligned as expected. This is a general issue with iPad devices that only affects the home screen. The issue is caused by invalid information returned from Apple's XCTest framework.

In addition, you can use Object Spy to configure, filter, or download the object tree, search the object tree and validate object locators, view object properties, and perform actions on the device or add commands to the test.

To learn how to work with Object Spy in Scriptless Mobile, watch this video or review the instructions following the video.

Turn Object Spy mode on or off

When you open Object Spy, the Object Spy mode toggle above the open device is turned on by default. To turn off Object Spy mode, click the toggle.

In Object Spy mode, you can select elements on the device screen to find them in the object tree, and vice versa. When an element is selected, a menu appears below the selected element on the device, as shown in the following image. You can use this menu to perform an action on the selected element on the device or to add a command to the test, or both. For details on the available options, see Run and add commands.

Object menu below selected element in Object Spy mode

When Object Spy mode is turned off, there is no correlation between the object tree and the device. In this case, you can perform actions on the device, such as opening an app or browsing to a URL, just like you would during normal interactive testing without Object Spy.

Configure, filter, or download the object tree

You can simplify the object tree by configuring the maximum number of children included in the tree or by filtering the tree by specific object types: buttons, edit fields, images, links, text, or other objects. By default, all objects are shown in the object tree. However, if you limit the number of children or filter the tree, the object that you select on the device might be hidden in the tree.

Filtering is helpful when the tree is long and complex and you want to focus on specific objects. When a filter is applied, the object tree reverts to a flat view. A hierarchical view is available only when all objects are displayed.

You can also download the entire object tree as an XML file or HTML file (for web views) for offline use.

Search and validate

With Object Spy, you can search an object tree by specifying an object property. If the search brings up results, the number of objects found is displayed next to the search field. You can use the < Prev and Next > buttons to browse through the results.

In addition, you can use Object Spy to validate object locators to make sure they are strong. Strong locators are an important component of reliable tests.

Tip: To spy for objects on another screen of your app or webpage, close Object Spy, navigate to the new screen, and then open Object Spy again.

View object properties

To view object properties, you can select an object on the device screen and click Object Info at the top. Many object parameters are displayed, for example:

  • Smart locator (formerly referred to as object locator)
  • Object type
  • Xpath
  • X and Y coordinates
  • Height and width
  • Identifier
  • Name
  • Label
  • Type
  • Value
  • Resource ID
  • Package
  • Origin class
  • Class

For Boolean properties, the pane provides information on whether they are turned on (indicated by a green checkmark ) or off (indicated by the general prohibition sign ). 

You can copy a path or property to the clipboard to embed it in your automated tests.

Run and add commands

In Object Spy mode, you can run a command on the selected element on the device, add a command to the test, or both. In the process, you can also configure parameter values as needed.

When you click an object on the device screen, a menu with the following options appears:

Click element

Enter text

Find element

View element info

Run the command on the device

Add the command to the test

Apply the selection