Hybrid app automation in iOS automation using appium

We can automate the hybrid app very easily using Appium. Hybrid app contains native control as well as web controls. You need to switch the context to web control within app and then we can use the normal Selenium webdriver API to perform the operations. To auto switch the context to web, you can pass below capability.
 
capabilities.SetCapability(“autoWebview”, true);

Otherwise you can use below code to find all contexts within app and switch to it.
 
System.out.println("Context count " + driver.getContextHandles().size());

for (Object contextName : driver.getContextHandles()) {
    System.out.println("Context Name -> " + contextName);
    if (contextName.toString().toUpperCase().contains("WEBVIEW")){
        driver.context(contextName.toString());
        System.out.println("Switched to WebView Context");
    }
}
driver.get("https://www.softpost.org");
driver.close();

//Switch back to Native app
driver.context("NATIVE_APP");

Web development and Automation testing

solutions delivered!!