This came to mind reading a Selenium forum post.
Selenium WebDriver can support an XPath expression defined as such:
String locator = “//someXPathA | //someOtherXPathB”;
driver.findElement(By.Xpath(locator)).click();
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.