Appium 1.4.16 for android doesn't recognize WEB_VIEW context

I have an android activity with webview.

However appium 1.4.16 cannot recognize this context.

How can i fix this?

myAndroidDriver.getContextHandles() ==> return list of size 1

First you need to interact with webview, then web element.
Click on `webview -> driver.findElement(“wvBase”)).click(); then you can interact with web elements.

This is how i am doing in my hybrid app automation. Hope this will work in your case as well.

Is ur app targeted to which android platform? anything below 4.4.4 will not work with appium to detect Webview… actually this is not limitation from appium side, its limitation of UIAutomator, which appium uses under the hood. So you need to run ur script under selendroid mode.

@Priyank_Shah Are you sure about 4.4.4 ? I think Appium supports above 4.2+.

Appium supports all API >=10, and if device’s API < 17 then it uses Selendroid mode, otherwise it uses android’s own UIAutomator framework. So point here, is WebView detection capability had been introduced to UIAutomator in API 4.4.4, so UIAUtomatorviewer can not detect web view if ur application’s targeted api is below 4.4.4, so Appium will not work. In such cases selendroid instrumentation will work to detect web view.

Priyank Shah

1 Like


  1. So it’s not related to webView

setWebContentsDebuggingEnabled = true;

or is in addition to that flag?

  1. What does “selendroid mode” really means?
    appium not using UIAutomator? Will this affect other tests I have?

  2. I have tried this before, but the code execution fails
    when I add:

capabilities.setCapability(“automationName”, “Selendroid”);

org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: hasInternetPermissionFromManifest failed. Error: Command failed: /bin/sh -c /Users/eladb/MyWorkspace/sdk/build-tools/android-4.4/aapt dump badging
ERROR: no dump file specified
) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 3.54 seconds
Build info: version: ‘2.47.1’, revision: ‘unknown’, time: ‘2015-07-30 11:02:44’
System info: host: ‘’, ip: ‘’, ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.2’, java.version: ‘1.8.0_25’
Driver info:
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.lang.reflect.Constructor.newInstance(
at org.openqa.selenium.remote.ErrorHandler.createThrowable(
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(
at org.openqa.selenium.remote.RemoteWebDriver.execute(
at io.appium.java_client.DefaultGenericMobileDriver.execute(
at io.appium.java_client.AppiumDriver.execute(
at org.openqa.selenium.remote.RemoteWebDriver.startSession(
at org.openqa.selenium.remote.RemoteWebDriver.(
at org.openqa.selenium.remote.RemoteWebDriver.(
at io.appium.java_client.DefaultGenericMobileDriver.(
at io.appium.java_client.AppiumDriver.(
at io.appium.java_client.AppiumDriver.(

  1. Yes, its related to setWebContentsDebuggingEnabled = true; but that has to be done in ur code. And rebuild app by keeping target API to 19.
  2. If u switch to selendroid mode, by keeping AutomationName to Selendroid in capability. And yes it will affect your other test. because its different way of instrumentation.
  3. i think u need to stop server and try again, because aapt utility was able to resolved AndroidMenifest.xml file of ur apk.

Priyank Shah

  1. I did server reset, but it throws the same error.

can u try “aapt dumpsys badging ‘APK location’” from command line. I guess ur apk might get corrupted.