Does Appium support multi-value XPath for location strategy?

This came to mind reading a Selenium forum post.

Selenium WebDriver can support an XPath expression defined as such:

String locator = “//someXPathA | //someOtherXPathB”;

where if either XPath expression is matched, then the locator can be found. This is also testable from the browser developer console too.

I’m just curious whether the same technique can work for Appium. Although I don’t really know if there is any use case to that approach, but here are 2 possibilities:

  • A/B testing of a mobile app (A version has this locator, B has that). This might be applicable more for web views and such than native code

  • Sharing code base that is used for both desktop web testing and mobile web/app testing (e.g. single page object to represent both the desktop and mobile views, or both the website and the native mobile app)

It would be awesome if this multi-value XPath works in Appium web view and native app view, for both iOS and Android.

use @FindAll or @FindBys :slight_smile:

What does @FindBys do? And which location strategies does it work with?

Also, bear in mind that while the example was in Java, I’m referring to a cross language solution, @FindAll, @FindBys sounds like Java centric attributes option? In which case, what about Python, Ruby, etc.?

What does @FindBys do? - looking for each FindBy inside FindBys to present.

@FindAll, @FindBys sounds like Java centric attributes option? - looks like only Java.


What driver we need to use to access FindBys? Can you post a syntax or sample code if you would have used?

you can choose any:

Can this be implemented other than page factory?

possible but much more code needed. e.g. use waitUntil for first search then check that other property exists in found element. if not do again waitUntil and check always that some given timeout not exceeded.