Selector Type List
- Selector values should be obtained via Appium Inspector.
- Selector values must be unique to prevent errors during test execution.
General Selectors
id
Locates elements using their id attribute.
Most efficient selector when unique id's are available.
Selector Value: login_button
Primary selector for Android (resource-id) and iOS (name / accessibility id).
Set selector value login_button (from full id com.company.appName:id/login_button)
className
Finds elements by their class name.
Returns first match if multiple elements share the class.
E.g ⤵️
Android: android.widget.Button
iOS: XCUIElementTypeButton
Selector Value: android.widget.Button
cssSelector
Advanced element targeting using CSS syntax.
Supports combinations of tag, class, ID, and attributes.
Only Webview elements for mobile apps.
Same as web CSS selectors for hybrid apps.
Selector Value: input.login-field
linkText
Locates anchor tags by exact visible text.
Case-sensitive matching of link content.
Selector Value: Sign Up
partialLinkText
Finds links containing partial text matches.
Useful for dynamic link text.
Selector Value: Up
name
Targets elements by name attribute.
Commonly used for form inputs.
Selector Value: email
tagName
Selects elements by HTML tag type.
Returns first matching element.
Selector Value: h1
xpath
Advanced element location using XML path syntax.
Supports complex hierarchy navigation.
Selector Value: ⤵️
- //button[@id='submit-button']
- //XCUIElementTypeButton[@name="menu"]/*[1]
- //*[contains(@resource-id,"checkbox")]
text
Finds elements by exact visible text.
Case-sensitive matching.
Selector Value: Welcome to Testmore!
Custom Selectors
customByIdAndIndex
Handles duplicate id's by index position.
Selector Value: user-list/2
(Finds 3rd element with id "user-list")
customByClassNameAndIndex
Finds nth element with specified class.
Zero-based index position.
Selector Value: android.widget.TextView/1
(Finds 2nd element with class "android.widget.ImageView")
customByClassNameAndText
Precise combination of class and exact text.
Case-sensitive text matching.
Selector Value: alert/Error occurred
customByClassNameAndContainsText
Class with partial text content match.
Flexible for dynamic content.
Selector Value: XCUIElementTypeStaticText/Success
customByIdAndColor
Verifies elements by ID and CSS color.
Hex color format required.
Selector Value: android.widget.ImageView/#00ff00