Appium only shows NATIVE_APP context on a Cordova App

0
0

I’m running Appium on Windows to test a Cordova app directly on an Android device. However, when I try to fetch the contexts and switch to the one containing WEBVIEW (basically, the recommended process), it only returns one context, NATIVE_APP.

When I use the inspector, I’m able to see a WebView child and a lot of View children appended to it, which relate to each one of the elements inside the app. So, despite it doesn’t show the element tree in Webview mode, I’m able to see it’s using a WebView, but somehow isn’t able to connect to that specific context.

Any ideas about this?

  • You must to post comments
0
0

Its working. I tried with a different combinations of capabilities and at-last I found the working combination. Use automationName and dont put platformVersion in capabilities.

final File app = new File(appDir, "HybridSample.apk");
final DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities
.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities
.setCapability("deviceName", "Android Emulator");
// capabilities.setCapability("platformVersion", "4.4");
capabilities
.setCapability("automationName", "Selendroid");
capabilities
.setCapability("platformName", "Android");
capabilities
.setCapability("app", app.getAbsolutePath());
capabilities
.setCapability("appPackage", "com.mcc.hybrid"); // Optional
capabilities
.setCapability("appActivity", ".HybridSample"); // Optional

If you inspect server logs, you can also see this. Available contexts: NATIVE_APP,WEBVIEW_0

That means, you have to switch context as follows.

for (final String contextName : contextNames) {
System.out.println(contextName);
if (contextName.contains("WEBVIEW_0")) {
driver
.context(contextName);
}
}

Please note that above settings are for Android version older than 4.4. If you have KitKat or later, just remove automationName. With automationName, it will not work correctly as it returns only NATIVE_APP as available context.

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website