Can't Switch To Context Webview

Hello guys,

I’ve been reading a lot and still no answer.

I’m testing an hybrid app in real devices, I’m able to get Contexts : native_app, webview. I’m able to Switch To Context NATIVE_APP but I’m not able to switch to webview.

Why can’t I Switch To Context Webview?
Is there any reference for stable version of Appium to get the hybrid apps on real devices working properly or any other ideas/tweaks to get this working ?

I’m using :
robotframework 2.8.7
appium (v1.4.13) installed with node in command line.


Here is my log:

info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Condition unmet after 152ms. Timing out.
info: [debug] Responding to client with success: {"status":0,"value":[],"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements 200 159.406 ms - 74 {"status":0,"value":[],"sessionId":"4ccd9eab-279
0-4750-a504-10afdfe05133"}
info: --> POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements {"using":"xpath","sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133",
"value":"//android.widget.Button[@index='39']"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.Button[@index='39']","context":"","m
ultiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget
.Button[@index='39']","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Condition unmet after 131ms. Timing out.
info: [debug] Responding to client with success: {"status":0,"value":[],"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements 200 138.089 ms - 74 {"status":0,"value":[],"sessionId":"4ccd9eab-279
0-4750-a504-10afdfe05133"}
info: --> POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements {"using":"xpath","sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133",
"value":"//android.widget.Button[@index='39']"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.Button[@index='39']","context":"","m
ultiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget
.Button[@index='39']","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Condition unmet after 124ms. Timing out.
info: [debug] Responding to client with success: {"status":0,"value":[],"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements 200 131.704 ms - 74 {"status":0,"value":[],"sessionId":"4ccd9eab-279
0-4750-a504-10afdfe05133"}
info: --> POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements {"using":"xpath","sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133",
"value":"//android.widget.Button[@index='39']"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.Button[@index='39']","context":"","m
ultiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget
.Button[@index='39']","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Condition unmet after 142ms. Timing out.
info: [debug] Responding to client with success: {"status":0,"value":[],"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements 200 148.441 ms - 74 {"status":0,"value":[],"sessionId":"4ccd9eab-279
0-4750-a504-10afdfe05133"}
info: --> POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements {"using":"xpath","sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133",
"value":"//android.widget.Button[@index='39']"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.Button[@index='39']","context":"","m
ultiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget
.Button[@index='39']","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Condition unmet after 197ms. Timing out.
info: [debug] Responding to client with success: {"status":0,"value":[],"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements 200 202.970 ms - 74 {"status":0,"value":[],"sessionId":"4ccd9eab-279
0-4750-a504-10afdfe05133"}
info: --> POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements {"using":"xpath","sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133",
"value":"//android.widget.Button[@index='39']"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.Button[@index='39']","context":"","m
ultiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget
.Button[@index='39']","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Condition unmet after 176ms. Timing out.
info: [debug] Responding to client with success: {"status":0,"value":[],"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements 200 182.715 ms - 74 {"status":0,"value":[],"sessionId":"4ccd9eab-279
0-4750-a504-10afdfe05133"}
info: --> POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements {"using":"xpath","sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133",
"value":"//android.widget.Button[@index='39']"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.Button[@index='39']","context":"","m
ultiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget
.Button[@index='39']","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Condition unmet after 144ms. Timing out.
info: [debug] Responding to client with success: {"status":0,"value":[],"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements 200 154.343 ms - 74 {"status":0,"value":[],"sessionId":"4ccd9eab-279
0-4750-a504-10afdfe05133"}
info: --> POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements {"using":"xpath","sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133",
"value":"//android.widget.Button[@index='39']"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.Button[@index='39']","context":"","m
ultiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget
.Button[@index='39']","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Condition unmet after 165ms. Timing out.
info: [debug] Responding to client with success: {"status":0,"value":[],"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements 200 172.041 ms - 74 {"status":0,"value":[],"sessionId":"4ccd9eab-279
0-4750-a504-10afdfe05133"}
info: --> POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements {"using":"xpath","sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133",
"value":"//android.widget.Button[@index='39']"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.Button[@index='39']","context":"","m
ultiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget
.Button[@index='39']","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.Button, INSTANCE=6]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.Button, INSTANCE=6]
info: [debug] [BOOTSTRAP] [debug] Selector ends with instance.
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[{"ELEMENT":"1"}]}
info: [debug] Responding to client with success: {"status":0,"value":[{"ELEMENT":"1"}],"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements 200 1139.233 ms - 89 {"status":0,"value":[{"ELEMENT":"1"}],"sessionI
d":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: --> POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements {"using":"xpath","sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133",
"value":"//android.widget.Button[@index='39']"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.Button[@index='39']","context":"","m
ultiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget
.Button[@index='39']","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[@index='39'] using XPATH with the contextId:  multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.Button, INSTANCE=6]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.Button, INSTANCE=6]
info: [debug] [BOOTSTRAP] [debug] Selector ends with instance.
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[{"ELEMENT":"2"}]}
info: [debug] Responding to client with success: {"status":0,"value":[{"ELEMENT":"2"}],"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/elements 200 169.425 ms - 89 {"status":0,"value":[{"ELEMENT":"2"}],"sessionId
":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: --> POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/element/2/click {"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133","id":"2"}

info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"2"}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"2"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/element/2/click 200 268.865 ms - 76 {"status":0,"value":true,"sessionId":"4cc
d9eab-2790-4750-a504-10afdfe05133"}
info: --> GET /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/context {}
info: [debug] Responding to client with success: {"status":0,"value":"NATIVE_APP","sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- GET /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/context 200 2.121 ms - 84 {"status":0,"value":"NATIVE_APP","sessionId":"4ccd9e
ab-2790-4750-a504-10afdfe05133"}
info: --> POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/context {"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133","name":"NATIVE_AP
P"}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: "C:\Users\Ana Padinha\AppData\Local\Android\sdk\platform-tools\adb.exe" -s 99d22cf0 shell "cat /proc/net/unix"
info: [debug] WEBVIEW_31256 mapped to pid 31256
info: [debug] Getting process name for webview
info: [debug] executing cmd: "C:\Users\Ana Padinha\AppData\Local\Android\sdk\platform-tools\adb.exe" -s 99d22cf0 shell "ps"
info: [debug] Parsed pid: 31256 pkg: com.emn8.mobilem8.nativeapp.bk
info: [debug] from: u0_a280,31256,361,2656104,416388,ffffffff,00000000,R,com.emn8.mobilem8.nativeapp.bk
info: [debug] returning process name: com.emn8.mobilem8.nativeapp.bk
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.xxxxx.xxxx.nativxxx.xx
info: [debug] ["WEBVIEW_com.xxxxx.xxxx.nativxxx.xx"]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.xxxxx.xxxx.nativxxx.xx
info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/context 200 736.600 ms - 76 {"status":0,"value":null,"sessionId":"4ccd9eab-27
90-4750-a504-10afdfe05133"}
info: --> GET /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/context {}
info: [debug] Responding to client with success: {"status":0,"value":"NATIVE_APP","sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133"}
info: <-- GET /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/context 200 4.599 ms - 84 {"status":0,"value":"NATIVE_APP","sessionId":"4ccd9e
ab-2790-4750-a504-10afdfe05133"}
info: --> POST /wd/hub/session/4ccd9eab-2790-4750-a504-10afdfe05133/context {"sessionId":"4ccd9eab-2790-4750-a504-10afdfe05133","name":"WEBVIEW_com.xxxxx.xxxx.nativxxx.xx"}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: "C:\Users\Xxx Xxxxx\AppData\Local\Android\sdk\platform-tools\adb.exe" -s 99d22cf0 shell "cat /proc/net/unix"
info: [debug] WEBVIEW_31256 mapped to pid 31256
info: [debug] Getting process name for webview
info: [debug] executing cmd: "C:\Users\Xxx Xxxxx\AppData\Local\Android\sdk\platform-tools\adb.exe" -s 99d22cf0 shell "ps"
info: [debug] Parsed pid: 31256 pkg: com.xxxxx.xxxx.nativxxx.xx
info: [debug] from: u0_a280,31256,361,2655160,416348,ffffffff,00000000,S,com.xxxxx.xxxx.nativxxx.xx
info: [debug] returning process name: com.xxxxx.xxxx.nativxxx.xx
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.xxxxx.xxxx.nativxxx.xx
info: [debug] ["WEBVIEW_com.xxxxx.xxxx.nativxxx.xx"]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.xxxxx.xxxx.nativxxx.xx
info: [debug] Connecting to chrome-backed webview
info: Chromedriver: Changed state to 'starting'
info: Chromedriver: Set chromedriver binary as: C:\Users\Xxx Xxxxx\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\chr
omedriver\win\chromedriver.exe
info: Chromedriver: Killing any old chromedrivers, running: FOR /F "usebackq tokens=5" %a in (`netstat -nao ^| findstr /R /C:"9515 "`) do (FOR /F
 "usebackq" %b in (`TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe`) do (IF NOT %b=="" TASKKILL /F /PID %a))
info: Chromedriver: No old chromedrivers seemed to exist
info: Chromedriver: Spawning chromedriver with: C:\Users\Xxx Xxxxx\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\chr
omedriver\win\chromedriver.exe --url-base=wd/hub --port=9515
info: Chromedriver: [STDOUT] Starting ChromeDriver 2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a) on port 9515
Only local connections are allowed.
info: JSONWP Proxy: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: JSONWP Proxy: Got response with status 200: {"sessionId":"","status":0,"value":{"build":{"version":"alpha"},"os":{"arch":"x86_64","name":"W
indows NT","version":"6.1 SP1"}}}
info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"
androidPackage":"com.xxxxx.xxxx.nativxxx.xx","androidUseRunningApp":true,"androidDeviceSerial":"99d22cf0"}}}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"3e7a949fe353e600fb8f760519ee5be7","status":13,"value":{"message":"unknown error:
Device 99d22cf0 is not online\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c9...
info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"
androidPackage":"com.xxxxx.xxxx.nativxxx.xx","androidUseRunningApp":true,"androidDeviceSerial":"99d22cf0"}}}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"7833183591f430ce52dd5f6468557c5e","status":13,"value":{"message":"unknown error:
Device 99d22cf0 is not online\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c9...
info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"
androidPackage":"com.emn8.mobilem8.nativeapp.bk","androidUseRunningApp":true,"androidDeviceSerial":"99d22cf0"}}}
info: [debug] Didn't get a new command in 60 secs, shutting down...
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: "C:\Users\Xxx Xxxxx\AppData\Local\Android\sdk\platform-tools\adb.exe" -s 99d22cf0 shell "input keyevent 3"
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 77.176
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] We shut down because no new commands came in
info: JSONWP Proxy: Got response with status 200: {"sessionId":"17e4567ff7f105ed7f60f4e1760698b4","status":13,"value":{"message":"unknown error:
unable to discover open pages\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c9...
info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"
androidPackage":"com.xxxxx.xxxx.nativxxx.xx","androidUseRunningApp":true,"androidDeviceSerial":"99d22cf0"}}}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"c6cd7a791c5f74a1707eae89180bd87c","status":13,"value":{"message":"unknown error:
unable to discover open pages\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c9...
error: Chromedriver: Chromedriver exited unexpectedly with code null, signal SIGTERM
info: Chromedriver: Changed state to 'stopped'
warn: Chromedriver for context WEBVIEW_com.xxxxx.xxxx.nativxxx.xx stopped unexpectedly
warn: Chromedriver quit unexpectedly, but it wasn't the active context, ignoring
error: Chromedriver: Error: An unknown server-side error occurred while processing the command. (Original error: unknown error: unable to discove
r open pages
  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86_64))
    at JWProxy.command$ (lib/proxy.js:149:15)
    at tryCatch (C:\Users\Xxx Xxxxx\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\node_modules\babel-runtime\regener
ator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\Xxx Xxxxx\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedri
ver\node_modules\babel-runtime\regenerator\runtime.js:294:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\Xxx Xxxxx\AppData\Roaming\npm\node_modules\appium\node_mod
ules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (C:\Users\Xxx Xxxxx\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\node_modu
les\babel-runtime\regenerator\runtime.js:136:37)
    at bound (domain.js:250:14)
    at GeneratorFunctionPrototype.runBound (domain.js:263:12)
    at run (C:\Users\Xxx Xxxxx\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\node_modules\babel-runtime\node_modules
\core-js\library\modules\es6.promise.js:89:39)
    at C:\Users\Xxx Xxxxx\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\node_modules\babel-runtime\node_modules\core
-js\library\modules\es6.promise.js:100:28
    at doNTCallback0 (node.js:407:9)
    at process._tickDomainCallback (node.js:377:13)
 { [Error: An unknown server-side error occurred while processing the command. (Original error: unknown error: unable to discover open pages
  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86_64))]
  status: 13,
  value: { message: 'unknown error: unable to discover open pages\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94
682a),platform=Windows NT 6.1 SP1 x86_64)' },
  httpCode: 200 }
^CTerminate batch job (Y/N)? n

Try using chromedriver 2.20 recently updated
More here

1 Like

Thanks :grin:

I have npm appium-chromedriver installed and didn’t solve the problem.
Any other ideas?

Copying and pasting my last comment in this ticket. (https://github.com/appium/appium/issues/5616#issuecomment-151458164).

In appium I add this to my desired capabilities (i’m in ruby using the appium.txt file)
[caps]
chromedriverExecutable = “/usr/local/bin/chromedriver”

I download 2.20 from https://sites.google.com/a/chromium.org/chromedriver/downloads

Then I move the above chromedriver to /usr/local/bin

Then I change permissions: chmod 7555 /usr/local/bin/chromedriver

Then I check the version. Here’s my prompt

15:04 $ chromedriver --version

ChromeDriver 2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b)

Then I run appium as normal without problem.
The chromedriverExecutable allows you to specify your own chromedriver executable thus bypassing the appium-chromedriver.

Hope this helps!

Hello, I did your suggestion and no better result. Thanks anyway. Might always help some other people.

Happened to me also.

In both times it happened when trying to switch to webview context.
Is there any other solution ?

error: Chromedriver: Chromedriver exited unexpectedly with code null, signal SIGTERM

info: Chromedriver: Changed state to ‘stopped’
warn: Chromedriver for context WEBVIEW_com.vox.enDirect3 stopped unexpectedly
warn: Chromedriver quit unexpectedly, but it wasn’t the active context, ignoring

error: Chromedriver: Error: An unknown server-side error occurred while processing the command. (Original error: unknown error: Device 0e5fe41a is not online
(Driver info: chromedriver=2.18.343837 (52eb4041461e46a6b73308ebb19e85787ced4281),platform=Mac OS X 10.10.5 x86_64))
at JWProxy.command$ (lib/proxy.js:149:15)
at tryCatch (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:294:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) as next] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at bound (domain.js:254:14)
at GeneratorFunctionPrototype.runBound (domain.js:267:12)
at run (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:89:39)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:100:28
at process._tickDomainCallback (node.js:381:11)
{ [Error: An unknown server-side error occurred while processing the command. (Original error: unknown error: Device 0e5fe41a is not online
(Driver info: chromedriver=2.18.343837 (52eb4041461e46a6b73308ebb19e85787ced4281),platform=Mac OS X 10.10.5 x86_64))]
status: 13,
value: { message: ‘unknown error: Device 0e5fe41a is not online\n (Driver info: chromedriver=2.18.343837 (52eb4041461e46a6b73308ebb19e85787ced4281),platform=Mac OS X 10.10.5 x86_64)’ },
httpCode: 200 }


After upgrading to chromedriver 2.20

"{“message”:“unknown error: unable to discover open pages\n (Driver info: chromedriver=2.20.353124 (035346203162d32c80f1dce587c8154a…”

info: Chromedriver: Successfully cleaned up old chromedrivers
info: Chromedriver: Spawning chromedriver with: /Users/yacov/development/chromedriver --url-base=wd/hub --port=9515
info: Chromedriver: [STDOUT] Starting ChromeDriver 2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b) on port 9515
Only local connections are allowed.
info: JSONWP Proxy: Proxying [GET /status] to GET http:// 127.0.0.1:9515/wd/hub/status with no body

info: JSONWP Proxy: Got response with status 200: {“sessionId”:“”,“status”:0,“value”:{“build”:{“version”:“alpha”},“os”:{“arch”:“x86_64”,“name”:“Mac OS X”,“version”:“10.10.5”}}}
info: JSONWP Proxy: Proxying [POST /session] to [POST http:// 127.0.0.1:9515/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.vox.enDirect3”,“androidUseRunningApp”:true,“androidDeviceSerial”:“0e5fe41a”}}}

info: → GET /wd/hub/status {}

info: JSONWP Proxy: Proxying [GET /wd/hub/status] to [GET http://127.0.0.1:9515/wd/hub/status] with body: {}

info: JSONWP Proxy: Got response with status 200: {“sessionId”:“”,“status”:0,“value”:{“build”:{“version”:“alpha”},“os”:{“arch”:“x86_64”,“name”:“Mac OS X”,“version”:“10.10.5”}}}
info: ← GET /wd/hub/status 200 7.588 ms - 126

info: → GET /wd/hub/status {}

info: JSONWP Proxy: Proxying [GET /wd/hub/status] to [GET http:// 127.0.0.1:9515/wd/hub/status] with body: {}

info: JSONWP Proxy: Got response with status 200: {“sessionId”:“”,“status”:0,“value”:{“build”:{“version”:“alpha”},“os”:{“arch”:“x86_64”,“name”:“Mac OS X”,“version”:“10.10.5”}}}
info: ← GET /wd/hub/status 200 4.494 ms - 126

info: JSONWP Proxy: Got response with status 200: {“sessionId”:“0c9eb5a37072a3208da65e008996daab”,“status”:13,“value”:{“message”:"unknown error: unable to discover open pages\n (Driver info: chromedriver=2.20.353124 (035346203162d32c80f1dce587c8154a…

info: JSONWP Proxy: Proxying [POST /session] to [POST http:// 127.0.0.1:9515/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidPackage”:“com.vox.enDirect3”,“androidUseRunningApp”:true,“androidDeviceSerial”:“0e5fe41a”}}}

info: → GET /wd/hub/status {}

info: JSONWP Proxy: Proxying [GET /wd/hub/status] to [GET http://127.0.0.1:9515/wd/hub/status] with body: {}

info: JSONWP Proxy: Got response with status 200: {“sessionId”:“”,“status”:0,“value”:{“build”:{“version”:“alpha”},“os”:{“arch”:“x86_64”,“name”:“Mac OS X”,“version”:“10.10.5”}}}
info: ← GET /wd/hub/status 200 6.663 ms - 126

info: → GET /wd/hub/status {}

info: JSONWP Proxy: Proxying [GET /wd/hub/status] to [GET http:// 127.0.0.1:9515/wd/hub/status] with body: {}

info: JSONWP Proxy: Got response with status 200: {“sessionId”:“”,“status”:0,“value”:{“build”:{“version”:“alpha”},“os”:{“arch”:“x86_64”,“name”:“Mac OS X”,“version”:“10.10.5”}}}
info: ← GET /wd/hub/status 200 4.834 ms - 126

,…

info: JSONWP Proxy: Got response with status 200: {“sessionId”:“ceae9e54525378e352792817c9d87669”,“status”:13,“value”:{“message”:"unknown error: unable to discover open pages\n (Driver info: chromedriver=2.20.353124 (035346203162d32c80f1dce587c8154a…

info: Chromedriver: Changed state to ‘stopped’

warn: Chromedriver for context WEBVIEW_com.vox.enDirect3 stopped unexpectedly
warn: Chromedriver quit unexpectedly, but it wasn’t the active context, ignoring

error: Chromedriver: Chromedriver exited unexpectedly with code null, signal SIGTERM

error: Chromedriver: Error: An unknown server-side error occurred while processing the command. (Original error: unknown error: unable to discover open pages
(Driver info: chromedriver=2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b),platform=Mac OS X 10.10.5 x86_64))
at JWProxy.command$ (lib/proxy.js:149:15)
at tryCatch (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke
(/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:294:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next
(/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at bound (domain.js:254:14)
at GeneratorFunctionPrototype.runBound (domain.js:267:12)
at run (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:89:39)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-chromedriver/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:100:28
at process._tickDomainCallback (node.js:381:11)
{ [Error: An unknown server-side error occurred while processing the command. (Original error: unknown error: unable to discover open pages
(Driver info: chromedriver=2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b),platform=Mac OS X 10.10.5 x86_64))]
status: 13,
value: { message: ‘unknown error: unable to discover open pages\n (Driver info: chromedriver=2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b),platform=Mac OS X 10.10.5 x86_64)’ },
httpCode: 200 }

One solution worked for me:

  1. download chromedriver 2.20 from https://sites.google.com/a/chromium.org/chromedriver/downloads and keep it somewhere like ~/Desktop
  2. give it executable permission like chmod +x ~/Desktop/chromedriver
  3. add capability to driver like :
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(“deviceName”, “Android”);
    capabilities.setCapability(“platformName”, “Android”);
    capabilities.setCapability(“app”, appFile.getAbsolutePath());
    capabilities.setCapability(“serial”, deviceID);
    capabilities.setCapability(“newCommandTimeout”, “120”);
    capabilities.setCapability(“chromedriverExecutable”, “Desktop/tpt/chromedriver”));
    driver = new AndroidDriver(new URL(“http://localhost:4723/wd/hub”), capabilities);
  4. thats it, you should be good now.

Hello everyone!! I could get a fix by monitoring chromedriver all the time during test execution, chromedriver becomes unresponsive while switching back to webview from natiove_app, I developed a small piece of code available at https://github.com/mi2pankaj/chromeDriverHandler, it has solved my all problems, just add this jar chromedriverHandler.jar to your project and use ChromedriverHandler.chromeDriverHandlerThread().start(); in your @beforeclass / @beforetest and ChromedriverHandler.chromeDriverHandlerThread().stop(); in your @afterclass / @aftertest.

Hi All,

I have faced similar issue and I am able to fix it with below workaround,

Issues description –
Chrome driver was failing unexpectedly while switching to “Webview” context.

Appium version - 1.4.13.1
chromedriver - 25

Work around –

  1. Changed appium settings
     Platform version – 5.0 Lolipop (API Level 21)

Set Server address – 0.0.0.0
Uncheck – Check for updates checkbox

  1. Upgraded the chromdriver version to 25 and replaced the chromedriver.exe on below location with latest version i.e. 25

C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win

I hope this will work.