Making Your Appium Tests Fast and Reliable - Part 2(Finding Elements)

January 19, 2026 · 12 min read · Tool Comparison

HeadSpin Platform
Automated & amp; manual testing made easy through information skill perceptiveness.
Differentiating capabilities:
  • Extensive end-to-end mechanisation of QA process
  • Comparative analysis of app performance against match
  • Continuous monitoring of app execution using synthetic data for higher availability of apps
  • Easy-to-use developer friendly program
cloudtest go
Affordable Existent Device Testing for Emerging Teams
cloudtest go
Affordable Real Device Testing for Digital Enterprises
cloudtest go
The Ultimate Solution for a Powerful Blend of Functional & amp; Performance Testing!
cyol
TEM
New
Centralized mobile test execution in cloud
cyol
Enhance Your Accessibility Testing With HeadSpin
cyol
Automate camera-based examination

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

retail

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎

Making Your Appium Tests Fast and Reliable - Finding ElementsMaking Your Appium Tests Fast and Reliable - Finding Elements

Making Your Appium Tests Fast and Reliable - Part 2 (Finding Elements)

Published on
June 6, 2018
Updated on
Published on
June 5, 2022
Updated on
 by 
 Jonathan LippsJonathan Lipps
Jonathan Lipps
This clause is the second in a multi-part series on test hurrying and reliability, animate by a webinar I afford recently on the same subject (you canwatch the webinar hither). You might also require to check out.

One of the biggest surface indicators of imbalance or flakiness is an factor not being institute. Finding element is a natural place for job to develop, because it is when we try to find an element that our assumption about an app & # x27; s state and its actual state are work together (whether in concordance or in struggle). We certainly require to avoid likely problems in finding component which we can do something about, for example habituate selectors that are not unique, or trying to find ingredient by some active attribute which can not be trust on. This means that noesis of your app and its plan are essential. What is likely to change? What isn & # x27; t? Which elements experience availableness IDs?

Check out:

Locator Strategies

Before going further, it & # x27; s worth saying what we mean by & quot; notice elements & quot;, and & quot; approachability ID & quot;, for example. In Appium (as with Selenium), actions can be guide on specific objects in the app UI. These object (corresponding to elements in a webpage, hence the gens of the findElement API command) must be & quot; found & quot; before it is possible to interact with them. There are different manner of find elements. Take a look at the illustration cry below:

find element command

In this exemplar,By.classNamesymbolise a so-called & quot; locator strategy & quot; called & quot; class gens & quot;, andButton correspond a & quot; picker & quot; which the scheme uses to find one or more elements. The result of this cry is (if all goes well) an object of typeWebElement, which comes with the rich set of interaction APIs you rely on for your examination.

Also chit:

& quot; Class gens & quot; is just one of a routine of locater strategies uncommitted in Appium and refers to a platform-specific UI object class name, for exampleXCUIElementTypeButtonor android.widget.Button. Already you can see that perhaps this locator strategy isn & # x27; t always ideal; what if you are? Would you need to have a different set of codification to bump an iOS button or an Android push? If you rely on the & quot; class name & quot; locater strategy, the response is yes.

There & # x27; s another job with this scheme: it & # x27; s often the case that there is more than one constituent of any give type in the hierarchy. Thus, you might very good findabutton with this locator strategy, but will it bethebutton you want? So, we could say that the & quot; grade name & quot; locator scheme is not a good choice because it is platform-specific (take to branched iOS and Android codification), and too general (difficult to unambiguously place an ingredient with). What other options are there? Have a expression at this table of the full set:

locator strategies

As you can see, many of the locater strategies were carried over from Selenium, though not all are support or even make sense in Appium (at least when automatise a aboriginal app). Appium has also acquaint a number of its own strategies, such as & quot; accessibility id & quot;, to reflect the fact (and take advantage of the fact) that we & # x27; re dealing with mobile app UIs and an all different automation stack.

Remotely examination and debug mobile, web, audio and picture covering on grand of devices around the world.!

XPath

SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses.

In another Appium Pro article, I go into detail about. To summarize hither, many people discover the XPath strategy attractive, because it vouch that any element in the UI can be launch. The trouble is that some elements can alone be found using selector that are & quot; brittle & quot;, meaning they are apt to find no element, or a different element, if anything change in your app & # x27; s blueprint. XPath can also be slow with Appium, because it entails sometimes multiple recursive renderings of the UI hierarchy.

Accessibility ID

What should we use alternatively? When potential, I advocate habituate the & quot; accessibility ID & quot; locator strategy, because it is (a) cross-platform, (b) unique, and (c) fasting. Both iOS and Android have the conception of an availability label, though on iOS it & # x27; s called & quot; accessibility ID & quot; and on Android it & # x27; s called & quot; content description & quot; (or & quot; content-desc & quot;). Since the availability label is a string set by developers, it can be a unique identifier. Of course, the point of setting accessibility label is for users, not for testers, so care must be taken. Setting good user-centric accessibility labels is usually sufficient to provide the kinds of identifiers testers too need, and that is the best recitation (i.e., set approachability labels on everything for users, and then take reward of this for testing). In the Appium Java node, finding component by availableness ID involves using theMobileBy strategy:

WebElement el = driver.findElement (MobileBy.AccessibilityID (`` foo ''));

Since testers don & # x27; t always receive the ability to influence the app & # x27; s development, sometimes approachability label are not usable, or are not unique. What else could we use?

Read:

iOS-specific Locator Strategies

In the same Appium Pro article I referenced earlier, I went into detail on some iOS-specific locater strategies that could be apply as a stand-in for XPath, because they are hierarchical query-based strategies. The most rich is the & quot; -ios grade concatenation & quot; strategy, which allows you to use a & quot; lite & quot; version of something like XPath, sundry together with iOSpredicate format strings.

The welfare of this locator strategy is that it allows for complex queries while remaining in most cases much speedier than XPath. The drawback, of course, is that it is platform-specific, so requires fork your code (or adding further distinctions to your object models). As an exemplar of what you can do, insure out this command:

String selector = `` * * /XCUIElementTypeCell [` gens BEGINSWITH `` C '' `] /XCUIElementTypeButton [10] ''; driver.findElement (MobileBy.iOSClassChain (picker));

What we & # x27; re make here is chance the 10th push which is a child of a table cell anywhere in the UI hierarchy which has a name beginning with the lineament & quot; C & quot;. That & # x27; s quite the inquiry! Because of the more rigid form of family chain queries, the performance guarantees are best than those of XPath.

Android-specific Locator Strategies

A like trick is uncommitted for Android, in the pretext of a exceptional parser the Appium team implemented which supports most of theUiSelectorAPI. We make this parser available via the & quot; -android uiautomator & quot; locator strategy, and the selectors should be string which are valid spot of Java code beginning withnew UiSelector (). Let & # x27; s have a look at an example:

String chooser = `` new UiSelector () .className (\ '' ScrollView\ '') .getChildByText (new UiSelector () .className (\ '' android.widget.TextView\ ''), \ '' Tabs\ '') ''; driver.findElement (MobileBy.AndroidUIAutomator (picker));

Once again, we get use of aMobileBy scheme since this strategy is usable only for Appium. What & # x27; s go on hither is that we have constructed a string which could be used as valid UiAutomator test code, but in fact will be parse and construe by Appium when the command is sent. According to the semantics of the UiSelector API, we & # x27; re allege that we require the inauguralTextView element we observe with the text & quot; Tabs & quot;, which is besides a fry of the firstScrollViewin the hierarchy. It & # x27; s a bit clunkier than XPath, but it can be used in similar ways, and again with a best execution profile in most cases.

Also read:

As with the iOS class chain scheme, the chief downside here is that selectors are locomote to be platform specific. (Additionally, we can & # x27; t support arbitrary Java and there are limits to what we can provide from the UiSelector API).

Determining Which Selectors to Use

So far, we & # x27; ve see some good passport on which strategies to use to find factor dependably. But how do you know which selector to use in co-occurrence with those strategies? I said before that knowledge of your app is required in order to do this correctly. How do you get that noesis of your app? If you & # x27; re one of the app developer, you can simply have a aspect at the code, or maybe you remember that you gave a sure element a sure availability label. If you don & # x27; t have access to the code, or if you want a method that will show you just what Appium understand in your app, then it & # x27; s best to useAppium Desktop.

Appium Desktop is a GUI tool for running Appium and visit apps. You can use it to launch & quot; inspector sessions & quot; with arbitrary desired capabilities. Inspector session shew you a screenshot of your app, its UI hierarchy (as XML), and lots of metadata about any element you take. It looks like this:

Appium Inspector

One of the great things about the Inspector is that, when you chatter on an factor in the hierarchy, it will intelligently suggest locater strategy and selector for you. In the image above, you can see that the top trace for the selected element is the & quot; accessibility id & quot; locator strategy, used in continuative with the selector & quot; Login Screen & quot;.

Things can get a bit more complex, certainly, but the Appium Desktop Inspector is always a great place to start when figuring out what & # x27; s going on with your app hierarchy. It & # x27; s especially useful if you run into issues where you believe an element should exist on a sure view: just fire up the Inspector and manually look through the XML tree to see if in fact the factor subsist. If it doesn & # x27; t, that imply Appium (read: the underlie) can & # x27; t see it, and you & # x27; ll need to ask your app developer why.

And that reason our discussion of finding elements dependably in Appium -- -or at least one aspect of it. Just because you can find an element with the right locator scheme doesn & # x27; t entail it will forever be there when you look. Make sure to also check out the next part, on (include the presence of constituent).

Author & # x27; s Profile

Jonathan Lipps

LinkedIn
Author & # x27; s Profile

Piali Mazumdar

Lead, Content Marketing, HeadSpin Inc.

Piali is a dynamic and results-driven Content Marketing Specialist with 8+ years of experience in crafting engross narratives and market collateral across diverse industries. She excel in cooperate with cross-functional teams to develop innovative content strategies and present compelling, authentic, and impactful message that resonates with quarry hearing and enhances brand authenticity.

LinkedIn

Making Your Appium Tests Fast and Reliable - Part 2 (Finding Elements)

4 Parts

regression intelligence blog
-

Regression Intelligence hardheaded guide for advanced user (Part 3)

Coming Soon
Regression Intelligence practical guide for advanced users
-

Regression Intelligence practical guidebook for advanced users (Part 4)

Coming Soon

Discover how HeadSpin can endow your business with superior essay capacity

Our Platform enables you to:
accelerate time-to-market
Accelerate time-to-market, benefit a competitory edge
faster development cycles
Boost developer/QA productiveness with faster development cycles
automated buil-over-build regression testing
Automate build-over-build regression testing for consistent issue
gain better visibility into functional & performance issues
Gain better visibility into functional and performance issues
reduce mean time
Reduce mean time to identify/resolve during test, QA, and production
evaluate audio, video & qoe
Evaluate sound, video, and content quality of experience (QoE) effortlessly
The trusted choice for planetary enterprises
Adobe
Hargreaves Lansdown
Truecaller
Crazylabs
Nedbank
Numeracle
Veryon
Close

Discover how HeadSpin can authorize your business with superior testing capabilities

Our Platform enables you to:
accelerate time-to-market
Accelerate time-to-market, gaining a competitive edge
faster development cycles
Boost developer/QA productivity with quicker development cycles
automated buil-over-build regression testing
Automate build-over-build fixation testing for coherent results
gain better visibility into functional & performance issues
Gain best visibility into functional and performance issues
reduce mean time
Reduce mean time to identify/resolve during test, QA, and production
evaluate audio, video & qoe
Evaluate sound, picture, and content quality of experience (QoE) effortlessly
The trusted choice for global endeavor
Close

Discover how HeadSpin can authorise your business with superior testing capability

Our Platform enable you to:
accelerate time-to-market
Accelerate time-to-market, gaining a free-enterprise edge
faster development cycles
Boost developer/QA productivity with faster growth round
automated buil-over-build regression testing
Automate build-over-build regression prove for consistent results
gain better visibility into functional & performance issues
Gain better visibility into functional and execution issues
reduce mean time
Reduce mean time to identify/resolve during test, QA, and production
evaluate audio, video & qoe
Evaluate audio, video, and contented caliber of experience (QoE) effortlessly
The trusted selection for global go-ahead
Close

Connet Now

Wipro LogoVMLYR Logo
Close
Book a Meeting
Products
footer down arrow
Solutions
footer down arrow
Industries
footer down arrow
Features
footer down arrow
Support
footer down arrow
Resource Center
footer down arrow
Why Choose HeadSpin?
footer down arrow
Copyright © 2026 HeadSpin, Inc. All Rights Reserved.

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free