TouchTest Location Strategies

Document created by Dave Murphy Employee on Jul 20, 2017
Version 1Show Document
  • View in full screen mode

TouchTest dynamically determines locators during a TouchTest recording session. First, TouchTest tries each strategy to see if we get a locator that works. The first strategy that returns a working locator is used. Although this order can't be customized, the Touch Locator tool can be used to select from among the possible locators.

The order of precedence for locators within TouchTest is:

  • id
  • placeholder
  • xpath (if it contains a touchTestId)
  • text
  • Accessibility label
  • tag

Note: After iterating the above order of precedence, we recurse in child elements for that same order of locators. If nothing is found yet, then we do the "last resort" which is Xpath (if it has a class that is the only one of its type) followed by classname followed by the full Xpath.

Location Strategies Reference

The following location strategies can be defined at the target level for a given clip and are case-insensitive.

kindof

Usage:

kindof=UIButton, kindof=UIButton[2]

Locates elements that are a subclass of the specified class. For example, kindof=UIButton will find UIButtons as well as UIRoundedRectButtons.

classname

classname=RoundedRectButton, classname=RoundedRectButton[2]

Locates elements that are of the specified class. For example, classname=UIButton will find only UIButtons and not UIRoundedRectButtons.

xpath

Usage:

//UITableView//UILabel[@text="Carbon"]
//UITableViewCell[UITableViewCellContentView/UILabel[@text="Pickers"]]/UIButton
//UIDatePicker[@touchTestId="DatePicker"]//UIPickerTableView[0]

XPath locators must start with //. They allow you to find any element in the XML view hierarchy. Use the outputXmlHierarchy accessor to see the XML to which the XPath is applied.

partialText

Usage:

partialText=for all good men 

Locates elements that contain the specified text.

textStartsWith

Usage:

textStartsWith=Now is the time

Locates elements that have text that starts with the specified text.

textEndsWith

Usage:

textEndsWith=aid of their country.

Locates elements that have text that ends with the specified text.

text

Usage:

text=Login

Locates elements that have text that matches the specified text exactly.

index

Usage:

index=20

Locates elements that have the specified index in the view hierarchy. This strategy is usually used in conjunction with other strategies and is assumed if no strategy is given (i.e. UIButton[2] is the same as UIButton[index=2].

placeholder

Usage:

placeholder=User name

Locates elements that have a placeholder property that matches the specified text. UITextFields have placeholder text which displays when there is no other text in hte text field. 

touchTestId

Usage:

id=yellowSquare

Locates elements that have a touchTestId property that matches the specified text. TouchTestIds are strings set by the developer to identify views in the application for testing.

accessibilityLabel

Usage:

accessibilityLabel=User name

Locates elements that have an accessibility label that matches the specified text. Accessibility labels can only be used when the device has the VoiceOver accessibility feature turned on.

tag

Usage:

tag=20

Locates elements that have a tag property that matches the specified integer. Tags are an integer set by the developer to identify views in the application.

ttxp (deprecated)

Usage:

ttxp=//UIButton[2]
       ttxp=//UITableView//UILabel[text=Carbon]
       ttxp=//UITableView//AtomicElementTableViewCell//UILabel[text=Carbon]

ttxp locators are a deprecated strategy that was used before xpath locators were available. They are a pseudo-xpath which allow you to find elements from a starting point in the view hierarchy.

Attachments

    Outcomes