Element Addressing
How an Appium test names the element it wants: each driver accepts a short strategy list, and that list splits into portable names and query languages only one platform understands.
on this pageshowhide
explore
- Cross-Platform Strategies15 questions
- Android Selector Dialects10 questions
- UiSelector Expressions5 questions
- View and Data Matchers5 questions
- iOS Query Languages8 questions
- Predicate Strings4 questions
- Class Chain Paths4 questions
- Locator Longevity14 questions
- App-Side Test Ids5 questions
- Hierarchy Snapshots4 questions
- Attribute Vocabularies5 questions
questions
page 2 of 2How would you write one Appium switch-state assertion that works on Android and iOS?
basics
~20 sMap the fact, not the attribute: hold one pair per platform - checked with true on Android's UiAutomator2 driver, value with 1 on iOS's XCUITest driver - normalise the reply to a boolean at the read, and assert on that.
In Appium, why does a `class name` locator that works on Android hit the wrong control on iOS?
basics
~20 sBecause the two vocabularies have different resolution. An Android class string such as android.widget.EditText is often narrow enough to hit one control, while the iOS equivalent XCUIElementTypeTextField is a coarse role shared by many, so the find returns the first of several.
In an Appium translation-glossary suite, an iOS locator finds nothing though the term is on screen — how do you triage?
basics
~20 sCapture GET /session/:sessionId/source at the moment of failure and search it for the term. If the node is absent, no XCUITest locator can match it: widen snapshotMaxDepth or snapshotMaxChildren, or fix the app. If present, the locator is wrong.
In Appium, why does a test id kept in Android's content-desc break on a copy change when an iOS accessibilityIdentifier does not?
basics
~20 sAndroid publishes one description field, so content-desc is both what an accessibility id locator matches and what the platform announces, and rewriting the copy rewrites the locator. iOS splits the two: accessibilityIdentifier holds the machine id and the label holds the text.
Why does a broken Appium `-android uiautomator` expression fail at find time rather than at build time?
basics
~20 sThe selector is an ordinary string that nothing in your build compiles. A misspelt matcher or a bad argument only surfaces when the UiAutomator2 server on the Android device parses the text during the find.
Your Appium Espresso `-android datamatcher` find for a hedgerow-survey row fails though the row is on screen — how do you triage it?
basics
~20 sWork three layers in order: the Android list may not be an AdapterView, so onData never applies; the matcher JSON may name a method or class the on-device Espresso server cannot resolve; or the matcher may match no data item.
In Appium, what does the limitXPathContextScope setting change on Android and on iOS?
basics
~20 sIt decides what an element-scoped xpath find is matched against: by default only that element's subtree, and when switched off the whole page source. Both the UiAutomator2 driver on Android and the XCUITest driver on iOS expose it.
An Appium xpath loop over 40 tram fare-inspection rows crawls on iOS but not on Android - why?
basics
~20 sEach xpath find serialises the hierarchy again, so 40 single finds cost 40 documents on both platforms. The iOS document is built from an XCTest element snapshot across the app boundary, so its unit cost is far higher than Android's.
Appium's `-ios class chain` is iOS-only — how do you keep one locator layer?
basics
~20 sOnly Appium's XCUITest driver accepts a class chain, so no path can be shared. Keep one method per element, resolve its locator per platform behind that method, and let the divergence live at a single named seam.
In Appium, how much should one `-ios predicate string` pin down, and why?
basics
~20 sPin the smallest set of attributes that makes the iOS match unambiguous — usually type plus one identifier. Every extra clause buys precision but costs a rewrite when that attribute changes, and makes a failure harder to read.
How would you get one test id into the Android and iOS fields Appium matches across a mixed-stack scouting badge-tracker?
basics
~20 sPick one field pair for the whole app, then make every stack fill it: Android resource-id or content-desc, and the iOS accessibilityIdentifier. Put the Android driver settings in the session profile, and verify per screen that the value reached the page source.
In an Appium hedgerow-survey suite, what does addressing Android views by Espresso matcher JSON cost you at scale?
basics
~20 sReach, paid for in coupling. Matcher JSON is code as a string, resolved reflectively on the device, so it fails at run time; it pins that part of the suite to Android's Espresso driver; and onData ties tests to the app's data model.
How would you budget xpath use in an Appium tram fare-inspection suite spanning Android and iOS?
basics
~20 sBudget by measured serialisations per platform, not a blanket rule. One xpath find on a shallow screen is affordable on both lanes; the same find inside a loop is wasteful on Android and a stall on iOS.
In Appium, what do shouldUseCompactResponses and elementResponseAttributes change?
basics
~20 sBoth settings control how much of an element comes back with a find. In compact mode the reply carries only the element identifier, so every attribute costs its own request; turning it off makes the driver inline the attributes named in elementResponseAttributes.
Why does Appium's `-android uiautomator` strategy have no Apple counterpart, and what warning ships with it?
basics
~20 sIt is a pass-through to Google's UiAutomator framework, which exists only on Android; Apple platforms have no equivalent, and Appium's XCUITest driver ships its own dialects. The driver's own documentation warns that Google intends to retire the underlying UiSelector API.
In Appium, which XPath dialect does Android's UiAutomator2 driver evaluate, and which does iOS?
basics
~20 sAndroid's UiAutomator2 driver evaluates XPath 2 by default and can be pushed back to XPath 1 with its enforceXPath1 setting. On iOS, WebDriverAgent evaluates XPath 1.0 only, and the XCUITest settings reference carries no equivalent switch.
showing 31–47 of 47