Skip to content

devicelab driver maps Maestro text: selector to UiSelector.hintMatches instead of textMatches #90

@simon-kuzin

Description

@simon-kuzin

Description

The devicelab driver incorrectly maps Maestro's text: selector to Android UIAutomator's hintMatches() instead of textMatches(). This causes tapOn: "OK" and similar text-based selectors to fail when targeting standard Android dialog buttons (e.g., AlertDialog.setPositiveButton()), which have visible text but no hint attribute.

Error

When running a flow with --driver devicelab:

✗ tapOn: text="OK" (12.7s)
  ╰─ Element not found: handler_error: Element not found: -android uiautomator=new UiSelector().hintMatches("(?is).*\QOK\E.*")

The selector uses hintMatches() to search for "OK", but AlertDialog positive buttons have text "OK" (from android.R.string.ok), not a hint attribute.

Expected behavior

The text: selector should map to UiSelector().textMatches("(?is).*\\QOK\\E.*") (or similar text-based matching), consistent with how the default uiautomator2 driver handles it.

The default --driver uiautomator2 works correctly — it uses textMatches and successfully finds the button via tapOn: "OK".

Steps to reproduce

appId: any.app
---
# After any action that opens an AlertDialog with positive button:
- tapOn: "OK"

Run with:

maestro-runner --driver devicelab --platform android test flow.yaml

Environment

  • maestro-runner version: 1.1.16
  • Platform: android (SDK 31 emulator)
  • Driver: devicelab

Workaround

Use --driver uiautomator2 (the default) instead of --driver devicelab, which correctly handles text-based selectors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions