What is the difference between LocatorGroupStrategy.CHAIN
and ALL_POSSIBLE
?
Can anyone explain with examples?
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.