Skip to content

feat(android): add UiAutomator2 and Espresso locator strategies - #1188

Open
KazuCocoa wants to merge 1 commit into
mainfrom
feat/android-locator-strategies
Open

KazuCocoa wants to merge 1 commit into
mainfrom
feat/android-locator-strategies

Conversation

@KazuCocoa

Copy link
Copy Markdown
Member

PR title

feat(android): add UiAutomator2 and Espresso locator strategies

Related issue

Closes #1187

List of changes

  • Add MobileBy.AndroidPredicateString and MobileBy.AndroidClassChain for UiAutomator2.
  • Add MobileBy.AndroidText and MobileBy.AndroidViewTag for Espresso.
  • Cover the strategy name and selector value sent by both FindElement and FindElements for all four locators.

Types of changes

  • New feature (backwards compatible)

Tests

  • Unit tests
  • Device integration tests

The Release build passed for all target frameworks. All 92 tests in the device-free .NET 8 CI filter passed on macOS, including the four new cases in Tests.Common. The build reported an existing platform warning in the iOS clipboard test. Windows .NET Framework tests and Android device tests were not run locally.

Documentation

The new public factories include XML documentation identifying the driver and, for UiAutomator2, the minimum supported version. The driver references document selector syntax. UiAutomator2 locators · Espresso locators

Details

For example, a UiAutomator2 session can find a button by predicate on driver version 10.2.0 or later.

var button = driver.FindElement(MobileBy.AndroidPredicateString("text == 'Settings' AND clickable == true"));

Copilot AI balanced review requested due to automatic review settings November 26, 2026 17:27
@KazuCocoa
KazuCocoa requested a review from Dor-bl November 26, 2026 17:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the four added Android locator strategies.

No open issues 🎉

What changed in this PR

Adds four Android locator strategies to the Appium .NET client, addressing #1187 with new MobileBy factories for UiAutomator2 and Espresso.

Changes:

  • Adds predicate-string and class-chain locators for UiAutomator2, plus text and view-tag locators for Espresso.
  • Documents driver requirements and minimum UiAutomator2 versions.
  • Adds tests verifying strategy names and selector values for both FindElement and FindElements.
File Description
test/​integration/​Common/​MobileByFactoryTest.cs Tests forwarding of all four locator strategies and selector values.
src/​Appium.Net/​Appium/​MobileBy.cs Adds documented factories and locator classes.
src/​Appium.Net/​Appium/​Enums/​MobileSelector.cs Defines the four locator strategy strings.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]: Support more locator strategies

2 participants