Switch Context in Hybrid Application

Hi,
I have an Hybrid Android app, and want to automate it using Appium.
I want to switch from NATIVE_APP to WEBVIEW context and do some stuff on WEBVIEW part.
But I can’t switch the context because when I print all the available contexts using getContextHandles() method ,
I only found NATIVE_APP context. I tried to set WEBVIEW context but it throws nosuchcontext found exception.
Is there any possible way that I can switch contexts from NATIVE_APP to WEBVIEW in hybrid app so that I can do the stuff.

This might help…

Hi,

Is it possible to get the WEBVIEW context by using automationName = Appium(and not Selendroid)?

There isn’t any Android mode, there are two modes “Appium” and “Selendroid” for android. if you want to use “Appium” as automation name you need to enable webview debugging (Sadly) there aren’t any other way around it.

Hi,

I have a problem in switching my Hybrid application from Native APP context view to Web Context view with new Appium 1.6.4 version.
can you please let me know if anyone encountered this ?

Sample Code Used:

Set<String> contextName = driver.getContextHandles();
        System.out.println(contextName);
        for (String contexts : contextName) {
            System.out.println(contexts);
            if (contextName.contains("NATIVE_APP")) {
                System.out.println("Show me:" + contextName);
                Thread.sleep(1500);
                driver.context("NATIVE_APP");
                driver.findElement(By.xpath("//android.widget.Button[@text='Set']")).click();
            }
            if (contextName.contains("WEBVIEW")) {
                driver.context("WEBVIEW");
                driver.findElement(By.xpath("//android.widget.Button[@text='Set']")).click();
            }