测试人社区

微信小程序webview切换的经典错误案例

日志报错

[HTTP] --> POST /wd/hub/session/c5c6de1b-4115-4fb2-882b-94de993bb9ee/context
[HTTP] {"name":"WEBVIEW_xweb"}
[debug] [W3C (c5c6de1b)] Calling AppiumDriver.setContext() with args: ["WEBVIEW_xweb","c5c6de1b-4115-4fb2-882b-94de993bb9ee"]
[debug] [AndroidDriver] Getting a list of available webviews
[debug] [ADB] Running '/Users/seveniruby/Library/Android/sdk/platform-tools/adb -P 5037 -s 030c06a50404 shell cat /proc/net/unix'
[AndroidDriver] Not checking whether webviews have active pages; use the 'ensureWebviewsHavePages' cap to turn this check on
[debug] [AndroidDriver] Found webviews: ["WEBVIEW_xweb"]
[debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_xweb"]
[debug] [AndroidDriver] Connecting to chrome-backed webview context 'WEBVIEW_xweb'
[debug] [AndroidDriver] A port was not given, using random free port: 8000
[debug] [AndroidDriver] Automated Chromedriver download is disabled. Use 'chromedriver_autodownload' server feature to enable it
[debug] [AndroidDriver] Before starting chromedriver, androidPackage is 'com.tencent.mm'
[debug] [Chromedriver] Changed state to 'starting'
[Chromedriver] Set chromedriver binary as: /Users/seveniruby/projects/chromedriver/72/chromedriver
[debug] [Chromedriver] Killing any old chromedrivers, running: pkill -15 -f "/Users/seveniruby/projects/chromedriver/72/chromedriver.*--port=8000"
[Chromedriver] No old chromedrivers seem to exist
[debug] [Chromedriver] Cleaning any old adb forwarded port socket connections
[debug] [ADB] List forwarding ports
[debug] [ADB] Running '/Users/seveniruby/Library/Android/sdk/platform-tools/adb -P 5037 -s 030c06a50404 forward --list'
[Chromedriver] Spawning chromedriver with: /Users/seveniruby/projects/chromedriver/72/chromedriver --url-base=wd/hub --port=8000 --adb-port=5037 --verbose
[debug] [Chromedriver] Chromedriver version: '72.0.3626.69'
[debug] [Chromedriver] Chromedriver v. 72.0.3626.69 does not fully support W3C protocol. Defaulting to MJSONWP
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"","status":0,"value":{"build":{"version":"alpha"},"os":{"arch":"x86_64","name":"Mac OS X","version":"10.14.6"}}}
[Chromedriver] Starting MJSONWP Chromedriver session with capabilities: {
[Chromedriver]   "desiredCapabilities": {
[Chromedriver]     "chromeOptions": {
[Chromedriver]       "androidPackage": "com.tencent.mm",
[Chromedriver]       "androidUseRunningApp": true,
[Chromedriver]       "androidDeviceSerial": "030c06a50404"
[Chromedriver]     },
[Chromedriver]     "loggingPrefs": {
[Chromedriver]       "browser": "ALL"
[Chromedriver]     }
[Chromedriver]   }
[Chromedriver] }
[debug] [WD Proxy] Matched '/session' to command name 'createSession'
[debug] [WD 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":"030c06a50404"},"loggingPrefs":{"browser":"ALL"}}}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"210819e0aa8f5f8bcfd88763a22a572c","status":13,"value":{"message":"unknown error: Failed to get sockets matching: @webview_devtools_remote_.*11159\n  (make sure the app has its WebView configured for debugging)\n  (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Mac OS X 10.14.6 x86_64)"}}
[WD Proxy] Determined the downstream protocol as 'MJSONWP'
[WD Proxy] The response has an unknown format
[debug] [MJSONWP] Matched JSONWP error code 13 to UnknownError
[Chromedriver] Failed to start Chromedriver session: An unknown server-side error occurred while processing the command. Original error: unknown error: Failed to get sockets matching: @webview_devtools_remote_.*11159
[Chromedriver]   (make sure the app has its WebView configured for debugging)
[Chromedriver]   (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Mac OS X 10.14.6 x86_64)
[debug] [WD Proxy] Matched '/session' to command name 'createSession'
[debug] [WD 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":"030c06a50404"},"loggingPrefs":{"browser":"ALL"}}}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"d8b461f661e71841bb88f5c92ea52eaf","status":13,"value":{"message":"unknown error: Failed to get sockets matching: @webview_devtools_remote_.*11159\n  (make sure the app has its WebView configured for debugging)\n  (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Mac OS X 10.14.6 x86_64)"}}
[WD Proxy] Determined the downstream protocol as 'MJSONWP'
[WD Proxy] The response has an unknown format
[debug] [MJSONWP] Matched JSONWP error code 13 to UnknownError
[Chromedriver] Failed to start Chromedriver session: An unknown server-side error occurred while processing the command. Original error: unknown error: Failed to get sockets matching: @webview_devtools_remote_.*11159
[Chromedriver]   (make sure the app has its WebView configured for debugging)
[Chromedriver]   (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Mac OS X 10.14.6 x86_64)
[debug] [WD Proxy] Matched '/session' to command name 'createSession'
[debug] [WD 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":"030c06a50404"},"loggingPrefs":{"browser":"ALL"}}}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"ee8e182510e087b1e7fd4b7c0a6b131f","status":13,"value":{"message":"unknown error: Failed to get sockets matching: @webview_devtools_remote_.*11159\n  (make sure the app has its WebView configured for debugging)\n  (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Mac OS X 10.14.6 x86_64)"}}
[WD Proxy] Determined the downstream protocol as 'MJSONWP'
[WD Proxy] The response has an unknown format
[debug] [MJSONWP] Matched JSONWP error code 13 to UnknownError
[Chromedriver] Failed to start Chromedriver session: An unknown server-side error occurred while processing the command. Original error: unknown error: Failed to get sockets matching: @webview_devtools_remote_.*11159
[Chromedriver]   (make sure the app has its WebView configured for debugging)
[Chromedriver]   (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Mac OS X 10.14.6 x86_64)
[debug] [WD Proxy] Matched '/session' to command name 'createSession'
[debug] [WD 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":"030c06a50404"},"loggingPrefs":{"browser":"ALL"}}}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"47d8b76fd6986b94bde044531cc8dfbe","status":13,"value":{"message":"unknown error: Failed to get sockets matching: @webview_devtools_remote_.*11159\n  (make sure the app has its WebView configured for debugging)\n  (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Mac OS X 10.14.6 x86_64)"}}
[WD Proxy] Determined the downstream protocol as 'MJSONWP'
[WD Proxy] The response has an unknown format
[debug] [MJSONWP] Matched JSONWP error code 13 to UnknownError
[Chromedriver] Failed to start Chromedriver session: An unknown server-side error occurred while processing the command. Original error: unknown error: Failed to get sockets matching: @webview_devtools_remote_.*11159
[Chromedriver]   (make sure the app has its WebView configured for debugging)
[Chromedriver]   (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Mac OS X 10.14.6 x86_64)
[Chromedriver] Chromedriver exited unexpectedly with code null, signal SIGTERM
[debug] [Chromedriver] Changed state to 'stopped'
[Chromedriver] An unknown server-side error occurred while processing the command. Original error: unknown error: Failed to get sockets matching: @webview_devtools_remote_.*11159
[Chromedriver]   (make sure the app has its WebView configured for debugging)
[Chromedriver]   (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Mac OS X 10.14.6 x86_64)
[debug] [W3C (c5c6de1b)] Encountered internal error running command: Error: An unknown server-side error occurred while processing the command. Original error: unknown error: Failed to get sockets matching: @webview_devtools_remote_.*11159
[debug] [W3C (c5c6de1b)]   (make sure the app has its WebView configured for debugging)
[debug] [W3C (c5c6de1b)]   (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Mac OS X 10.14.6 x86_64)
[debug] [W3C (c5c6de1b)]     at Object.errorAndThrow (/usr/local/lib/node_modules/appium/node_modules/appium-support/lib/logging.js:74:35)
[debug] [W3C (c5c6de1b)]     at Chromedriver.start (/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/lib/chromedriver.js:569:11)
[HTTP] <-- POST /wd/hub/session/c5c6de1b-4115-4fb2-882b-94de993bb9ee/context 500 2364 ms - 1191

错误日志的解读

微信小程序的webview

seveniruby:~ seveniruby$ adb shell cat /proc/net/unix | grep devtool
0000000000000000: 00000002 00000000 00010000 0001 01 58649 @xweb_devtools_remote_7567
0000000000000000: 00000002 00000000 00010000 0001 01 58565 @xweb_devtools_remote_7206
0000000000000000: 00000002 00000000 00010000 0001 01 50145 @xweb_devtools_remote_6671

报错相关的语句

[debug] [WD Proxy] Got response with status 200: {"sessionId":"210819e0aa8f5f8bcfd88763a22a572c","status":13,"value":{"message":"unknown error: Failed to get sockets matching: @webview_devtools_remote_.*11159\n  (make sure the app has its WebView configured for debugging)\n  (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Mac OS X 10.14.6 x86_64)"}}

类似错误还包括

[Chromedriver] Failed to start Chromedriver session: An unknown server-side error occurred while processing the command. Original error: unknown error: Failed to get sockets matching: @weblayer_devtools_remote_.*18878

解决了@xweb_devtools_remote_问题后

[debug] [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"capabilities":{"alwaysMatch":{"goog:chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidDeviceSerial":"030c06a50404"},"goog:loggingPrefs":{"browser":"ALL"}}}}
[WD Proxy] Got an unexpected response with status 408: {"value":{"error":"timeout","message":"timeout: Adb command timed out after 30 seconds\n  (make sure the app has its WebView configured for debugging)","stacktrace":"0   chromedriver_78.0.3904.11           0x000000010c4be309 chromedriver_78.0.3904.11 + 3748617\n1   chromedriver_78.0.3904.11           0x000000010c452943 chromedriver_78.0.3904.11 + 3307843\n2   chromedriver_78.0.3904.11           0x000000010c1e244f chromedriver_78.0.3904.11 + 750671\n3   chromedriver_78.0.3904.11           0x000000010c1c886a chromedriver_78.0.3904.11 + 645226\n4   chromedriver_78.0.3904.11           0x000000010c1c782a chromedriver_78.0.3904.11 + 641066\n5   chromedriver_78.0.3904.11           0x000000010c1c8d58 chromedriver_78.0.3904.11 + 646488\n6   chromedriver_78.0.3904.11           0x000000010c1c9ae1 chromedriver_78.0.3904.11 + 649953\n7   chromedriver_78.0.3904.11           0x000000010c1d2bed chromedriver_78.0.3904.11 + 687085\n8   chromedriver_78.0.3904.11           0x000000010c1d29d7 chromedriver_78.0.3904.11 + 686551...
[debug] [W3C] Matched W3C error code 'timeout' to TimeoutError
[Chromedriver] Failed to start Chromedriver session: timeout: Adb command timed out after 30 seconds
[Chromedriver]   (make sure the app has its WebView configured for debugging)

解决办法参考其他帖子