Chrome not reachable error

Appium = 1.2.2
Android = 4.4.x

We have a series of Appium tests that require us to login to our Android application. The login page is a WebView.

When we run the first test case, it logs into our application just fine and creates a ChromeDriver session. Appium log output

2014-09-17 21:41:37:683 - info: [debug] Connecting to chrome-backed webview
2014-09-17 21:41:37:683 - info: [debug] Creating Chrome session
2014-09-17 21:41:37:684 - info: [debug] Set chromedriver binary as: /Users/berkl008/npm/lib/node_modules/appium/build/chromedriver/mac/chromedriver
2014-09-17 21:41:37:684 - info: [debug] Ensuring Chromedriver exists
2014-09-17 21:41:37:684 - info: [debug] Killing any old chromedrivers, running: ps -ef | grep /Users/berkl008/npm/lib/node_modules/appium/build/chromedriver/mac/chromedriver | grep -v grep |grep -e '--port=9515$' | awk '{ print $2 }' | xargs kill -15
2014-09-17 21:41:37:716 - info: [debug] Successfully cleaned up old chromedrivers
2014-09-17 21:41:37:716 - info: [debug] Spawning chromedriver with: /Users/berkl008/npm/lib/node_modules/appium/build/chromedriver/mac/chromedriver
2014-09-17 21:41:37:751 - info: [debug] [CHROMEDRIVER] Starting ChromeDriver (v2.10.267517) on port 9515
Only local connections are allowed.
2014-09-17 21:41:37:752 - info: [debug] Making http request with opts: {"url":"http://127.0.0.1:9515/wd/hub/session","method":"POST","json":{"sessionId":null,"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.my-domain.xyz","androidUseRunningApp":true,"androidDeviceSerial":"12218680"}}}}
2014-09-17 21:41:38:683 - info: [debug] Successfully started chrome session ccf360325d13ea64c7852b2aa9e538e8
2014-09-17 21:41:38:683 - info: [debug] Setting proxy session id to ccf360325d13ea64c7852b2aa9e538e8
2014-09-17 21:41:38:684 - info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"f27b15f2-d41c-4f3c-921b-1c91338dc07e"}
2014-09-17 21:41:38:684 - info: <-- POST /wd/hub/session/f27b15f2-d41c-4f3c-921b-1c91338dc07e/context 200 1179.646 ms - 76 {"status":0,"value":null,"sessionId":"f27b15f2-d41c-4f3c-921b-1c91338dc07e"}
2014-09-17 21:41:40:695 - info: --> POST /wd/hub/session/f27b15f2-d41c-4f3c-921b-1c91338dc07e/element {"using":"id","value":"username"}
2014-09-17 21:41:40:695 - info: [debug] Proxying command to 127.0.0.1:9515
2014-09-17 21:41:40:696 - info: [debug] Making http request with opts: {"url":"http://127.0.0.1:9515/wd/hub/session/ccf360325d13ea64c7852b2aa9e538e8/element","method":"POST","json":{"using":"id","value":"username"}}
2014-09-17 21:41:41:087 - info: [debug] Proxied response received with status 200: {"sessionId":"ccf360325d13ea64c7852b2aa9e538e8","status":0,"value":{"ELEMENT":"0.7960182004608214-1"}}
2014-09-17 21:41:41:088 - info: <-- POST /wd/hub/session/f27b15f2-d41c-4f3c-921b-1c91338dc07e/element 200 393.899 ms - 102 

However, when the application attempts to run our 2nd test and tries to login, it successfully finds the pre-existing instance of ChromeDriver and uses it, but it fails to use the driver, complaining ‘chrome not reachable’. Is anybody else experiencing this sort of behavior?

2014-09-17 21:42:05:275 - info: [debug] Connecting to chrome-backed webview
2014-09-17 21:42:05:275 - info: [debug] Found existing Chromedriver for context 'WEBVIEW_com.my-domain.xyz'. Using it.
2014-09-17 21:42:05:275 - info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"f27b15f2-d41c-4f3c-921b-1c91338dc07e"}
2014-09-17 21:42:05:275 - info: <-- POST /wd/hub/session/f27b15f2-d41c-4f3c-921b-1c91338dc07e/context 200 191.007 ms - 76 {"status":0,"value":null,"sessionId":"f27b15f2-d41c-4f3c-921b-1c91338dc07e"}
2014-09-17 21:42:05:278 - info: --> GET /wd/hub/session/f27b15f2-d41c-4f3c-921b-1c91338dc07e/context {}
2014-09-17 21:42:05:279 - info: [debug] Responding to client with success: {"status":0,"value":"WEBVIEW_com.my-domain.xyz","sessionId":"f27b15f2-d41c-4f3c-921b-1c91338dc07e"}
2014-09-17 21:42:05:279 - info: <-- GET /wd/hub/session/f27b15f2-d41c-4f3c-921b-1c91338dc07e/context 200 0.905 ms - 96 {"status":0,"value":"WEBVIEW_com.disney.dma","sessionId":"f27b15f2-d41c-4f3c-921b-1c91338dc07e"}
2014-09-17 21:42:07:284 - info: --> POST /wd/hub/session/f27b15f2-d41c-4f3c-921b-1c91338dc07e/element {"using":"id","value":"username"}
2014-09-17 21:42:07:285 - info: [debug] Proxying command to 127.0.0.1:9515
2014-09-17 21:42:07:285 - info: [debug] Making http request with opts: {"url":"http://127.0.0.1:9515/wd/hub/session/ccf360325d13ea64c7852b2aa9e538e8/element","method":"POST","json":{"using":"id","value":"username"}}
2014-09-17 21:42:07:290 - info: [debug] Responding to client with error: {"status":100,"value":{"message":"An error occurred","origValue":"chrome not reachable\n  (Session info: webview=)\n  (Driver info: chromedriver=2.10.267517,platform=Mac OS X 10.9.4 x86_64)"},"sessionId":"f27b15f2-d41c-4f3c-921b-1c91338dc07e"}

Yes. I’ve encountered the same issue. You could try using Selendroid. Another alternative is to access the webview directly via uiautomator and bypass chromedriver.

Our team is new to Appium (about 4 weeks). Would you be able to expand on how we might use uiautomator to bypass chromedriver – example code, docs, etc?

This is how we are switching contexts:

    // groovy code    
    String webViewContext = webDriver.contextHandles.find { it == 'WEBVIEW_com.disney.dma' }
    if (webViewContext != null) {
        webDriver.context(webViewContext)
    }

Here is a snapshot of the WebView we are attempting to interact with

On my app, reloading the activity eventually makes the webview elements appear in the source output (requires at least API 19).

If you setup the appium ruby console, I could try and walk you through this via a google hangout screenshare.