最近在学习移动端自动化,遇到一个问题,就是每次在切换context操作时,chromedriver就会停止,起初一直以为是版本不兼容的问题,但是看日志信息貌似并不是。日志信息如下:
[AndroidDriver] Getting process name for webview
[ADB] Running ‘E:\android-sdk\platform-tools\adb.exe -P 5037 -s 127.0.0.1:62001 shell ps’
[AndroidDriver] Parsed pid: ‘3402’ pkg: ‘com.foreverht.workplus.htkgszgyy’ from
[AndroidDriver] USER PID PPID VSIZE RSS WCHAN PC NAME
[AndroidDriver] u0_a36 3402 1483 1529344 267368 ffffffff b754f355 S com.foreverht.workplus.htkgszgyy
[AndroidDriver] Returning process name: ‘com.foreverht.workplus.htkgszgyy’
[AndroidDriver] Found webviews: [“WEBVIEW_com.foreverht.workplus.htkgszgyy”]
[AndroidDriver] Available contexts: [“NATIVE_APP”,“WEBVIEW_com.foreverht.workplus.htkgszgyy”]
[AndroidDriver] Connecting to chrome-backed webview context ‘WEBVIEW_com.foreverht.workplus.htkgszgyy’
[AndroidDriver] A port was not given, using random free port: 8000
[AndroidDriver] Automated Chromedriver download is disabled. Use ‘chromedriver_autodownload’ server feature to enable it
[AndroidDriver] Before starting chromedriver, androidPackage is ‘undefined’
[Chromedriver] Changed state to ‘starting’
[Chromedriver] Found 6 executables in ‘D:\chromedrivers’
[Chromedriver] The following Chromedriver executables were found:
[Chromedriver] ‘D:/chromedrivers/chromedriver7612.exe’ (version ‘76.0.3809.12’, minimum Chrome version ‘76.0.3809’)
[Chromedriver] ‘D:/chromedrivers/chromedriver75140.exe’ (version ‘75.0.3770.140’, minimum Chrome version ‘75.0.3770’)
[Chromedriver] ‘D:/chromedrivers/chromedriver758.exe’ (version ‘75.0.3770.8’, minimum Chrome version ‘75.0.3770’)
[Chromedriver] ‘D:/chromedrivers/chromedriver74.exe’ (version ‘74.0.3729.6’, minimum Chrome version ‘74.0.3729’)
[Chromedriver] ‘D:/chromedrivers/chromedriver7368.exe’ (version ‘73.0.3683.68’, minimum Chrome version ‘70.0.3538’)
[Chromedriver] ‘D:/chromedrivers/chromedriver7320.exe’ (version ‘73.0.3683.20’, minimum Chrome version ‘Unknown’)
[ADB] Getting package info for ‘com.google.android.webview’
[ADB] Running ‘E:\android-sdk\platform-tools\adb.exe -P 5037 -s 127.0.0.1:62001 shell dumpsys package com.google.android.webview’
[Chromedriver] Found Chrome bundle ‘com.google.android.webview’ version ‘74.0.3729’
[Chromedriver] Found 1 Chromedriver executable capable of automating Chrome ‘74.0.3729’.
[Chromedriver] Choosing the most recent, ‘D:/chromedrivers/chromedriver74.exe’.
[Chromedriver] If a specific version is required, specify it with the chromedriverExecutable
desired capability.
[Chromedriver] Set chromedriver binary as: D:/chromedrivers/chromedriver74.exe
[Chromedriver] Killing any old chromedrivers, running: wmic process where “commandline like ‘%chromedriver.exe%–port=8000%’” delete
[Chromedriver] Successfully cleaned up old chromedrivers
[Chromedriver] Cleaning any old adb forwarded port socket connections
[ADB] List forwarding ports
[ADB] Running ‘E:\android-sdk\platform-tools\adb.exe -P 5037 -s 127.0.0.1:62001 forward --list’
[Chromedriver] Spawning chromedriver with: D:/chromedrivers/chromedriver74.exe --url-base=wd/hub --port=8000 --adb-port=5037 --verbose
[Chromedriver] Chromedriver version: ‘74.0.3729.6’
[Chromedriver] Chromedriver v. 74.0.3729.6 does not fully support W3C protocol. Defaulting to MJSONWP
[WD Proxy] Matched ‘/status’ to command name ‘getStatus’
[WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body
[WD Proxy] Got response with status 200: {“sessionId”:"",“status”:0,“value”:{“build”:{“version”:“74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29})”},“message”:“ChromeDriver ready for new sessions.”,“os”:{“arch”:“x86_64”,“name”:“Windows NT”,“version”:“10.0.18363”},“ready”:true}}
[Chromedriver] Starting MJSONWP Chromedriver session with capabilities: {
[Chromedriver] “desiredCapabilities”: {
[Chromedriver] “chromeOptions”: {
[Chromedriver] “androidUseRunningApp”: true,
[Chromedriver] “androidDeviceSerial”: “127.0.0.1:62001”
[Chromedriver] },
[Chromedriver] “loggingPrefs”: {
[Chromedriver] “browser”: “ALL”
[Chromedriver] }
[Chromedriver] }
[Chromedriver] }
[WD Proxy] Matched ‘/session’ to command name ‘createSession’
[WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidUseRunningApp”:true,“androidDeviceSerial”:“127.0.0.1:62001”},“loggingPrefs”:{“browser”:“ALL”}}}
[WD Proxy] Got response with status 200: {“sessionId”:“1f0a2a33241eb7d01b86f3f02774228d”,“status”:61,“value”:{“message”:“invalid argument: cannot parse capability: chromeOptions\nfrom invalid argument: unrecognized chrome option: androidDeviceSerial\n (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.18363 x86_64)”}}
[WD Proxy] Determined the downstream protocol as ‘MJSONWP’
[WD Proxy] The response has an unknown format
[MJSONWP] Matched JSONWP error code 61 to InvalidArgumentError
[Chromedriver] Failed to start Chromedriver session: invalid argument: cannot parse capability: chromeOptions
[Chromedriver] from invalid argument: unrecognized chrome option: androidDeviceSerial
[Chromedriver] (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.18363 x86_64)
[WD Proxy] Matched ‘/session’ to command name ‘createSession’
[WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidUseRunningApp”:true,“androidDeviceSerial”:“127.0.0.1:62001”},“loggingPrefs”:{“browser”:“ALL”}}}
[WD Proxy] Got response with status 200: {“sessionId”:“3b78317b55814558b7079e66be1f9cf8”,“status”:61,“value”:{“message”:“invalid argument: cannot parse capability: chromeOptions\nfrom invalid argument: unrecognized chrome option: androidDeviceSerial\n (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.18363 x86_64)”}}
[WD Proxy] Determined the downstream protocol as ‘MJSONWP’
[WD Proxy] The response has an unknown format
[MJSONWP] Matched JSONWP error code 61 to InvalidArgumentError
[Chromedriver] Failed to start Chromedriver session: invalid argument: cannot parse capability: chromeOptions
[Chromedriver] from invalid argument: unrecognized chrome option: androidDeviceSerial
[Chromedriver] (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.18363 x86_64)
[WD Proxy] Matched ‘/session’ to command name ‘createSession’
[WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidUseRunningApp”:true,“androidDeviceSerial”:“127.0.0.1:62001”},“loggingPrefs”:{“browser”:“ALL”}}}
[WD Proxy] Got response with status 200: {“sessionId”:“e9a9fdea6ede6f8c031878d56f7208a6”,“status”:61,“value”:{“message”:“invalid argument: cannot parse capability: chromeOptions\nfrom invalid argument: unrecognized chrome option: androidDeviceSerial\n (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.18363 x86_64)”}}
[WD Proxy] Determined the downstream protocol as ‘MJSONWP’
[WD Proxy] The response has an unknown format
[MJSONWP] Matched JSONWP error code 61 to InvalidArgumentError
[Chromedriver] Failed to start Chromedriver session: invalid argument: cannot parse capability: chromeOptions
[Chromedriver] from invalid argument: unrecognized chrome option: androidDeviceSerial
[Chromedriver] (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.18363 x86_64)
[WD Proxy] Matched ‘/session’ to command name ‘createSession’
[WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {“desiredCapabilities”:{“chromeOptions”:{“androidUseRunningApp”:true,“androidDeviceSerial”:“127.0.0.1:62001”},“loggingPrefs”:{“browser”:“ALL”}}}
[WD Proxy] Got response with status 200: {“sessionId”:“be60525712e11afc77997718055efec0”,“status”:61,“value”:{“message”:“invalid argument: cannot parse capability: chromeOptions\nfrom invalid argument: unrecognized chrome option: androidDeviceSerial\n (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.18363 x86_64)”}}
[WD Proxy] Determined the downstream protocol as ‘MJSONWP’
[WD Proxy] The response has an unknown format
[MJSONWP] Matched JSONWP error code 61 to InvalidArgumentError
[Chromedriver] Failed to start Chromedriver session: invalid argument: cannot parse capability: chromeOptions
[Chromedriver] from invalid argument: unrecognized chrome option: androidDeviceSerial
[Chromedriver] (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.18363 x86_64)
[Chromedriver] Chromedriver exited unexpectedly with code null, signal SIGTERM
[Chromedriver] Changed state to ‘stopped’
[Chromedriver] Error: invalid argument: cannot parse capability: chromeOptions
[Chromedriver] from invalid argument: unrecognized chrome option: androidDeviceSerial
[Chromedriver] (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.18363 x86_64)
[Chromedriver] at Object.wrappedLogger.errorAndThrow (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:79:13)
[Chromedriver] at Chromedriver.errorAndThrow [as start] (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-chromedriver\lib\chromedriver.js:540:11)
[W3C (8c79fbaa)] Encountered internal error running command: Error: invalid argument: cannot parse capability: chromeOptions
[W3C (8c79fbaa)] from invalid argument: unrecognized chrome option: androidDeviceSerial
[W3C (8c79fbaa)] (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.18363 x86_64)
[W3C (8c79fbaa)] at Object.wrappedLogger.errorAndThrow (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:79:13)
[W3C (8c79fbaa)] at Chromedriver.errorAndThrow [as start] (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-chromedriver\lib\chromedriver.js:540:11)
[HTTP] <-- POST /wd/hub/session/8c79fbaa-5be3-4d8c-ab13-931af3ce46c5/context 500 1910 ms - 1127
忘各位大神指教一二!