I use Appium (appium.io) as framework for mobile app testing cross-platform (same app in iOS and Android).
In my code, the XPath selector is different for each platform (iOS and Android), for example:
By btnSearchMarketXPath = AppiumHelpers.BuildXPathPlatform(new XPathPlatform()
{
XPathAndroid4 = "//android.view.View[@content-desc='Search For a Market Link']",
XPathAndroid5 = "//android.view.View[@content-desc='Search For a Market']",
XPathAndroid6 = "//android.view.View[@content-desc='Search For a Market']",
XPathIOS7 = "//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAWebView[1]/UIALink[2]/UIAStaticText[1]",
XPathIOS9 = "//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAWebView[1]/UIALink[2]"
});
AppiumHelpers.Wait(10, btnSearchMarketXPath, true);
AppiumHelpers.GetScreenshot();
var btnSearchMarket = _driver.FindElement(btnSearchMarketXPath);
AppiumHelpers.GetCountXMLNodes(_driver.PageSource, true);
AppiumHelpers.Tap(btnSearchMarket);
(https://github.com/andremenegassi/ScriptTestingPaper2016/blob/master/UnitTestProject/FreshFoodFinder.cs)
How to implement the same test script for a hybrid application for iOS and Android platforms?
I need write the script 100% compatible for both platform.