Android: Change context to webview not working

Unsure if anyone else has seen this. But it looks like a disconnect has occurred recently between ADB and chromedriver (That we use in appium). It appears as though chromedriver creates the session correctly, but then adb returns “OKAYOKAY” at some point setting up port forwarding and it then decides the setup didn’t work. I have chrome 77.0.3865.92 on the phone, and am using ChromeDriver 77.0.3865.40. The end of the chromedriver log is as follows:

[1633551056.610][DEBUG]: Sending adb command: host:transport:accf5280|shell:grep -a '@webview_devtools_remote_.*15297' /proc/net/unix
[1633551056.638][DEBUG]: Received adb response: 0000000000000000: 00000002 00000000 00010000 0001 01 16666183 @webview_devtools_remote_15297

[1633551056.638][DEBUG]: Sending adb command: host-serial:accf5280:forward:tcp:0;localabstract:webview_devtools_remote_15297
[1633551056.639][DEBUG]: ADB server responded with "OKAYOKAY" instead of "OKAY".
[1633551056.639][DEBUG]: Received adb response: 50185
[1633551056.639][DEBUG]: DevTools HTTP Request: http://localhost:50185/json/version
[1633551056.645][DEBUG]: DevTools HTTP Response: {
   "Android-Package": "com.testapp.package",
   "Browser": "Chrome/77.0.3865.92",
   "Protocol-Version": "1.3",
   "User-Agent": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G935V Build/R16NW; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.92 Mobile Safari/537.36",
   "V8-Version": "",
   "WebKit-Version": "537.36 (@293f9bc46ce2af24bdbc1f632a37e87fa5247385)",
   "webSocketDebuggerUrl": "ws://localhost:50185/devtools/browser"

[1633551056.645][INFO]: [c3e257ce5d46e12b3bacc6f43dc1395d] RESPONSE InitSession ERROR session not created: please close 'com.tripadvisor.tripadvisor.prerelease' and try again

The issue seems to be the disconnect between expecting “OKAY” but receiving “OKAYOKAY”. Any assistance here would be much appreciated. Thanks!

It looks like this error happens if the webview package name provided on caps does not match to the actual one:;l=286?q="please%20close%20"&ss=chromium&start=41

Interesting… so we’re starting the Appium session using the settings package as we have to uninstall a few different apps pre-run, then through appium we install the app under test and launch it. During our POST to chromedriver, I do see that appium posts the following:

[1633551055.646][INFO]: [c3e257ce5d46e12b3bacc6f43dc1395d] COMMAND InitSession {
   "desiredCapabilities": {
      "chromeOptions": {
         "androidDeviceSerial": "accf5280",
         "androidPackage": "",
         "androidProcess": "com.testapp.package",
         "androidUseRunningApp": true,
         "w3c": false
      "loggingPrefs": {
         "browser": "ALL"

Could this be a bug in the android driver? When I change the to com.testapp.package the command succeeds. We recently updated to appium 1.22.0 for all our Androids.

FWIW: During the initial driver creation, if we pass the following it works:

2021-10-07 13:54:52:279 - [debug] [BaseDriver]     "goog:chromeOptions": {
2021-10-07 13:54:52:279 - [debug] [BaseDriver]       "w3c": false,
2021-10-07 13:54:52:279 - [debug] [BaseDriver]       "androidPackage": "com.testapp.package"
2021-10-07 13:54:52:279 - [debug] [BaseDriver]     },
1 Like

I assume by default Appium uses the package name from session capabilities. So, it makes sense to provide the actual value in chromeOptions for your case

It’s possible it’s doing this now, but this is a relatively new issue we’ve hit with latest Appium. We’ll continue passing in the package. But this will break if we’re switching between apps during the test.