The autoWebview
desired capability is just a simple shortcut provided for interacting with Webviews in Hybrid apps.
When you are using appium, you normally operate in something called the Native Context. When in the native context, you use all the regular appium commands to interact with the native elements of the mobile UI.
If the UI contains any embedded webviews, there are other contexts available. You can see all the available contexts by calling the contexts()
method provided by your appium client.
This call typically yields a list of contexts like this:
["NATIVE_CONTEXT", "WEBVIEW_1", "WEBVIEW_2"]
If you want to automate parts of the UI which are inside the webview, you need to tell appium to switch contexts to the webview. setContext("WEBVIEW_1")
Once set to a Webview Context, all commands sent by your test will apply to elements inside the webview, instead of elements which are part of the native UI.
In a Webview context, you can use regular Selenium commands, like get('http://example.com')
or CSS selectors for locating elements.
If you want to control part of the Native UI again, you need to return to the Native Context setContext("NATIVE_CONTEXT")
.
For projects which are testing Hybrid Apps, which are basically 100% webview apps, it can be inconvenient to remember to switch to using the Webview Context before every test. Sending the autoWebview
capability tells appium to automatically switch to the WEBVIEW_CONTEXT as soon as the test starts. Appium adds some additional logic for waiting until the webview has loaded, which can be a common source of errors.
Recently, in the master
branch of appium, we have added a feature that sends some appium commands to the Native context, even when you are in a Webview. For example: chromeDriver does not support changing orientation, so sending an Orientation command when you are inside a webview will not work. Rather than making you switch to the Native context and back to the Webview context, appium now automatically forwards the Orientation commands to the Native context.
As a separate issue:
You should not be setting automationName:"selendroid"
you definitely want the default automation to be used. For android 4.4, the chromeDriver is used to automate webviews. Selendroid is only used for older versions of Android.