This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 2
Nov 2017

Using Page Object Pattern and its annotations to find a particular element, however this element has different possibilities, I tried to use all the locator strategies explained in this page:

The problem with (ALL_POSSIBLE) strategy is that it will get all the result of all strategies that apply, for example:
@HowToUseLocators(androidAutomation = LocatorGroupStrategy.ALL_POSSIBLE)
@AndroidFindBy(xpath = “strategy1”, priority=0)
@AndroidFindBy(xpath = “strategy2”, priority=1)
@AndroidFindBy(xpath = “strategy3”, priority=2)
@AndroidFindBy(xpath = “strategy4”, priority=3)
List elements;

It might return a list of elements that apply for 2 of the above strategies while i presumed that it will only return the result of the first successful strategy according to the defined priority.

Is there a workaround for this?

Thanks in advance.

  • created

    Nov '17
  • last reply

    Nov '17
  • 1

    reply

  • 900

    views

  • 1

    user

  • 1

    link

After looking into the source of the Java client, I think it will apply the first one if was fetching for a particular MobileElement but in my case, I’m fetching a list of MobileElements which results in applying all BYs and getting their results instead of getting the first successful match.