The 'Android Data Matcher' Locator Strategy

January 12, 2026 · 9 min read · Mobile Testing

HeadSpin Platform
Automated & amp; manual testing made easygoing through data science insights.
Differentiating potentiality:
  • Extensive end-to-end automation of QA operation
  • Comparative analysis of app execution against peers
  • Continuous monitoring of app performance habituate synthetic data for high availability of apps
  • Easy-to-use developer friendly platform
cloudtest go
Affordable Real Device Testing for Emerging Teams
cloudtest go
Affordable Existent 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 testing

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

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

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

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

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

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

retail

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

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

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

Android Data Matcher Locator StrategyAndroid Data Matcher Locator Strategy

The & # x27; Android Data Matcher & # x27; Locator Strategy

Published on
November 13, 2019
Updated on
Published on
February 13, 2022
Updated on
 by 
 Jonathan LippsJonathan Lipps
Jonathan Lipps

One of the well-known limitation of finding elements on Android is that the Android UI renderer doesn & # x27; t actually build and render elements until they & # x27; re about to seem on the blind. What this means is that, if we are looking for an element which is far downward in a listing, and not yet visible on the blind, the element just does not & quot; exist & quot;. You can prove this to yourself by generating a source snapshot of your app while there are lots of list elements present below the edge of the screen. They won & # x27; t be thither! Let & # x27; s take as an illustration the ApiDemos app; let & # x27; s say we & # x27; re on the screen below, and want to tap on the & quot; Layouts & quot; item, which is not on the first screen & # x27; s worth of detail (you can see the first screen on the left, and how we had to scroll to get to & quot; Layouts & quot; on the right):

Check out:
scroll to layout

How do we handle a situation like this with Appium? Well, what I usually say is to & quot; think like a user & quot; -- how would a user find this item? By sneak to scroll the tilt, of course, and using their eyes to sporadically assure for the appropriate content. We could, thus, implement a scroll-and-find helper method with built-in retry loops. If we & # x27; re using the Espresso driver, nonetheless, there & # x27; s a better way: the & # x27; Android Data Matcher & # x27; strategy!

Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.

Accelerate Appium test round with the HeadSpin, a solution for mobile app automation.!

This strategy take advantage of the fact that Espresso runs in the app context, not on top of the Accessibility stratum, so it has access to the data which backs a leaning, not just the elements which are displayed on the screen. (In Android,ListViewsare a subtype of what & # x27; s called anAdapterView,which associate the listdatasource). We can use a part of the Espresso API to essentially target thisdata, and have Espresso automatically scroll to the element which represents that data for us.

As you can see in Appium & # x27; sData Matcher Guide, if we were expend Espresso directly (not through Appium), we might accomplish this feat with some code that looks like the pursuit:

onData (hasEntry (`` title '', `` textClock '') .inAdapterView (withId (`` android: id/list)) .perform (click ());

This Espresso codification waits for some & quot; information & quot; consort to the parameters we & # x27; ve given theonData dictation, namely that we want an debut which has a specific title, within the list that has a certain Android ID. The important bit here is thehasEntryfunction, which builds aHamcrest Matcher. The matcher is employ by Espresso to assist observe the desired data and turn it into a scene we can interact with.

Also check:

There are all kinds of matchers, which you can explore and use with Espresso, and now with Appium. So how do we do this with Appium? Basically, we postulate to use the -androiddatamatcherlocator strategy, which in Java is accessed asMobileBy.androidDataMatcher. And for the selector, rather than a mere string, we construct a JSON object containing the Matcher information,stringify it, and pass it as the selector. It & # x27; s a bit sneaky (or, how I like to think of it, a clever way of act within the W3C WebDriver protocol definitions for locator strategy chooser). Here & # x27; s how we & # x27; d construct the attempt to encounter the & quot; Layouts & quot; detail we saw in the screenshot above:

// first, find the AdapterView (not necessary if there 's only one) WebElement list = wait.until (ExpectedConditions.presenceOfElementLocated (MobileBy.className (`` android.widget.ListView ''))); // Construct the Hamcrest Matcher spec String chooser = new Json () .toJson (ImmutableMap.of (`` name '', `` hasEntry '', `` args '', ImmutableList.of (`` title '', `` Layouts ''))); // find and tick on the element habituate the androidDataMatcher selector list.findElement (MobileBy.androidDataMatcher (selector)) .click ();

As you can see, we have to do a bit of employment to codify the Hamcrest Matcher we want to use, by background itsname and args. What should the values hither be? Basically, whatever they would be in the raw Espresso case (the gens of the matchmaker ishasEntry, and its arguments aretitle and Layouts, because we & # x27; re trying to find an entry whose title is & # x27; Layouts & # x27;).

Read:

That & # x27; s essentially it! When you see this work, it & # x27; s pretty awesome -- the screen will jump real quickly to the expected item, without having to do a caboodle of manual scrolling. Below is a total representative, with two tests; one essay to find the & # x27; Layouts & # x27; item using XPath alone, which neglect (because the element is not on the blind), and a 2d test which succeeds because it uses this locater scheme. This strategy is an especially good surrogate for XPath when you only experience fond information about the element you require to find.

public class Edition095_Android_Datamatcher {private AndroidDriver driver; individual String APP = `` https: //github.com/appium/android-apidemos/releases/download/v3.1.0/ApiDemos-debug.apk ''; WebDriverWait wait; @ Before public nihility frame-up () throws Exception {DesiredCapabilities capabilities = new DesiredCapabilities (); capabilities.setCapability (`` platformName '', `` Android ''); capabilities.setCapability (`` deviceName '', `` Android Emulator ''); capabilities.setCapability (`` automationName '', `` Espresso ''); capabilities.setCapability (`` app '', APP); driver = new AndroidDriver (new URL (`` http: //localhost:4723/wd/hub ''), capability); wait = new WebDriverWait (driver, 10);} @ After public void tearDown () {if (driver! = null) {driver.quit ();}} @ Test public void testFindHiddenListItemNormally () {wait.until (ExpectedConditions.presenceOfElementLocated (MobileBy.AccessibilityId (`` Views ''))) .click (); wait.until (ExpectedConditions.presenceOfElementLocated (MobileBy.xpath (`` // * [@ content-desc='Layouts '] ''))) .click (); wait.until (ExpectedConditions.presenceOfElementLocated (MobileBy.AccessibilityId (`` Baseline '')));} @ Test public void testFindHiddenListItemWithDatamatcher () {wait.until (ExpectedConditions.presenceOfElementLocated (MobileBy.AccessibilityId (`` Views ''))) .click (); WebElement list = wait.until (ExpectedConditions.presenceOfElementLocated (MobileBy.className (`` android.widget.ListView ''))); String chooser = new Json () .toJson (ImmutableMap.of (`` name '', `` hasEntry '', `` args '', ImmutableList.of (`` rubric '', `` Layouts ''))); list.findElement (MobileBy.androidDataMatcher (picker)) .click (); wait.until (ExpectedConditions.presenceOfElementLocated (MobileBy.AccessibilityId (`` Baseline '')));}}

(Of class, you can invariably see thefull code samplingon GitHub!)

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 engaging tale and market collateral across diverse industry. She excels in collaborating with cross-functional teams to develop innovative content strategies and deliver compelling, authentic, and impactful content that resonates with target audiences and enhances brand legitimacy.

LinkedIn

The & # x27; Android Data Matcher & # x27; Locator Strategy

4 Parts

regression intelligence blog
-

Regression Intelligence pragmatic guidebook for advanced users (Part 3)

Coming Soon
Regression Intelligence practical guide for advanced users
-

Regression Intelligence practical guide for advanced users (Part 4)

Coming Soon

Discover how HeadSpin can endue 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 faster development rhythm
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 clip to identify/resolve during test, QA, and production
evaluate audio, video & qoe
Evaluate audio, picture, and contented quality of experience (QoE) effortlessly
The trusted choice for global enterprises
Adobe
Hargreaves Lansdown
Truecaller
Crazylabs
Nedbank
Numeracle
Veryon
Close

Discover how HeadSpin can empower your concern 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 faster development rhythm
automated buil-over-build regression testing
Automate build-over-build regression testing 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 calibre of experience (QoE) effortlessly
The sure choice for global enterprises
Close

Discover how HeadSpin can empower your concern 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 productiveness with quicker evolution cycles
automated buil-over-build regression testing
Automate build-over-build regression testing for logical results
gain better visibility into functional & performance issues
Gain better visibility into functional and performance issues
reduce mean time
Reduce mean clip to identify/resolve during tryout, QA, and product
evaluate audio, video & qoe
Evaluate audio, picture, and content quality of experience (QoE) effortlessly
The trusted choice for ball-shaped enterprises
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