
Mobile application testing comes with its own set of challenges. For example, it is preferable to automate the functional regression test cases since they typically consume a huge chunk of your testing time. However, running automated regression tests (on a deadline) for hybrid mobile apps can be challenging. We faced this very challenge while testing a hybrid mobile app for the hospice industry, and we’re going to talk about how we handled it.We used Appium to create a single test script for multiple platforms.This blog is a step by step guide to setting up and using the Appium server for hybrid mobile application development. We’ll talk about the complete installation of the latest Appium version (1.6.4). As of today, this is the only version which supports Android 7 (Nougat) and iOS 10.3.
Appium is an open-source automation tool that can be used to automate native and hybrid mobile applications for both iOS and Android platforms. With Appium, cross-platform testing is simple since the same test scripts can be used for for multiple platforms.
If the app has to be tested for both the iOS and Android platforms, it's better to have Appium installed on a Mac.
Eg:export ANDROID_HOME=/Users/jenkins/Library/Android/sdk //sdk path
export PATH=$ANDROID_HOME/platform-tools:$PATH
export JAVA_HOME=$(/usr/libexec/java_home) //java path
cd/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
brew install carthage
npm i -g webpack
./Scripts/bootstrap.sh -d
Webdriver Installation and prerequisites:
which appiumSample output: /usr/local/bin/appium

1. Select “WebDriverAgentLib” as the target and go to the “General” tab. Check Automatic Signing, and then ask your development team to give you a developer id.

2. Repeat step 1, this time selecting “WebDriverAgentRunner” as the target.

Now, run the program in Xcode.Items to be added in Capabilities:
desiredCapabilities.setCapability("automationName","uiautomator2")
<desiredCapabilities.setCapability("automationName", "XCUITest");<desiredCapabilities.setCapability("startIWDP",true); // this will auto-handle the “ iOS Webkit Debug Proxy”How to inspect elements in native applications:
If you need to inspect native elements for an iOS application, you'll need to do a little workaround. Take a look at this, because the GUI version for Appium 1.6.4 is still under development.How to inspect elements in hybrid applications:
Tips for hybrid automation:
public void switchToWebView() {
Set<String> availableContexts = driver.getContextHandles();
logger.info("Total No of Context Found After we reach to WebView = " + availableContexts.size());
for (String context : availableContexts) {
if (context.contains("WEBVIEW")) {
logger.info("Context Name is " + context);
driver.context(context);
break;
}
}
}
The above code will get the list of contexts available and set the webview context
public static void <switchToNativeView() {
<<driver<.context("NATIVE_APP"<);
<<logger<.info("Context switched to " <+ "NATIVE_APP"<);
}
How to handle network scenarios:
<driver.setConnection(Connection.AIRPLANE); //supported in Java client 4.1.2

