Skip to content

fix(appium): prefer exact text matches over substring in page-source filters - #161

Open
nt-ben-leblond wants to merge 1 commit into
devicelab-dev:mainfrom
nt-ben-leblond:fix/appium-exact-text-first
Open

fix(appium): prefer exact text matches over substring in page-source filters#161
nt-ben-leblond wants to merge 1 commit into
devicelab-dev:mainfrom
nt-ben-leblond:fix/appium-exact-text-first

Conversation

@nt-ben-leblond

Copy link
Copy Markdown
Contributor

What

On the Appium driver path, FilterBySelector's literal-text matching used case-insensitive CONTAINS only. A plain selector like text: "0" therefore resolved to the first node whose text merely contains 0 (e.g. a trading order ticket's price field "7000.00") ahead of the element whose text is exactly "0" (the leg switch).

That broke real flows on Sauce/Appium: WebViews expose price-field text that the uiautomator2/devicelab drivers never surface, so the same flow passes on a local/dcd device and fails on Appium with the tap landing in the wrong field (and downstream state corruption).

Change

Literal text now prefers exact matches:

  • When any element matches the literal text exactly, only those elements are returned.
  • Otherwise the existing contains semantics apply (genuine substring usage keeps working).
  • Regex selectors are untouched (looksLikeRegex gate).

Tests

  • New regression test: text: "0" over elements ["7000.00" (price field), "0" (switch), "Limit"] resolves to the switch, while a non-exact literal still matches by contains.
  • TestFilterBySelector_Android / TestFilterBySelector_iOS updated to the new exact-first contract.
go test ./pkg/driver/appium/...

Impact

Text selectors that target full labels (the common case, e.g. text: "Good till Cancel") are unaffected — exact matches simply take precedence. Only flows that relied on an exact node ALSO existing when a substring matched could see a different (more specific) selection.

…filters

FilterBySelector matched literal text selectors with case-insensitive CONTAINS only. On the Appium path that makes a plain selector like text: "0" resolve to the first node whose text merely contains 0 (e.g. a trading ticket price field "7000.00") ahead of the element whose text is exactly "0" (the switch), corrupting the flow — the TT-ticket failure seen through Sauce/Appium, where the webview exposes price text that the uiautomator2/devicelab drivers never surface.

Literal text now prefers exact matches: when any element matches exactly, only those are returned; otherwise the existing contains semantics apply. Regex selectors are untouched. Adds a regression test for the price-field vs switch case and updates the FilterBySelector contract tests.
@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.62500% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/driver/appium/pagesource.go 90.62% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant