Appium [求助] appium 切换到 webview 下,执行 webview 下的第二次操作时,proxying chromedriver 的 session 请求无响应

· 2016年11月02日 · 最后由 aa1111 回复于 2022年08月23日 · 4465 次阅读

今天执行碰到个问题,简单地说就是

appium 切换到 webview 下,在 webview 下执行第二个点击操作时操作时,appium session 去 proxying 到 chromedriver 的 session 时请求无响应。
相关信息如下:
设备:OPPO R7
appium 版本:1.5.3
chromedriver 版本:2.25
client 版本:java_client 4.1
app 内置浏览器内核:据开发说是改为了 TX 的 x5 内核
日志如下(从切换 webview 开始,到最后请求无响应结束的所有日志)

2016-11-02 16:51:48:343 - [debug] [AndroidDriver] from: u0_a384,25454,249,1506648,220112,ffffffff,00000000,S,com.aixuedai.axd
2016-11-02 16:51:48:343 - [debug] [AndroidDriver] returning process name: com.aixuedai.axd
2016-11-02 16:51:48:343 - [debug] [AndroidDriver] Found webviews: ["WEBVIEW_com.aixuedai.axd"]
2016-11-02 16:51:48:343 - [debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_com.aixuedai.axd"]
2016-11-02 16:51:48:343 - [MJSONWP] Responding to client with driver.getContexts() result: ["NATIVE_APP","WEBVIEW_com....
2016-11-02 16:51:48:343 - [HTTP] <-- GET /wd/hub/session/59646e68-67b3-49d1-b89a-73b075a9113e/contexts 200 226 ms - 113
2016-11-02 16:51:48:359 - [HTTP] --> POST /wd/hub/session/59646e68-67b3-49d1-b89a-73b075a9113e/context {"name":"WEBVIEW_com.aixuedai.axd"}
2016-11-02 16:51:48:359 - [MJSONWP] Calling AppiumDriver.setContext() with args: ["WEBVIEW_com.aixuedai.axd"...
2016-11-02 16:51:48:359 - [debug] [AndroidDriver] Getting a list of available webviews
2016-11-02 16:51:48:359 - [debug] [ADB] Getting connected devices...
2016-11-02 16:51:48:375 - [debug] [ADB] 1 device(s) connected
2016-11-02 16:51:48:375 - [debug] [ADB] Running D:\Tools\android-sdk-windows\platform-tools\adb.exe with args: ["-P",5037,"-s","KZZLQSPNKZGEVWK7","shell","cat","/proc/net/unix"]
2016-11-02 16:51:48:422 - [debug] [AndroidDriver] WEBVIEW_25454 mapped to pid 25454
2016-11-02 16:51:48:422 - [debug] [AndroidDriver] Getting process name for webview
2016-11-02 16:51:48:422 - [debug] [ADB] Getting connected devices...
2016-11-02 16:51:48:437 - [debug] [ADB] 1 device(s) connected
2016-11-02 16:51:48:437 - [debug] [ADB] Running D:\Tools\android-sdk-windows\platform-tools\adb.exe with args: ["-P",5037,"-s","KZZLQSPNKZGEVWK7","shell","ps"]
2016-11-02 16:51:48:547 - [debug] [AndroidDriver] Parsed pid: 25454 pkg: com.aixuedai.axd!
2016-11-02 16:51:48:547 - [debug] [AndroidDriver] from: u0_a384,25454,249,1508984,221296,ffffffff,00000000,S,com.aixuedai.axd
2016-11-02 16:51:48:547 - [debug] [AndroidDriver] returning process name: com.aixuedai.axd
2016-11-02 16:51:48:547 - [debug] [AndroidDriver] Found webviews: ["WEBVIEW_com.aixuedai.axd"]
2016-11-02 16:51:48:547 - [debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_com.aixuedai.axd"]
2016-11-02 16:51:48:547 - [debug] [AndroidDriver] Connecting to chrome-backed webview context 'WEBVIEW_com.aixuedai.axd'
2016-11-02 16:51:48:547 - [debug] [Chromedriver] Changed state to 'starting'
2016-11-02 16:51:48:625 - [Chromedriver] Set chromedriver binary as: C:\Users\hwb\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe
2016-11-02 16:51:48:625 - [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))
2016-11-02 16:51:48:703 - [Chromedriver] No old chromedrivers seemed to exist
2016-11-02 16:51:48:719 - [Chromedriver] Spawning chromedriver with: C:\Users\hwb\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe --url-base=wd/hub --port=9515 --adb-port=5037
2016-11-02 16:51:49:063 - [Chromedriver] [STDOUT] Starting ChromeDriver 2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed) on port 9515
Only local connections are allowed.
2016-11-02 16:51:49:078 - [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
2016-11-02 16:51:49:094 - [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"stat...
2016-11-02 16:51:49:094 - [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"ch...
2016-11-02 16:51:51:735 - [JSONWP Proxy] Got response with status 200: {"sessionId":"c6856afd440d4...
2016-11-02 16:51:51:751 - [debug] [Chromedriver] Changed state to 'online'
2016-11-02 16:51:51:751 - [MJSONWP] Responding to client with driver.setContext() result: null
2016-11-02 16:51:51:751 - [HTTP] <-- POST /wd/hub/session/59646e68-67b3-49d1-b89a-73b075a9113e/context 200 3396 ms - 76
2016-11-02 16:51:54:783 - [HTTP] --> POST /wd/hub/session/59646e68-67b3-49d1-b89a-73b075a9113e/execute {"script":"document.getElementById('J_go').click()","args":[]}
2016-11-02 16:51:54:783 - [MJSONWP] Driver proxy active, passing request on via HTTP proxy
2016-11-02 16:51:54:783 - [JSONWP Proxy] Proxying [POST /wd/hub/session/59646e68-67b3-49d1-b89a-73b075a9113e/execute] to [POST http://127.0.0.1:9515/wd/hub/session/c6856afd440d4877fdb0c07ee0303108/execute] with body: {"script":"document.getElem...
2016-11-02 16:51:54:970 - [JSONWP Proxy] Got response with status 200: {"sessionId":"c6856afd440d4...
2016-11-02 16:51:54:970 - [JSONWP Proxy] Replacing sessionId c6856afd440d4877fdb0c07ee0303108 with 59646e68-67b3-49d1-b89a-73b075a9113e
2016-11-02 16:51:54:970 - [HTTP] <-- POST /wd/hub/session/59646e68-67b3-49d1-b89a-73b075a9113e/execute 200 197 ms - 76
2016-11-02 16:51:58:018 - [HTTP] --> POST /wd/hub/session/59646e68-67b3-49d1-b89a-73b075a9113e/execute {"script":"document.getElementById('J_Submit').click()","args":[]}
2016-11-02 16:51:58:018 - [MJSONWP] Driver proxy active, passing request on via HTTP proxy
2016-11-02 16:51:58:018 - [JSONWP Proxy] Proxying [POST /wd/hub/session/59646e68-67b3-49d1-b89a-73b075a9113e/execute] to [POST http://127.0.0.1:9515/wd/hub/session/c6856afd440d4877fdb0c07ee0303108/execute] with body: {"script":"document.getElem...

可以看到,执行到最后的

2016-11-02 16:51:58:018 - [JSONWP Proxy] Proxying [POST /wd/hub/session/59646e68-67b3-49d1-b89a-73b075a9113e/execute] to [POST http://127.0.0.1:9515/wd/hub/session/c6856afd440d4877fdb0c07ee0303108/execute] with body: {"script":"document.getElem...

这一步后,就再没有收到相应的 response,日志没有报错,运行的 client 脚本也没报错,一直处于运行状态,相关的 java 代码如下:

//调用封装的切换webvie方法切换到webview模式:
appcomm.switchToWebView(driver);

//webview模式下操作app
jse.executeScript("document.getElementById('J_go').click()");
logger.info("****");       
comm.forceWaiting(3000);
jse.executeScript("document.getElementById('J_Submit').click()");
logger.info("****");

奇怪的是,执行第一步

jse.executeScript("document.getElementById('J_go').click()");

可以正常执行,但是执行第二步

jse.executeScript("document.getElementById('J_Submit').click()");

就无响应。请各位大神指教。

问题更新

等待 5 分钟后,appium 终于排除异常,如下:

2016-11-02 17:26:58:101 - [BaseDriver] Shutting down because we waited 300 seconds for a command
2016-11-02 17:26:58:106 - [debug] [AndroidDriver] Shutting down Android driver
2016-11-02 17:26:58:109 - [Appium] Closing session, cause was 'New Command Timeout of 300 seconds expired. Try customizing the timeout using the 'newCommandTimeout' desired capability'
2016-11-02 17:26:58:110 - [Appium] Removing session 59646e68-67b3-49d1-b89a-73b075a9113e from our master session list
2016-11-02 17:26:58:116 - [debug] [AndroidDriver] Stopping chromedriver for context WEBVIEW_com.aixuedai.axd
2016-11-02 17:26:58:119 - [debug] [Chromedriver] Changed state to 'stopping'
2016-11-02 17:26:58:123 - [JSONWP Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:9515/wd/hub/session/c6856afd440d4877fdb0c07ee0303108] with no body
2016-11-02 17:26:58:225 - [MJSONWP] Encountered internal error running command: Error: Could not proxy. Proxy error: New Command Timeout of 300 seconds expired. Try customizing the timeout using the 'newCommandTimeout' desired capability
    at doJwpProxy$ (lib/mjsonwp/mjsonwp.js:329:11)
    at tryCatch (C:\Users\hwb\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\hwb\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\hwb\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (C:\Users\hwb\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
    at process._tickCallback (internal/process/next_tick.js:103:7)
2016-11-02 17:31:58:115 - [Chromedriver] [STDERR] [2409.039][SEVERE]: Timed out receiving message from renderer: 600.000

好了,可以断定就是 proxy 的问题。

依然请教各位大神!

共收到 21 条回复 时间 点赞

这个我也遇到过,webview 自动化的时候,你打开 chrome 的 inspect 功能就没事儿。
chrome://inspect

#2 · 2016年11月03日 Author

#1 楼 @jinjun0620 是的 chrome 的调试工具是可以识别该页面的,但是卡住的这个时候去点击 inspect 会解析不了页面,提示冲突

@darkmanno6 启动自动化之前一直打开 inspect 的话就不会出现无响应的现象。(我是这样解决的)

#4 · 2016年11月03日 Author

#3 楼 @jinjun0620 还是不行,没有用。

楼主解决了吗? 我也出现了,第二次进入 webview

#6 · 2016年11月28日 Author

#5 楼 @jira 没有解决,估计和设备有关,我换了设备就可以了,你可以试试。

#6 楼 @darkmanno6 你换的手机是什么版本的?

我额遇到同样的问题

#9 · 2017年01月18日 Author

#7 楼 @jira 华为荣耀 6.

您好,我也是 appium 切换 webview 后,进入 url 后再次点击链接,进入第二页面的 url 后没有反应,此时使用代码: System.out.println(driver.getCurrentUrl());一直没有响应,知道最后 timeout 了。貌似加载到第二页的 url 后,chromedriver 不能获取 body 的信息,导致这个页面加载失败。有人解决这个类似的问题么?

timeout 之前显示错误信息:
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/mff/Desktop/workspace/android-sdk-macosx/platform-tools/adb' with args: ["-P",5037,"-s","57b51c43","shell","ps"]
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/mff/Desktop/workspace/android-sdk-macosx/platform-tools/adb' with args: ["-P",5037,"-s","57b51c43","shell","ps"]
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/mff/Desktop/workspace/android-sdk-macosx/platform-tools/adb' with args: ["-P",5037,"-s","57b51c43","shell","ps"]
[debug] [AndroidDriver] Parsed pid: 16121 pkg: com.tencent.mm:tools!
[debug] [AndroidDriver] from: u0_a124,16121,466,1701652,157084,ffffffff,00000000,S,com.tencent.mm:tools
[debug] [AndroidDriver] returning process name: com.tencent.mm:tools
[debug] [AndroidDriver] Parsed pid: 23591 pkg: com.android.browser!
[debug] [AndroidDriver] from: u0_a2,23591,466,1191136,66424,ffffffff,00000000,S,com.android.browser
[debug] [AndroidDriver] returning process name: com.android.browser
[debug] [AndroidDriver] Parsed pid: 20021 pkg: com.android.quicksearchbox!
[debug] [AndroidDriver] from: u0_a80,20021,465,1992180,93528,ffffffff,00000000,S,com.android.quicksearchbox
[debug] [AndroidDriver] returning process name: com.android.quicksearchbox
[debug] [AndroidDriver] Found webviews: ["WEBVIEW_com.android.browser","WEBVIEW_com.tencent.mm:tools","WEBVIEW_com.android.quicksearchbox"]
[debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_com.android.browser","WEBVIEW_com.tencent.mm:tools","WEBVIEW_com.android.quicksearchbox"]
[debug] [AndroidDriver] Connecting to chrome-backed webview context 'WEBVIEW_com.tencent.mm:tools'
[debug] [AndroidDriver] A port was not given, using random port: 8002
[debug] [Chromedriver] Changed state to 'starting'
[Chromedriver] Set chromedriver binary as: /usr/local/lib/node_modules/appium/node_modules/.2.10.0@appium-chromedriver/chromedriver/mac/chromedriver
[Chromedriver] Killing any old chromedrivers, running: pkill -15 -f "/usr/local/lib/node_modules/appium/node_modules/.2.10.0@appium-chromedriver/chromedriver/mac/chromedriver.*--port=8002"
[Chromedriver] No old chromedrivers seemed to exist
[Chromedriver] Spawning chromedriver with: /usr/local/lib/node_modules/appium/node_modules/.2.10.0@appium-chromedriver/chromedriver/mac/chromedriver --url-base=wd/hub --port=8002 --adb-port=5037
[Chromedriver] [STDOUT] Starting ChromeDriver 2.26.436421 (6c1a3ab469ad86fd49c8d97ede4a6b96a49ca5f6) on port 8002
Only local connections are allowed.
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8002/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\":\"Mac OS X\",\"version\":\"10.12.3\"}}}"
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8002/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"args":[],"extensions":[],"androidProcess":"com.tencent.mm:tools","androidDeviceSerial":"57b51c43"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"bb37a650bdf7b09a3af75a32e9d6247d","status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.26.436421 (6c1a3ab469ad86fd49c8d97ede4a6b96a49ca5f6)"},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"hasTouchScreen":true,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":false,"nativeEvents":true,"pageLoadStrategy":"normal","platform":"ANDROID","rotatable":false,"takesHeapSnapshot":true,"takesScreenshot":true,"unexpectedAlertBehaviour":"","version":"53.0.2785.49","webStorageEnabled":true}}
[debug] [Chromedriver] Changed state to 'online'
[debug] [MJSONWP] Responding to client with driver.setContext() result: null
[HTTP] <-- POST /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/context 200 609 ms - 76
[HTTP] --> GET /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/url {}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [GET /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/url] to [GET http://127.0.0.1:8002/wd/hub/session/bb37a650bdf7b09a3af75a32e9d6247d/url] with body: {}
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"bb37a650bdf7b09a3af75a32e9d6247d\",\"status\":0,\"value\":\"https://h5.koudaitong.com/v2/common/error/closed?kdt_id=512479\"}"
[JSONWP Proxy] Replacing sessionId bb37a650bdf7b09a3af75a32e9d6247d with 26554ee3-1ce5-4e52-9773-54db34ebcaea
[HTTP] <-- GET /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/url 200 78 ms - 136
[HTTP] --> GET /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/window_handle {}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [GET /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/window_handle] to [GET http://127.0.0.1:8002/wd/hub/session/bb37a650bdf7b09a3af75a32e9d6247d/window_handle] with body: {}
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"bb37a650bdf7b09a3af75a32e9d6247d\",\"status\":0,\"value\":\"CDwindow-e24c7eee-f6f0-4a6b-9f17-afb56624c460\"}"
[JSONWP Proxy] Replacing sessionId bb37a650bdf7b09a3af75a32e9d6247d with 26554ee3-1ce5-4e52-9773-54db34ebcaea
[HTTP] <-- GET /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/window_handle 200 5 ms - 119
[HTTP] --> POST /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/element {"using":"xpath","value":"/html/body/div/div/a"}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/element] to [POST http://127.0.0.1:8002/wd/hub/session/bb37a650bdf7b09a3af75a32e9d6247d/element] with body: {"using":"xpath","value":"/html/body/div/div/a"}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"bb37a650bdf7b09a3af75a32e9d6247d","status":0,"value":{"ELEMENT":"0.8047745299561335-1"}}
[JSONWP Proxy] Replacing sessionId bb37a650bdf7b09a3af75a32e9d6247d with 26554ee3-1ce5-4e52-9773-54db34ebcaea
[HTTP] <-- POST /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/element 200 97 ms - 106
[HTTP] --> GET /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/element/0.8047745299561335-1/text {}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [GET /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/element/0.8047745299561335-1/text] to [GET http://127.0.0.1:8002/wd/hub/session/bb37a650bdf7b09a3af75a32e9d6247d/element/0.8047745299561335-1/text] with body: {}
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"bb37a650bdf7b09a3af75a32e9d6247d\",\"status\":0,\"value\":\"前往会员主页\"}"
[JSONWP Proxy] Replacing sessionId bb37a650bdf7b09a3af75a32e9d6247d with 26554ee3-1ce5-4e52-9773-54db34ebcaea
[HTTP] <-- GET /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/element/0.8047745299561335-1/text 200 110 ms - 92
[HTTP] --> POST /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/element/0.8047745299561335-1/click {"id":"0.8047745299561335-1"}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/element/0.8047745299561335-1/click] to [POST http://127.0.0.1:8002/wd/hub/session/bb37a650bdf7b09a3af75a32e9d6247d/element/0.8047745299561335-1/click] with body: {"id":"0.8047745299561335-1"}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"bb37a650bdf7b09a3af75a32e9d6247d","status":0,"value":null}
[JSONWP Proxy] Replacing sessionId bb37a650bdf7b09a3af75a32e9d6247d with 26554ee3-1ce5-4e52-9773-54db34ebcaea
[HTTP] <-- POST /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/element/0.8047745299561335-1/click 200 266 ms - 76
[HTTP] --> GET /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/url {}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [GET /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/url] to [GET http://127.0.0.1:8002/wd/hub/session/bb37a650bdf7b09a3af75a32e9d6247d/url] with body: {}

[MJSONWP] Encountered internal error running command: Error: Could not proxy. Proxy error: Could not proxy command to remote server. Original error: Error: ESOCKETTIMEDOUT
at doJwpProxy$ (../../../lib/mjsonwp/mjsonwp.js:343:13)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:136:37)
[HTTP] <-- GET /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea/url 500 240009 ms - 281
[HTTP] --> DELETE /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea {}
[debug] [MJSONWP] Calling AppiumDriver.deleteSession() with args: ["26554ee3-1ce5-4e52-9773-54db34ebcaea"]
[debug] [AndroidDriver] Shutting down Android driver
[debug] [AndroidDriver] Stopping chromedriver for context WEBVIEW_com.tencent.mm:tools
[debug] [Chromedriver] Changed state to 'stopping'
[debug] [JSONWP Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8002/wd/hub/session/bb37a650bdf7b09a3af75a32e9d6247d] with no body
[Chromedriver] [STDERR] [304.967][SEVERE]: Timed out receiving message from renderer: 300.000
[Chromedriver] [STDERR] [421.311][SEVERE]: Unable to receive message from renderer
[Logcat] Logcat terminated with code 0, signal null
[UiAutomator] UiAutomator exited unexpectedly with code 0, signal null
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [AndroidDriver] Shutting down Android driver
[Appium] Closing session, cause was 'UiAUtomator shut down unexpectedly'
[Appium] Removing session 26554ee3-1ce5-4e52-9773-54db34ebcaea from our master session list
[debug] [AndroidDriver] Stopping chromedriver for context WEBVIEW_com.tencent.mm:tools
[debug] [Chromedriver] Changed state to 'stopping'
[debug] [JSONWP Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8002/wd/hub/session/bb37a650bdf7b09a3af75a32e9d6247d] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"bb37a650bdf7b09a3af75a32e9d6247d\",\"status\":0,\"value\":null}"
[Chromedriver] ProxyRequestError: Could not proxy command to remote server. Original error: Error: connect ECONNREFUSED 127.0.0.1:8002
at JWProxy.proxy$ (../../../lib/jsonwp-proxy/proxy.js:127:13)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:136:37)
{ ProxyRequestError: Could not proxy command to remote server. Original error: Error: connect ECONNREFUSED 127.0.0.1:8002
at JWProxy.proxy$ (../../../lib/jsonwp-proxy/proxy.js:127:13)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:136:37)
jsonwp:
{ Error: connect ECONNREFUSED 127.0.0.1:8002
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at TCPConnectWrap.afterConnect as oncomplete
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 8002 } }
[debug] [ADB] Getting connected devices...
[debug] [Chromedriver] Changed state to 'stopped'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 0 device(s) connected
Unhandled rejection Error: No device connected, cannot run adb shell command 'am force-stop com.tencent.mm'
at ADB.callee$0$0$ (../../../lib/tools/system-calls.js:208:11)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/.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 (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:136:37)
[debug] [ADB] 0 device(s) connected
[Appium] Had trouble ending session 26554ee3-1ce5-4e52-9773-54db34ebcaea: No device connected, cannot run adb shell command 'am force-stop com.tencent.mm'
[Appium] Removing session 26554ee3-1ce5-4e52-9773-54db34ebcaea from our master session list
[MJSONWP] Encountered internal error running command: Error: No device connected, cannot run adb shell command 'am force-stop com.tencent.mm'
at ADB.callee$0$0$ (../../../lib/tools/system-calls.js:208:11)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/.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 (/usr/local/lib/node_modules/appium/node_modules/.5.8.24@babel-runtime/regenerator/runtime.js:136:37)
at process._tickCallback (internal/process/next_tick.js:103:7)
[HTTP] <-- DELETE /wd/hub/session/26554ee3-1ce5-4e52-9773-54db34ebcaea 500 176308 ms - 251

#12 · 2017年02月21日 Author

找到一个暂时解决问题的办法,在再次进入一个 h5 页面的时候,先切回 native,然后再切一次到 webview 就可以进行后续操作了,大家可以试试

回复

遇到了同样的问题,求分享解决方案

回复

切回 native,再一次切到 webview 的时候失败了,报错 session 找不到

appium 的配置里设置 recreateChromeDriverSessions 为 true 试试

rita07 回复

文档上没有这个属性啊

rita07 回复

尝试了下,这个属性确实有用, 感谢!

yuxiu 回复

我也碰到这种问题了,怎么设置的,能贴出来吗?

微信 webview 看思寒的帖子https://testerhome.com/topics/6954
desired_caps['chromeOptions'] = {'androidProcess': 'com.tencent.mm:tools'} 切换微信里边 webview
self.driver.switch_to.context('WEBVIEW_com.tencent.mm:tools')
webview 第一次点击操作后继续操作无响应的问题暂时没找到原因暂这么处理了,切换到 native 再切换回 webview,需要再添加一条desired_caps['recreateChromeDriverSessions'] = True appium API 上说的是每次切换到非 chrome-Driver 时 kill 掉 session 注意这个设置在 appium 1.5 版本上才做了处理,1.4 版本上是有问题的。查看 github 的 issue
https://github.com/appium/appium/issues/4502

沙子 回复

你好,不知道目前 appium 版本是否已经解决该问题,但是按你说的操作还是能解决问题的

rita07 回复

您好 ,我设置了这个参数,但是还是不行,您是怎么解决的呢?

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