Appium [已解决] Appium 转换 webview context 失败。报错 chrome not reachable

Pauline · 2017年01月12日 · 最后由 WhiteAlbum 回复于 2023年03月14日 · 6563 次阅读

测试背景:自动化测试微信公众号网页

问题描述:
1.Appium(版本 1.6.2)转换 webview context 失败。报错 chrome not reachable
2.测试使用安卓真机,android version 5.1.1
3.在转换的过程中,我留意到真机已经成功进入网页并能加载所有元素,但是就是不能对里面的元素进行操作。chrome browser is invoking but not communicating with the opened window. session 过了大概一分钟才正式关闭。

尝试解决方法:

google 有人说可能是 chromedriver 没有绕过代理设置。通过设置 Internet Properties->connections->LAN settings, set 'Bypass proxy server for local addresses'可以解决这个问题。--------------------我的情况实测不起作用。
google 说有时候引起这个问题是由于 chromedriver 对切换 webview 请求没有及时响应,而 appium 一直在等待 chromedriver 的进一步动作导致超时。所以要解决这个问题的方法就是创建一个线程来监控 chromedriver,当 chromedriver 停止运行,唤醒它。

下面是我的 appium 日志

[HTTP] --> GET /wd/hub/session/3fd60116-5418-4bdf-8c4e-e5f6627b837a/contexts {}
[debug] [MJSONWP] Calling AppiumDriver.getContexts() with args: ["3fd60116-5418-4bdf-8c4e-e5f6627b837a"]
[debug] [AndroidDriver] Getting a list of available webviews
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\software_home\Android_sdk\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0123456789ABCDEF","shell","cat","/proc/net/unix"]
[debug] [AndroidDriver] WEBVIEW_19192 mapped to pid 19192
[debug] [AndroidDriver] Getting process name for webview
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\software_home\Android_sdk\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0123456789ABCDEF","shell","ps"]
[debug] [AndroidDriver] Parsed pid: 19192 pkg: com.tencent.mm:tools!
[debug] [AndroidDriver] from: u0_a81,19192,1942,1544284,100912,ffffffff,00000000,S,com.tencent.mm:tools
[debug] [AndroidDriver] returning process name: com.tencent.mm:tools
[debug] [AndroidDriver] Found webviews: ["WEBVIEW_com.tencent.mm:tools"]
[debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_com.tencent.mm:tools"]
[debug] [MJSONWP] Responding to client with driver.getContexts() result: ["NATIVE_APP","WEBVIEW_com.tencent.mm:tools"]
[HTTP] <-- GET /wd/hub/session/3fd60116-5418-4bdf-8c4e-e5f6627b837a/contexts 200 1075 ms - 117
[HTTP] --> POST /wd/hub/session/3fd60116-5418-4bdf-8c4e-e5f6627b837a/context {"name":"WEBVIEW_com.tencent.mm:tools"}
[debug] [MJSONWP] Calling AppiumDriver.setContext() with args: ["WEBVIEW_com.tencent.mm:tools","3fd60116-5418-4bdf-8c4e-e5f6627b837a"]
[debug] [AndroidDriver] Getting a list of available webviews
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\software_home\Android_sdk\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0123456789ABCDEF","shell","cat","/proc/net/unix"]
[debug] [AndroidDriver] WEBVIEW_19192 mapped to pid 19192
[debug] [AndroidDriver] Getting process name for webview
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\software_home\Android_sdk\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0123456789ABCDEF","shell","ps"]
[debug] [AndroidDriver] Parsed pid: 19192 pkg: com.tencent.mm:tools!
[debug] [AndroidDriver] from: u0_a81,19192,1942,1560304,110312,ffffffff,00000000,S,com.tencent.mm:tools
[debug] [AndroidDriver] returning process name: com.tencent.mm:tools
[debug] [AndroidDriver] Found webviews: ["WEBVIEW_com.tencent.mm:tools"]
[debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_com.tencent.mm:tools"]
[debug] [AndroidDriver] Connecting to chrome-backed webview context 'WEBVIEW_com.tencent.mm:tools'
[debug] [AndroidDriver] A port was not given, using random port: 8000
[debug] [Chromedriver] Changed state to 'starting'
[Chromedriver] Set chromedriver binary as: C:\Users\Administrator\AppData\Roaming\npm\node_modules.appium_npminstall\appium-chromedriver\2.9.4\appium-chromedriver\chromedriver\win\chromedriver.exe
[Chromedriver] Killing any old chromedrivers, running: FOR /F "usebackq tokens=5" %a in (netstat -nao ^| findstr /R /C:"8000 ") do (FOR /F "usebackq" %b in (TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe) do (IF NOT %b=="" TASKKILL /F /PID %a))
[Chromedriver] No old chromedrivers seemed to exist
[Chromedriver] Spawning chromedriver with: C:\Users\Administrator\AppData\Roaming\npm\node_modules.appium_npminstall\appium-chromedriver\2.9.4\appium-chromedriver\chromedriver\win\chromedriver.exe --
url-base=wd/hub --port=8000 --adb-port=5037
[Chromedriver] [STDOUT] Starting ChromeDriver 2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed) on port 8000
Only local connections are allowed.
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"6.
1.7601 SP1\"}}}"
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningA
pp":true,"androidDeviceSerial":"0123456789ABCDEF"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"f53c787a58f62c87150b8fa107be307d","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.25.426923 (03
90b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningA
pp":true,"androidDeviceSerial":"0123456789ABCDEF"}}}
[HTTP] --> DELETE /wd/hub/session/3fd60116-5418-4bdf-8c4e-e5f6627b837a {}
[debug] [MJSONWP] Calling AppiumDriver.deleteSession() with args: ["3fd60116-5418-4bdf-8c4e-e5f6627b837a"]
[debug] [AndroidDriver] Shutting down Android driver
[debug] [AndroidDriver] Resetting IME to com.android.inputmethod.latin/.LatinIME
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\software_home\Android_sdk\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0123456789ABCDEF","shell","ime","set","com.and
roid.inputmethod.latin/.LatinIME"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\software_home\Android_sdk\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0123456789ABCDEF","shell","am","force-stop","com.tencent.mm"]
[debug] [ADB] Pressing the HOME button
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\software_home\Android_sdk\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0123456789ABCDEF","shell","input","keyevent",3]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [UiAutomator] Shutting down UiAutomator
[debug] [UiAutomator] Moving to state 'stopping'
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Closed client connection
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: numtests=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: current=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: 0
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Test results for WatcherResultPrinter=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Time: 109.533
[debug] [AndroidBootstrap] [UIAUTO STDOUT] OK (1 test)
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: -1
[debug] [UiAutomator] UiAutomator shut down normally
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [ADB] Attempting to kill all uiautomator processes
[debug] [ADB] Getting all processes with uiautomator
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\software_home\Android_sdk\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0123456789ABCDEF","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\software_home\Android_sdk\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0123456789ABCDEF","shell","am","force-stop","io.appium.unlock"]
[debug] [Logcat] Stopping logcat capture
[debug] [AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted.
[Appium] Removing session 3fd60116-5418-4bdf-8c4e-e5f6627b837a from our master session list
[debug] [MJSONWP] Received response: null
[debug] [MJSONWP] But deleting session, so not returning
[debug] [MJSONWP] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/3fd60116-5418-4bdf-8c4e-e5f6627b837a 200 6021 ms - 76
[HTTP] <-- POST /wd/hub/session/3fd60116-5418-4bdf-8c4e-e5f6627b837a/context - - ms - -
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"f449b3df3f3d38d7f9bd99e89b140692","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidDeviceSerial":"0123456789ABCDEF"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"aead2b91c6f5e51df6f9595492248f1e","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidDeviceSerial":"0123456789ABCDEF"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"e3d31d035b41bfb4f7471edb7f79b137","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
[Chromedriver] Chromedriver exited unexpectedly with code null, signal SIGTERM
[debug] [Chromedriver] Changed state to 'stopped'
[Chromedriver] Error: chrome not reachable
(Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64)
at Chromedriver.callee$2$0$ (C:\Users\Administrator\AppData\Roaming\npm\node_modules.appium_npminstall\appium-chromedriver\2.9.4\appium-chromedriver\build\lib\chromedriver.js:393:27)
at tryCatch (C:\Users\Administrator\AppData\Roaming\npm\node_modules.appium_npminstall\babel-runtime\5.8.24\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as next
at GeneratorFunctionPrototype.invoke (C:\Users\Administrator\AppData\Roaming\npm\node_modules.appium_npminstall\babel-runtime\5.8.24\babel-runtime\regenerator\runtime.js:136:37)
Error: chrome not reachable
(Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64)
at Chromedriver.callee$2$0$ (C:\Users\Administrator\AppData\Roaming\npm\node_modules.appium_npminstall\appium-chromedriver\2.9.4\appium-chromedriver\build\lib\chromedriver.js:393:27)
at tryCatch (C:\Users\Administrator\AppData\Roaming\npm\node_modules.appium_npminstall\babel-runtime\5.8.24\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as next
at GeneratorFunctionPrototype.invoke (C:\Users\Administrator\AppData\Roaming\npm\node_modules.appium_npminstall\babel-runtime\5.8.24\babel-runtime\regenerator\runtime.js:136:37)
[MJSONWP] Encountered internal error running command: Error: chrome not reachable
(Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64)
at Chromedriver.callee$2$0$ (C:\Users\Administrator\AppData\Roaming\npm\node_modules.appium_npminstall\appium-chromedriver\2.9.4\appium-chromedriver\build\lib\chromedriver.js:393:27)
at tryCatch (C:\Users\Administrator\AppData\Roaming\npm\node_modules.appium_npminstall\babel-runtime\5.8.24\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as next
at GeneratorFunctionPrototype.invoke (C:\Users\Administrator\AppData\Roaming\npm\node_modules.appium_npminstall\babel-runtime\5.8.24\babel-runtime\regenerator\runtime.js:136:37)

下面是我的用例报告

1) should navigate to the shopping mall homepage
timeout of 100000ms exceeded. Ensure the done() callback is being called in this test.
running
Error: timeout of 100000ms exceeded. Ensure the done() callback is being called in this test.
at Timeout.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules.wdio-mocha-framework_npminstall\mocha\2.5.3\mocha\lib\runnable.js:226:19)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)

如果有遇到同样问题的朋友,还请告知详细解决方法。thanks in advance。

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 41 条回复 时间 点赞

@TheRoadNotTaken 我也是这个情况 用的 mac 系统
appium:1.4.13
android:6.0.1
我特意写了个 for 循环 让他识别 webview contex 大概循环 2-3 次后才识别到 然后 switch_to context. 但是我切进入 web view 的时间比较久大概 1 分钟左右 我写了个 print ‘成功’ 之后一直在 webview 界面 不做任何操作也不执行 最好 1-2 分钟后 session 报错结束!
楼主搞定了记得 回复下 详细

@TheRoadNotTaken
错误代码如下

info: JSONWP Proxy: Got response with status 200: {"sessionId":"838847547e8af5138872d4abd0c9abce","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.18.343837 (52eb4041461e46a6b73308ebb19e85787ced4281),platform=Mac ...

info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:appbrand3","androidDeviceSerial":"532c6f13"}}}

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.11.5"}}}
info: <-- GET /wd/hub/status 200 8.021 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.11.5"}}}
info: <-- GET /wd/hub/status 200 5.346 ms - 126

info: JSONWP Proxy: Got response with status 200: {"sessionId":"ef97a6532170d82596d7338493c62565","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.18.343837 (52eb4041461e46a6b73308ebb19e85787ced4281),platform=Mac ...

info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:appbrand3","androidDeviceSerial":"532c6f13"}}}

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.11.5"}}}
info: <-- GET /wd/hub/status 200 5.502 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.11.5"}}}
info: <-- GET /wd/hub/status 200 8.762 ms - 126

info: JSONWP Proxy: Got response with status 200: {"sessionId":"0da1605e28f8a41a9863fb5c4c150f99","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.18.343837 (52eb4041461e46a6b73308ebb19e85787ced4281),platform=Mac ...

info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:appbrand3","androidDeviceSerial":"532c6f13"}}}

亲测可用方法:

在配置信息里加上这段(我的是 JavaScript Client)

chromeOptions: {
      androidProcess:"com.tencent.mm:tools"
    }

具体的也可以参考此贴
https://testerhome.com/topics/6954(里面有说到原因)

post 一下成功后的 log

[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Window
s NT\",\"version\":\"10.0.14393\"}}}"
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.
mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:tools","androidDeviceSerial":"0123456789ABCDEF"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"a3501a8a437dc4d9ec2700de1bcc95d3","status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"b
rowserConnectionEnabled":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed)"},"cssSelectorsEnabled":true,"datab
aseEnabled":false,"handlesAlerts":true,"hasTouchScreen":false,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":false,"nativeEvents":true,"pageLoad
Strategy":"normal","platform":"ANDROID","rotatable":false,"takesHeapSnapshot":true,"takesScreenshot":true,"version":"37.0.0.0","webStorageEnabled":true}}
[debug] [Chromedriver] Changed state to 'online'
[debug] [MJSONWP] Responding to client with driver.setContext() result: null
[HTTP] <-- POST /wd/hub/session/0a5c638f-1489-4cb4-b5ae-435235699860/context 200 6266 ms - 76
[HTTP] --> GET /wd/hub/session/0a5c638f-1489-4cb4-b5ae-435235699860/title {}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [GET /wd/hub/session/0a5c638f-1489-4cb4-b5ae-435235699860/title] to [GET http://127.0.0.1:8000/wd/hub/session/a3501a8a437dc4d9ec2700de1bcc95d3/ti
tle] with body: {}
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"a3501a8a437dc4d9ec2700de1bcc95d3\",\"status\":0,\"value\":\"测试平台\"}"

#1 楼 @Tester957 你可以试试我下面的方法,希望可以帮到你。

我切换成功
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no b
ody
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"
build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"6.
1.7601 SP1\"}}}"
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with
body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningA
pp":true,"args":[],"androidProcess":"com.tencent.mm:appbrand0","extensions":[],"androidDeviceSerial"
:"ZX1G4294SH"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"83a43f95f4d58aaa08c13278d617eb15"
,"status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled
":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.26.436362 (5476ec6bf7ccbada1734a0c
dec7d570bb042aa30)"},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"hasTou
chScreen":false,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":fals
e,"nativeEvents":true,"pageLoadStrategy":"normal","platform":"ANDROID","rotatable":false,"takesHeapS
napshot":true,"takesScreenshot":true,"unexpectedAlertBehaviour":"","version":"37.0.0.0","webStorageE
nabled":true}}
[debug] [Chromedriver] Changed state to 'online'
[debug] [MJSONWP] Responding to client with driver.setContext() result: null
[HTTP] <-- POST /wd/hub/session/9a81663a-b01d-4846-90e0-779e160c4644/context 200 5078 ms - 76、

但是找元素时候提示这个

[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"83a43f95f4d58aaa08c13278d617eb15"
,"status":7,"value":{"message":"no such element: Unable to locate element: {\"method\":\"xpath\",\"s
elector\":\"//*[text()='机票']\"}\n (Session info: webview=37.0.0.0)\n (Driver info: chromedriver=
2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 6.1.7601 SP1 x86_64)"}}

原因大概知道了,去哪儿出行页面显示很丰富,但是 getsource 看到 body 是空的
😂 😂 😂 😂 😂 😂 😂 😂 ,所以 xpath 什么也找不到


#6 楼 @utopia 转换 webview 后,我是能操作元素的。建议你再检查一下元素的定位信息。

@TheRoadNotTaken 能定位是说小程序么

#8 楼 @utopia 不是小程序,是公众号里面的网页。

#9 楼 @TheRoadNotTaken 您好 我这里始终切换不到 webview 试了好多方法都不行 log 里显示可用的 context 只有 NATIVE_APP,您遇到过这种情况吗

info: [debug] Getting a list of available webviews
info: [debug] executing cmd: E:\appnium\android\sdk\android-sdk-windows\platform-tools\adb.exe -s 3332B087C13200EC shell "cat /proc/net/unix"
info: [debug] Available contexts:
info: [debug] []
info: [debug] Available contexts: NATIVE_APP
info: [debug] Responding to client with success: {"status":0,"value":["NATIVE_APP"],"sessionId":"3442571c-56e5-47e5-86e4-e2d4c12a5718"}
info: <-- GET /wd/hub/session/3442571c-56e5-47e5-86e4-e2d4c12a5718/contexts 200 198.187 ms - 86 {"status":0,"value":["NATIVE_APP"],"sessionId":"3442571c-56e5-47e5-86e4-e2d4c12a5718"}
info: --> POST /wd/hub/session/3442571c-56e5-47e5-86e4-e2d4c12a5718/context {"sessionId":"3442571c-56e5-47e5-86e4-e2d4c12a5718","name":"WEBVIEW_com.tencent.mm:tools"}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: E:\appnium\android\sdk\android-sdk-windows\platform-tools\adb.exe -s 3332B087C13200EC shell "cat /proc/net/unix"
info: [debug] Available contexts: NATIVE_APP
info: [debug] []
info: [debug] Available contexts: NATIVE_APP
info: [debug] Responding to client with error: {"status":35,"value":{"message":"No such context found.","origValue":"Context 'WEBVIEW_com.tencent.mm:tools' does not exist"},"sessionId":"3442571c-56e5-47e5-86e4-e2d4c12a5718"}
info: <-- POST /wd/hub/session/3442571c-56e5-47e5-86e4-e2d4c12a5718/context 500 74.620 ms - 177
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: E:\appnium\android\sdk\android-sdk-windows\platform-tools\adb.exe -s 3332B087C13200EC 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: {"value":"OK, shutting down","status":0}
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
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

我的 log 是这样的,能不能帮忙看一下,谢谢

#11 楼 @zrleo 看了你的 log,说了当前的 context 没有 webview 哦。建议你先搜索一下什么时候才需要转 context。如果你一进入微信,想要控制元素进入公众号之类的,在 native context 下就可以控制元素了。不需要转 context,公众号里面打开网页,这时要转 context。

#12 楼 @TheRoadNotTaken 因为我是在测试微信号中做测试,没法配置微信的菜单,只能通过对话框进入 H5 页面。 切换 context 应该就是在跳转到 H5 页面之后转吧,我的有时候会出现 WEBVIEW_com.tencent.mm:tools,但是也会报错

#13 楼 @zrleo 我这边也是在测试微信号里测试的,你可以实现整个过程自动化的,从手机自动解锁,自动启动微信程序,自动点点点进入到测试网页。人工是怎么进入目标页面的,就驱动手机做相应操作。不是很清楚配置微信菜单是什么情况,建议你发个新帖问问其他朋友。

#14 楼 @TheRoadNotTaken 嗯 好的 谢谢哈 我和你的操作是一样的

#1 楼 @Tester957 我的情况和你一样,有什么好的解决方法吗?

—— 来自 TesterHome 官方 安卓客户端

> info: [debug] Connecting to chrome-backed webview
> info: Chromedriver: Changed state to 'starting'
> info: Chromedriver: Set chromedriver binary as: D:\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\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: D:\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\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\":\"Windows 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.quantum.Tmsp7","androidUseRunningApp":true,"androidDeviceSerial":"9298e3e5"}}}
> info: JSONWP Proxy: Got response with status 200: {"sessionId":"e99d4f25a7d1ed109a7bf5a59df93aa7","status":13,"value":{"message":"unknown error: Device 9298e3e5 is not online\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d...
> info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.quantum.Tmsp7","androidUseRunningApp":true,"androidDeviceSerial":"9298e3e5"}}}
> info: JSONWP Proxy: Got response with status 200: {"sessionId":"440c50570a1f7c28a06f590340979f51","status":13,"value":{"message":"unknown error: Device 9298e3e5 is not online\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d...
> info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.quantum.Tmsp7","androidUseRunningApp":true,"androidDeviceSerial":"9298e3e5"}}}
> info: JSONWP Proxy: Got response with status 200: {"sessionId":"7181aad8d442038eb88a3812db5dcd10","status":13,"value":{"message":"unknown error: Device 9298e3e5 is not online\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d...
> error: Chromedriver: Chromedriver exited unexpectedly with code null, signal SIGTERM
> info: Chromedriver: Changed state to 'stopped'
> warn: Chromedriver for context WEBVIEW_com.quantum.Tmsp7 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 9298e3e5 is not online
>   (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86_64))
>     at JWProxy.command$ (lib/proxy.js:133:15)

楼主的消息是:
[debug] [Chromedriver] Changed state to 'stopped'
[Chromedriver] Error: chrome not reachable

我的 log 是这样的,讨论看下,是不是一个问题

error: Chromedriver: Chromedriver exited unexpectedly with code null, signal SIGTERM
info: Chromedriver: Changed state to 'stopped'
warn: Chromedriver for context WEBVIEW_com.quantum.Tmsp7 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 9298e3e5 is not online

@TheRoadNotTaken 微信小程序 我 click 就动了一下 没有进入 但是代码是执行成功了 知道什么情况吗

#17 楼 @luke 我觉得是类似的情况。

@TheRoadNotTaken 进入 Webview 后不能操作页面元素,知道怎么解决么?定位方法没问题,提示:rg.openqa.selenium.NoSuchSessionException: no such session
(Driver info: chromedriver=2.22.397929 (fb72fb249a903a0b1041ea71eb4c8b3fa0d9be5a),platform=Mac OS X 10.12.2 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 28 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_121'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{app=, appPackage=com.tencent.mm, networkConnectionEnabled=true, noReset=true, warnings={}, databaseEnabled=false, deviceName=57b51c43, fullReset=false, platform=ANDROID, deviceUDID=57b51c43, appActivity=.ui.LauncherUI, desired={app=, appPackage=com.tencent.mm, noReset=true, deviceName=A02AECPB2CLTG, fullReset=false, platform=ANDROID, appActivity=.ui.LauncherUI, platformVersion=5.1.1, automationName=Appium, browserName=, fastReset=false, chromeOptions={args=[], extensions=[], androidProcess=com.tencent.mm:tools}, platformName=Android}, platformVersion=5.1.1, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, takesScreenshot=true, browserName=, javascriptEnabled=true, fastReset=false, chromeOptions={args=[], extensions=[], androidProcess=com.tencent.mm:tools}, platformName=Android}]
Session ID: b5fee2fb-cc51-422d-8b01-eb742b86a603
*** Element info: {Using=xpath, value=//*[contains(@url, '古代')]}

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:51)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:368)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:67)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:473)
at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:145)
at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElementByXPath(AndroidDriver.java:1)
at Weixin.MiniProgramTest.miniProgramTest(MiniProgramTest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:646)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:811)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1137)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:753)
at org.testng.TestRunner.run(TestRunner.java:607)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:368)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:363)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:321)
at org.testng.SuiteRunner.run(SuiteRunner.java:270)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1284)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
at org.testng.TestNG.runSuites(TestNG.java:1124)
at org.testng.TestNG.run(TestNG.java:1096)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:127)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

大神,我切换的时候是这样报错,请问下是什么原因呢?

Lyndon1 回复

你好,你的这个问题解决了吗?是怎么解决的呢?可以分享一下吗

http 回复

跟你一样的,请问解决了没。卡了我好久了

我想问下 我再转换后打印 driver.getcontext() 有时能打印出来,有时就不能。能的时候就可以执行下一步的元素点击操作了。
这是什么情况呢?


报错 chrome not reachable,同求解决方法,QQ188368459

通过设置 Internet Properties->connections->LAN settings, set 'Bypass proxy server for local addresses'

这个设置在哪里啊,想请问一下

我这边部署了三台电脑,同样的代码,有两台电脑能够执行通过,其中一台 90% 的概率执行报错,只要一切换 webview,就报:devices xxx is not online,求解惑,我猜想是环境问题,但是一直找不到原因,求共同探讨 QQ :271584350

hi,请问下各位大神,最先是我的 chrome 和 chromedriver 版本不一致导致切换 context 有问题,报 chrome not reachable 现在我已经把手机的 chrome 和 chromedriver 版本弄一致,但是又报其他错误
get context 得到 ["WEBVIEW_com.tencent.mm:appbrand0","WEBVIEW_com.tencent.mm:tools","WEBVIEW_com.tencent.mm:support","WEBVIEW_com.tencent.mm:appbrand1","WEBVIEW_com.android.quicksearchbox"]
日志打印的 chromeOptions
{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:tools","androidDeviceSerial":"ZPRWJREMM4NBL7"}}}
最后切换的时候总是报错 Device ZPRWJREMM4NBL7 is not online\n
info: JSONWP Proxy: Got response with status 200: {"sessionId":"bd50308685a46e4c369e386f881e9ab0","status":13,"value":{"message":"unknown error: Device ZPRWJREMM4NBL7 is not online\n (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.3...
一直说设备不在线,我很绝望,adb devices 设备是在的,请问有没有什么好的解决方法,然后 appium 超时而失败,一直卡在着!

你好!这个问题找到解决办法了吗请教一下?我也出现这个未能定位到问题。

我也出现这种问题,你们都解决了没

你好,我也出现这个问题,请问你解决没

你好,我也出现这个问题,请问你解决了没

弄了很久还没解决

[Chromedriver] Set chromedriver binary as: C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe
[Chromedriver] Killing any old chromedrivers, running: FOR /F "usebackq tokens=5" %a in (netstat -nao ^| findstr /R /C:"8000 ") do (FOR /F "usebackq" %b in (TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe) do (IF NOT %b=="" TASKKILL /F /PID %a))
[Chromedriver] No old chromedrivers seemed to exist
[Chromedriver] Cleaning any old adb forwarded port socket connections
[ADB] List forwarding ports
[ADB] Running 'D:\test\AndroidSdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","UYT0218323001687","forward","--list"]
[ADB] Removing forwarded port socket connection: 12608
[ADB] Running 'D:\test\AndroidSdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","UYT0218323001687","forward","--remove","tcp:12608"]
[Chromedriver] Spawning chromedriver with: C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe --url-base=wd/hub --port=8000 --adb-port=5037 --verbose
[Chromedriver] Chromedriver version: '2.28.455520'
[JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body
[JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"6.1.7601 SP1\"}}}"
[JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:tools","androidDeviceSerial":"UYT0218323001687"}}}
[JSONWP Proxy] Got response with status 200: {"sessionId":"6bc8ba69baf82753c45100b73b2364c6","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
[Chromedriver] Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable
(Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64))
at Object.wrappedLogger.errorAndThrow (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:69:13)
at Chromedriver.callee$2$0$ (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-chromedriver\lib\chromedriver.js:217:13)
at tryCatch (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at
Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable
(Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64))
at Object.wrappedLogger.errorAndThrow (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:69:13)
at Chromedriver.callee$2$0$ (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-chromedriver\lib\chromedriver.js:217:13)
at tryCatch (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at
[JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:tools","androidDeviceSerial":"UYT0218323001687"}}}
[JSONWP Proxy] Got response with status 200: {"sessionId":"ab360dae53ce766dced1e8fc6c9a9ea1","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
[Chromedriver] Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable
(Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64))
at Object.wrappedLogger.errorAndThrow (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:69:13)
at Chromedriver.callee$2$0$ (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-chromedriver\lib\chromedriver.js:217:13)
at tryCatch (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at
Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable
(Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64))
at Object.wrappedLogger.errorAndThrow (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:69:13)
at Chromedriver.callee$2$0$ (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-chromedriver\lib\chromedriver.js:217:13)
at tryCatch (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at
[JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:tools","androidDeviceSerial":"UYT0218323001687"}}}
[JSONWP Proxy] Got response with status 200: {"sessionId":"04ec4c7df9cc160429ecf94f041ccbc4","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
[Chromedriver] Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable
(Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64))
at Object.wrappedLogger.errorAndThrow (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:69:13)
at Chromedriver.callee$2$0$ (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-chromedriver\lib\chromedriver.js:217:13)
at tryCatch (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at
Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable
(Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64))
at Object.wrappedLogger.errorAndThrow (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:69:13)
at Chromedriver.callee$2$0$ (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-chromedriver\lib\chromedriver.js:217:13)
at tryCatch (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (C:\Users\xxq\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at

python+Appium v1.8.0 mac 10.13.5 切换 webview 也是报错,用了上文提到的'chromeOptions':{'androidProcess':'com.tencent.mm:appbrand0'}也还是不行,还有其他解决办法吗?下面是 log 信息

Chromedriver)
[Chromedriver] at Object.wrappedLogger.errorAndThrow (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-support/lib/logging.js:78:13)
[Chromedriver] at Chromedriver.callee$2$0$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/lib/chromedriver.js:357:13)
[Chromedriver] at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[Chromedriver] at GeneratorFunctionPrototype.invoke as _invoke
[Chromedriver] at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
[Chromedriver] at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[Chromedriver] at
[JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8001/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:appbrand0","androidDeviceSerial":"A7QDU17B14000798"}}}
[JSONWP Proxy] Got response with status 200: {"sessionId":"ec3d67c8e917363c4b99a6c82c5f4dd2","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.28.455517 (2c6d2707d8ea850c862f04ac066724273981e88f),platform=Mac OS X 10.13.5 x86_64)"}}
[Chromedriver] Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable
Chromedriver)
[Chromedriver] at Object.wrappedLogger.errorAndThrow (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-support/lib/logging.js:78:13)
[Chromedriver] at Chromedriver.callee$2$0$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/lib/chromedriver.js:357:13)
[Chromedriver] at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[Chromedriver] at GeneratorFunctionPrototype.invoke as _invoke
[Chromedriver] at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
[Chromedriver] at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[Chromedriver] at
[JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8001/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:appbrand0","androidDeviceSerial":"A7QDU17B14000798"}}}
[JSONWP Proxy] Got response with status 200: {"sessionId":"d82cf6ef756edbbbbf0c5fb67d889beb","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.28.455517 (2c6d2707d8ea850c862f04ac066724273981e88f),platform=Mac OS X 10.13.5 x86_64)"}}
[Chromedriver] Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable
Chromedriver)
[Chromedriver] at Object.wrappedLogger.errorAndThrow (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-support/lib/logging.js:78:13)
[Chromedriver] at Chromedriver.callee$2$0$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/lib/chromedriver.js:357:13)
[Chromedriver] at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[Chromedriver] at GeneratorFunctionPrototype.invoke as _invoke
[Chromedriver] at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
[Chromedriver] at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[Chromedriver] at
[JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8001/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:appbrand0","androidDeviceSerial":"A7QDU17B14000798"}}}
[JSONWP Proxy] Got response with status 200: {"sessionId":"ad6ca12b435ad7f35b50fc48cfab0920","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.28.455517 (2c6d2707d8ea850c862f04ac066724273981e88f),platform=Mac OS X 10.13.5 x86_64)"}}
[Chromedriver] Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable
Chromedriver)
[Chromedriver] at Object.wrappedLogger.errorAndThrow (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-support/lib/logging.js:78:13)
[Chromedriver] at Chromedriver.callee$2$0$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/lib/chromedriver.js:357:13)
[Chromedriver] at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[Chromedriver] at GeneratorFunctionPrototype.invoke as _invoke
[Chromedriver] at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
[Chromedriver] at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[Chromedriver] at
[Chromedriver] Chromedriver exited unexpectedly with code null, signal SIGTERM
[Chromedriver] Changed state to 'stopped'
[Chromedriver] Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable
Chromedriver)
[Chromedriver] at Object.wrappedLogger.errorAndThrow (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-support/lib/logging.js:78:13)
[Chromedriver] at Chromedriver.callee$2$0$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/lib/chromedriver.js:357:13)
[Chromedriver] at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[Chromedriver] at GeneratorFunctionPrototype.invoke as _invoke
[Chromedriver] at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
[Chromedriver] at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[Chromedriver] at
[W3C] Encountered internal error running command: Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable
W3C)
[W3C] at Object.wrappedLogger.errorAndThrow (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-support/lib/logging.js:78:13)
[W3C] at Chromedriver.callee$2$0$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/lib/chromedriver.js:357:13)
[W3C] at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[W3C] at GeneratorFunctionPrototype.invoke as _invoke
[W3C] at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
[W3C] at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-chromedriver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[W3C] at
[HTTP] <-- POST /wd/hub/session/42275fbe-8dad-4934-9a3d-967e1326c93b/context 500 244019 ms - 1716
[HTTP]
[HTTP] --> DELETE /wd/hub/session/42275fbe-8dad-4934-9a3d-967e1326c93b

@xxq 你的 chrome not reachable 问题解决没?求助

@nian0099 你好,你那边 chrome not reachable 的问题解决没?我这边也一样,用的是 python3+appium1.8

回复

你可以看我的回复 我的已经解决了 换部手机 可以切换 或者不用切换 你自己直接打印当前页面 你会发现不需要切换 也许美团小程序用了原生的 我觉得如果是原生可以不用切换 用了 h5 就需要切换

有人解决 webview 不能切换的问题吗?烦请告知。崩溃中。

Pauline 回复

你好 请教下能看到 webview 切换 webview 的时候报 chrome not reachable

你好,请问这个问题怎么解决的?

还有人活跃吗,我这边也是一直解决不了,报错 chrome not reachable

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册