Repository navigation
fix: try later ALL_POSSIBLE widget roots when a nested lookup misses - #2493
Open
Ganesh2325 wants to merge 1 commit into
Open
Ganesh2325 wants to merge 1 commit into
Ganesh2325 wants to merge 1 commit into
Conversation
Ganesh2325
requested review from
SrinivasanTarget,
mykola-mokhnach,
saikrishna321 and
valfirst
as code owners
November 3, 2026 07:09
A widget with several alternative locators kept the first matching root. Nested locators were searched only inside that root, so an element that exists only under a later widget locator was not found. Fixes appium#1816
cursor
Bot
force-pushed
the
cursor/fix-widget-multiple-locators-7a1e
branch
from
November 3, 2026 07:15
6206e61 to
a7f3320
Compare
1 task done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change list
@HowToUseLocators(... = ALL_POSSIBLE)or@AndroidFindAll, and the same shapes on other platforms), a nested lookup that misses inside the first matching root is retried against each later root.WidgetMultipleLocatorLookupTest, a device-free unit test for the combinations reported in Widget: Not all element look up options work when using multiple locators #1816.Fixes #1816
Types of changes
Details
Repro
Widget field:
Nested element:
widget1is present and contains neither nested element.widget2is present and containselement2. Calling a widget method that readselementthrewNoSuchElementException. The only lookups werewidget1 -> element1andwidget1 -> element2.The same miss happens with
@AndroidFindAllon the widget and on the nested element. Ifwidget1does not exist at all, the second root was already used. Chained@AndroidFindBypairs still describe one path and do not fall through.Root cause
ByAll.findElementreturns the first root that matches and stops. The widget is bound to that element, and nested locators run only inside it. A miss on the nested locators was never a reason to try the next widget locator.WidgetInterceptornow catches thatNoSuchElementExceptionand repeats the widget method against the first element of each later alternative locator.@AndroidFindAllis stored as a one-locator chain around aByAll, so that wrapper is unwrapped before the alternatives are read. A chain of more than one locator is left alone.Test command
./gradlew test checkstyleMain checkstyleTest javadocBUILD SUCCESSFUL in 33s. 234 tests, 0 failures, 0 errors, 0 skipped.
checkstyleMain,checkstyleTest, andjavadocpassed.This change was AI-assisted; I reviewed and tested it myself.