appium 在 mix2 安卓 8.0 上跑报错 org.openqa.selenium.remote.UnreachableBrowserException Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

log:

The server is running
[Appium] Welcome to Appium v1.9.1
[Appium] Non-default server args:
[Appium] address: 127.0.0.1
[Appium] Appium REST http interface listener started on 127.0.0.1:4723
[HTTP] --> POST /wd/hub/session
[HTTP] {"desiredCapabilities":{"appPackage":"com.intsig.camscanner","appActivity":".MainMenuActivity","noReset":true,"newCommandTimeout":60,"automationName":"uiautomator2","platformName":"Android","deviceName":"Redmi Note4x","version":"8.0 ","platform":"WINDOWS"}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"appPackage":"com.intsig.camscanner","appActivity":".MainMenuActivity","noReset":true,"newCommandTimeout":60,"automationName":"uiautomator2","platformName":"Android","deviceName":"Redmi Note4x","version":"8.0 ","platform":"WINDOWS"},null,null]
[BaseDriver] Event 'newSessionRequested' logged at 1540484007152 (00:13:27 GMT+0800 (中国标准时间))
[Appium] Creating new AndroidUiautomator2Driver (v1.19.0) session
[Appium] Capabilities:
[Appium] appPackage: com.intsig.camscanner
[Appium] appActivity: .MainMenuActivity
[Appium] noReset: true
[Appium] newCommandTimeout: 60
[Appium] automationName: uiautomator2
[Appium] platformName: Android
[Appium] deviceName: Redmi Note4x
[Appium] version: 8.0
[Appium] platform: WINDOWS
[BaseDriver] Creating session with MJSONWP desired capabilities: {"appPackage":"com.intsig.c...
[BaseDriver] The following capabilities were provided, but are not recognized by appium: version, platform.
[BaseDriver] Session created with session id: e9d2212b-1513-4b72-b56f-453d744f9f54
[AndroidDriver] Java version is: 1.8.0_101
[ADB] Checking whether adb is present
[ADB] Found 4 'build-tools' folders under 'D:\android-sdk-windows' (newest first):
[ADB] D:/android-sdk-windows/build-tools/28.0.0
[ADB] D:/android-sdk-windows/build-tools/21.1.2
[ADB] D:/android-sdk-windows/build-tools/20.0.0
[ADB] D:/android-sdk-windows/build-tools/19.1.0
[ADB] Using adb.exe from D:\android-sdk-windows\platform-tools\adb.exe
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[AndroidDriver] Using device: fd7caecd
[ADB] Setting device id to fd7caecd
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell getprop ro.build.version.sdk'
[ADB] Current device property 'ro.build.version.sdk': 26
[ADB] Device API level: 26
[AndroidDriver] No app sent in, not parsing package/activity
[ADB] Getting device platform version
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 8.0.0
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell wm size'
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell wm density'
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell getprop ro.product.model'
[ADB] Current device property 'ro.product.model': MIX 2
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell getprop ro.product.manufacturer'
[ADB] Current device property 'ro.product.manufacturer': Xiaomi
[ADB] Device API level: 26
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell am force-stop io.appium.uiautomator2.server'
[ADB] Checking app cert for C:\Users\test\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.18.0.apk
[ADB] Using apksigner.bat from D:\android-sdk-windows\build-tools\28.0.0\apksigner.bat
[ADB] Starting 'D:\android-sdk-windows\build-tools\28.0.0\apksigner.bat' with args '["verify","--print-certs","C:\Users\test\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.18.0.apk"]'
[ADB] apksigner stdout: Signer #1 certificate DN: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[ADB] Signer #1 certificate SHA-256 digest: a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc
[ADB] Signer #1 certificate SHA-1 digest: 61ed377e85d386a8dfee6b864bd85b0bfaa5af81
[ADB] Signer #1 certificate MD5 digest: e89b158e4bcf988ebd09eb83f5378e87
[ADB] WARNING: META-INF/INDEX.LIST not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
[ADB] WARNING: META-INF/io.netty.versions.properties not protected by signature. Unauthorized modifications to this JAR entry will not be detected. Delete or move the entry outside of META-INF/.
[ADB]
[ADB] 'C:\Users\test\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.18.0.apk' is already signed.
[ADB] Checking app cert for C:\Users\test\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk
[ADB] Starting 'D:\android-sdk-windows\build-tools\28.0.0\apksigner.bat' with args '["verify","--print-certs","C:\Users\test\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk"]'
[ADB] apksigner stdout: Signer #1 certificate DN: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[ADB] Signer #1 certificate SHA-256 digest: a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc
[ADB] Signer #1 certificate SHA-1 digest: 61ed377e85d386a8dfee6b864bd85b0bfaa5af81
[ADB] Signer #1 certificate MD5 digest: e89b158e4bcf988ebd09eb83f5378e87
[ADB]
[ADB] 'C:\Users\test\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk' is already signed.
[ADB] Getting install status for io.appium.uiautomator2.server
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell pm list packages io.appium.uiautomator2.server'
[ADB] App is installed
[ADB] Getting package info for 'io.appium.uiautomator2.server'
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell dumpsys package io.appium.uiautomator2.server'
[ADB] Checking whether aapt is present
[ADB] Using aapt.exe from D:\android-sdk-windows\build-tools\28.0.0\aapt.exe
[ADB] The installed 'io.appium.uiautomator2.server' package does not require upgrade ('1.18.0' >= '1.18.0')
[ADB] Getting install status for io.appium.uiautomator2.server.test
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell pm list packages io.appium.uiautomator2.server.test'
[ADB] App is installed
[ADB] Getting package info for 'io.appium.uiautomator2.server.test'
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell dumpsys package io.appium.uiautomator2.server.test'
[ADB] Cannot read version codes of 'C:\Users\test\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk' and/or 'io.appium.uiautomator2.server.test'
[ADB] Cannot read version names of 'C:\Users\test\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk' and/or 'io.appium.uiautomator2.server.test'. Assuming correct app version is already installed
[UiAutomator2] Waiting up to 20000ms for instrumentation 'io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner' to be available
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell pm list instrumentation'
[UiAutomator2] Instrumentation 'io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner' available
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd wait-for-device'
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell echo ping'
[AndroidDriver] Pushing settings apk to device...
[ADB] Getting install status for io.appium.settings
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell pm list packages io.appium.settings'
[ADB] App is installed
[ADB] Getting package info for 'io.appium.settings'
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell dumpsys package io.appium.settings'
[ADB] The installed 'io.appium.settings' package does not require upgrade ('2.3.0' >= '2.3.0')
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell ps'
[AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[ADB] Device API level: 26
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell appops set io.appium.settings android:mock_location allow'
[AndroidDriver] setDeviceLanguageCountry requires language or country.
[AndroidDriver] Got language: 'undefined' and country: 'undefined'
[Logcat] Starting logcat capture
[AndroidDriver] Pushing unlock helper app to device...
[ADB] Getting install status for io.appium.unlock
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell pm list packages io.appium.unlock'
[ADB] App is installed
[ADB] Getting package info for 'io.appium.unlock'
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell dumpsys package io.appium.unlock'
[ADB] The installed 'io.appium.unlock' package does not require upgrade ('2.0.0' >= '2.0.0')
[UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8200
[ADB] Forwarding system: 8200 to device: 6790
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd forward tcp:8200 tcp:6790'
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell rm -rf /data/local/tmp/strings.json'
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell pm path com.intsig.camscanner'
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd pull /data/app/com.intsig.camscanner-fO8hllZmEWt9LJT7ccTcaQ==/base.apk C:\Users\test\AppData\Local\Temp\com.intsig.camscanner.apk'
[ADB] Pulled app for package 'com.intsig.camscanner' to 'C:\Users\test\AppData\Local\Temp\com.intsig.camscanner.apk'
[AndroidDriver] Extracting strings from apk
[AndroidDriver] C:\Users\test\AppData\Local\Temp\com.intsig.camscanner.apk
[AndroidDriver] undefined
[AndroidDriver] C:\Users\test\AppData\Local\Temp\com.intsig.camscanner
[ADB] Extracting strings for language: default
[ADB] Successfully extracted 1942 strings from 'C:\Users\test\AppData\Local\Temp\com.intsig.camscanner.apk' resources for '(default)' configuration
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd push C:\Users\test\AppData\Local\Temp\com.intsig.camscanner\strings.json /data/local/tmp'
[UiAutomator2] No app capability. Assuming it is already on the device
[ADB] Checking app cert for undefined
[ADB] 'undefined' doesn't exist
[ADB] Getting all processes with uiautomator
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell ps'
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell am force-stop io.appium.uiautomator2.server'
[UiAutomator2] Starting uiautomator2 server 1.18.0
[UiAutomator2] Using UIAutomator2 server from 'C:\Users\test\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v1.18.0.apk' and test from 'C:\Users\test\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk'
[UiAutomator2] Running command: 'adb -s fd7caecd shell am instrument -w io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner'
[UiAutomator2] Waiting up to 20000ms for UiAutomator2 to be online...
[JSONWP Proxy] Matched '/status' to command name 'getStatus'
[JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[JSONWP Proxy] Matched '/status' to command name 'getStatus'
[JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[JSONWP Proxy] Matched '/status' to command name 'getStatus'
[JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[JSONWP Proxy] Matched '/status' to command name 'getStatus'
[JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"SESSIONID\",\"status\":0,\"value\":\"Status Invoked\"}"
[JSONWP Proxy] Matched '/session' to command name 'createSession'
[JSONWP Proxy] Proxying [POST /session] to [POST http://localhost:8200/wd/hub/session] with body: {"desiredCapabilities":{"platform":"WINDOWS","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appPackage":"com.intsig.camscanner","appActivity":".MainMenuActivity","noReset":true,"newCommandTimeout":60,"automationName":"uiautomator2","platformName":"Android","deviceName":"Redmi Note4x","version":"8.0 ","platform":"WINDOWS"},"appPackage":"com.intsig.camscanner","appActivity":".MainMenuActivity","noReset":true,"newCommandTimeout":60,"automationName":"uiautomator2","platformName":"Android","deviceName":"fd7caecd","version":"8.0 ","deviceUDID":"fd7caecd","platformVersion":"8.0.0","deviceScreenSize":"1080x2160","deviceScreenDensity":480,"deviceModel":"MIX 2","deviceManufacturer":"Xiaomi","deviceApiLevel":26}}
[JSONWP Proxy] Got response with status 200: {"sessionId":"84a9dc86-dc4d-4f93-9e6a-a4082eef7c81","status":0,"value":"Created Session"}
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell dumpsys window'
[AndroidDriver] Screen already unlocked, doing nothing
[UiAutomator2] UiAutomator2 did not start the activity we were waiting for, 'com.intsig.camscanner/.MainMenuActivity'. Starting it ourselves
[ADB] Device API level: 26
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell am start -W -n com.intsig.camscanner/.MainMenuActivity -S'
[JSONWP Proxy] Proxying [GET /appium/device/pixel_ratio] to [GET http://localhost:8200/wd/hub/session/84a9dc86-dc4d-4f93-9e6a-a4082eef7c81/appium/device/pixel_ratio] with body: {}
[JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"84a9dc86-dc4d-4f93-9e6a-a4082eef7c81\",\"status\":0,\"value\":2.75}"
[JSONWP Proxy] Matched '/appium/device/system_bars' to command name 'getSystemBars'
[JSONWP Proxy] Proxying [GET /appium/device/system_bars] to [GET http://localhost:8200/wd/hub/session/84a9dc86-dc4d-4f93-9e6a-a4082eef7c81/appium/device/system_bars] with body: {}
[JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"84a9dc86-dc4d-4f93-9e6a-a4082eef7c81\",\"status\":0,\"value\":{\"statusBar\":66}}"
[JSONWP Proxy] Matched '/window/current/size' to command name 'getWindowSize'
[JSONWP Proxy] Proxying [GET /window/current/size] to [GET http://localhost:8200/wd/hub/session/84a9dc86-dc4d-4f93-9e6a-a4082eef7c81/window/current/size] with body: {}
[JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"84a9dc86-dc4d-4f93-9e6a-a4082eef7c81\",\"status\":0,\"value\":{\"height\":2030,\"width\":1080}}"
[Appium] New AndroidUiautomator2Driver session created successfully, session e9d2212b-1513-4b72-b56f-453d744f9f54 added to master session list
[BaseDriver] Event 'newSessionStarted' logged at 1540484028869 (00:13:48 GMT+0800 (中国标准时间))
[MJSONWP] Cached the protocol value 'MJSONWP' for the new session e9d2212b-1513-4b72-b56f-453d744f9f54
[MJSONWP] Responding to client with driver.createSession() result: {"platform":"WINDOWS","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appPackage":"com.intsig.camscanner","appActivity":".MainMenuActivity","noReset":true,"newCommandTimeout":60,"automationName":"uiautomator2","platformName":"Android","deviceName":"Redmi Note4x","version":"8.0 ","platform":"WINDOWS"},"appPackage":"com.intsig.camscanner","appActivity":".MainMenuActivity","noReset":true,"newCommandTimeout":60,"automationName":"uiautomator2","platformName":"Android","deviceName":"fd7caecd","version":"8.0 ","deviceUDID":"fd7caecd","platformVersion":"8.0.0","deviceScreenSize":"1080x2160","deviceScreenDensity":480,"deviceModel":"MIX 2","deviceManufacturer":"Xiaomi","deviceApiLevel":26,"pixelRatio":2.75,"statBarHeight":66,"viewportRect":{"left":0,"top":66,"width":1080,"height":1964}}
[HTTP] <-- POST /wd/hub/session 200 21725 ms - 998
[HTTP]
[BaseDriver] Shutting down because we waited 60 seconds for a command
[UiAutomator2] Deleting UiAutomator2 session
[UiAutomator2] Deleting UiAutomator2 server session
[JSONWP Proxy] Matched '/' to command name 'deleteSession'
[JSONWP Proxy] Proxying [DELETE /] to [DELETE http://localhost:8200/wd/hub/session/84a9dc86-dc4d-4f93-9e6a-a4082eef7c81] with no body
[Appium] Closing session, cause was 'New Command Timeout of 60 seconds expired. Try customizing the timeout using the 'newCommandTimeout' desired capability'
[Appium] Removing session e9d2212b-1513-4b72-b56f-453d744f9f54 from our master session list
[JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"84a9dc86-dc4d-4f93-9e6a-a4082eef7c81\",\"status\":0,\"value\":\"Session deleted\"}"
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd shell am force-stop com.intsig.camscanner'
[Logcat] Stopping logcat capture
[ADB] Removing forwarded port socket connection: 8200
[ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe -P 5037 -s fd7caecd forward --remove tcp:8200'
[UiAutomator2] [UIAutomator2] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:.
[UiAutomator2] [UIAutomator2] Time: 64.158
[UiAutomator2] [UIAutomator2] OK (1 test)


↙↙↙阅读原文可查看相关链接,并与作者交流