Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between LocatorGroupStrategy.CHAIN and ALL_POSSIBLE in appium?

What is the difference between LocatorGroupStrategy.CHAIN and ALL_POSSIBLE?

Can anyone explain with examples?

like image 938
Navi Cheema Avatar asked Jan 23 '26 21:01

Navi Cheema


1 Answers

ALL_POSSIBLE: it will match the first locator strategy among the locators you have provided for example :

@HowToUseLocators(androidAutomation = ALL_POSSIBLE, iOSAutomation =
ALL_POSSIBLE)
@FindAll{@FindBy(someStrategy1), @FindBy(someStrategy2)})
@AndroidFindBy(fakeID1) @AndroidFindBy(someStrategy2)
@iOSFindBy(fakeID1) @iOSFindBy(someStrategy2)
MobileElement someElement;

So in above example if the locator is found by @FindBy(someStrategy1) then it will stop locating the next elements and perform the execution for the first found element.

CHAIN : first finding first locator then inside second and so on. for example,

@FindBys({@FindBy(someStrategy1),
@FindBy(someStrategy2)})
@AndroidFindBy(parent)
@AndroidFindBy(child)
@iOSFindBy(parent)
@iOSFindBy(child)
MobileElement someElement;

In above code, if you are automating android app, then it will first find the @AndroidFindBy(parent) and then it will find the @AndroidFindBy(child).

I hope this is clear to you.

like image 119
Suraj Jogdand Avatar answered Jan 27 '26 01:01

Suraj Jogdand



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!