尝试开始测试时出现此错误:
“无法初始化检测过程。请确保 被测应用程序不会崩溃并调查logcat 输出”。
from appium import webdriver
desired_caps = {'platformName': 'Android',
'platformVersion': '9',
'automationName': 'uiautomator2',
'deviceName': 'Android',
'udid': '22545b4c16057ece',
'browserName': 'Chrome'}
# 'appActivity': 'com.google.android.apps.chrome.Main',
# 'appPackage': 'com.android.chrome'}
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
答案 0 :(得分:0)
The server is running
[Appium] Welcome to Appium v1.13.0
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"firstMatch":[{"platformName":"Android","appium:platformVersion":"9","appium:automationName":"uiautomator2","appium:deviceName":"Android","appium:udid":"22545b4c16057ece","browserName":"Chrome"}]},"desiredCapabilities":{"platformName":"Android","platformVersion":"9","automationName":"uiautomator2","deviceName":"Android","udid":"22545b4c16057ece","browserName":"Chrome"}}
[W3C] Calling AppiumDriver.createSession() with args: [{"platformName":"Android","platformVersion":"9","automationName":"uiautomator2","deviceName":"Android","udid":"22545b4c16057ece","browserName":"Chrome"},null,{"firstMatch":[{"platformName":"Android","appium:platformVersion":"9","appium:automationName":"uiautomator2","appium:deviceName":"Android","appium:udid":"22545b4c16057ece","browserName":"Chrome"}]}]
[BaseDriver] Event 'newSessionRequested' logged at 1568972998485 (11:49:58 GMT+0200 (Środkowoeuropejski czas letni))
[Appium] Appium v1.13.0 creating new AndroidUiautomator2Driver (v1.33.1) session
[Appium] Capabilities:
[Appium] platformName: Android
[Appium] browserName: Chrome
[Appium] platformVersion: 9
[Appium] automationName: uiautomator2
[Appium] deviceName: Android
[Appium] udid: 22545b4c16057ece
[BaseDriver] W3C capabilities {"alwaysMatch":{"platformNa... and MJSONWP desired capabilities {"platformName":"Android","... were provided
[BaseDriver] Creating session with W3C capabilities: {"alwaysMatch":{"platformNa...
[BaseDriver] Session created with session id: 13c13949-9ce9-4f8c-8143-540cf367ac36
[UiAutomator2] We're going to run a Chrome-based session
[UiAutomator2] Chrome-type package and activity are com.android.chrome and com.google.android.apps.chrome.Main
[ADB] Using 'adb.exe' from 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\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: 22545b4c16057ece
[ADB] Using 'adb.exe' from 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe'
[ADB] Setting device id to 22545b4c16057ece
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell getprop ro.build.version.sdk'
[ADB] Current device property 'ro.build.version.sdk': 28
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 9
[ADB] Device API level: 28
[UiAutomator2] Relaxing hidden api policy
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell settings put global hidden_api_policy_pre_p_apps 1'
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell settings put global hidden_api_policy_p_apps 1'
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell settings put global hidden_api_policy 1'
[AndroidDriver] No app sent in, not parsing package/activity
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece wait-for-device'
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell echo ping'
[AndroidDriver] Pushing settings apk to device...
[ADB] Getting install status for io.appium.settings
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell dumpsys package io.appium.settings'
[ADB] 'io.appium.settings' is installed
[ADB] Getting package info for 'io.appium.settings'
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell dumpsys package io.appium.settings'
[ADB] Using 'aapt.exe' from 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\build-tools\29.0.2\aapt.exe'
[ADB] The version code of the installed 'io.appium.settings' is greater than the application version code (18 > 17)
[ADB] There is no need to install/upgrade 'C:\Users\MarcinPilzak\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk'
[ADB] Getting IDs of all 'io.appium.settings' processes
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell 'pgrep --help; echo $?''
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell pgrep -f io\\.appium\\.settings'
[AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell appops set io.appium.settings android\:mock_location allow'
[Logcat] Starting logcat capture
[ADB] Getting install status for io.appium.uiautomator2.server
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell dumpsys package io.appium.uiautomator2.server'
[ADB] 'io.appium.uiautomator2.server' is installed
[ADB] Getting package info for 'io.appium.uiautomator2.server'
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell dumpsys package io.appium.uiautomator2.server'
[ADB] The version name of the installed 'io.appium.uiautomator2.server' is greater or equal to the application version name ('3.5.1' >= '3.5.1')
[UiAutomator2] io.appium.uiautomator2.server installation state: sameVersionInstalled
[ADB] Checking app cert for C:\Users\MarcinPilzak\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v3.5.1.apk
[ADB] Using 'apksigner.bat' from 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\build-tools\29.0.2\apksigner.bat'
[ADB] Starting 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\build-tools\29.0.2\apksigner.bat' with args '["verify","--print-certs","C:\\Users\\MarcinPilzak\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-v3.5.1.apk"]'
[ADB] apksigner stdout:
[ADB] ERROR: No suitable Java found. In order to properly use the Android Developer
[ADB] Tools, you need a suitable version of Java JDK installed on your system.
[ADB] We recommend that you install the JDK version of JavaSE, available here:
[ADB] http://www.oracle.com/technetwork/java/javase/downloads
[ADB]
[ADB] If you already have Java installed, you can define the JAVA_HOME environment
[ADB] variable in Control Panel / System / Avanced System Settings to point to the
[ADB] JDK folder.
[ADB]
[ADB] You can find the complete Android SDK requirements here:
[ADB] http://developer.android.com/sdk/requirements.html
[ADB]
[ADB]
[ADB] 'C:\Users\MarcinPilzak\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v3.5.1.apk' is signed with non-default certificate
[ADB] Using 'zipalign.exe' from 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\build-tools\29.0.2\zipalign.exe'
[ADB] C:\Users\MarcinPilzak\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v3.5.1.apk' is already zip-aligned. Doing nothing
[ADB] Signing 'C:\Users\MarcinPilzak\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v3.5.1.apk' with default cert
[ADB] Starting 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\build-tools\29.0.2\apksigner.bat' with args '["sign","--key","C:\\Users\\MarcinPilzak\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-adb\\keys\\testkey.pk8","--cert","C:\\Users\\MarcinPilzak\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-adb\\keys\\testkey.x509.pem","C:\\Users\\MarcinPilzak\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-v3.5.1.apk"]'
[ADB] apksigner stdout:
[ADB] ERROR: No suitable Java found. In order to properly use the Android Developer
[ADB] Tools, you need a suitable version of Java JDK installed on your system.
[ADB] We recommend that you install the JDK version of JavaSE, available here:
[ADB] http://www.oracle.com/technetwork/java/javase/downloads
[ADB]
[ADB] If you already have Java installed, you can define the JAVA_HOME environment
[ADB] variable in Control Panel / System / Avanced System Settings to point to the
[ADB] JDK folder.
[ADB]
[ADB] You can find the complete Android SDK requirements here:
[ADB] http://developer.android.com/sdk/requirements.html
[ADB]
[ADB]
[ADB] Getting install status for io.appium.uiautomator2.server.test
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell dumpsys package io.appium.uiautomator2.server.test'
[ADB] 'io.appium.uiautomator2.server.test' is installed
[ADB] Checking app cert for C:\Users\MarcinPilzak\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk
[ADB] Starting 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\build-tools\29.0.2\apksigner.bat' with args '["verify","--print-certs","C:\\Users\\MarcinPilzak\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-debug-androidTest.apk"]'
[ADB] apksigner stdout:
[ADB] ERROR: No suitable Java found. In order to properly use the Android Developer
[ADB] Tools, you need a suitable version of Java JDK installed on your system.
[ADB] We recommend that you install the JDK version of JavaSE, available here:
[ADB] http://www.oracle.com/technetwork/java/javase/downloads
[ADB]
[ADB] If you already have Java installed, you can define the JAVA_HOME environment
[ADB] variable in Control Panel / System / Avanced System Settings to point to the
[ADB] JDK folder.
[ADB]
[ADB] You can find the complete Android SDK requirements here:
[ADB] http://developer.android.com/sdk/requirements.html
[ADB]
[ADB]
[ADB] 'C:\Users\MarcinPilzak\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk' is signed with non-default certificate
[ADB] C:\Users\MarcinPilzak\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk' is already zip-aligned. Doing nothing
[ADB] Signing 'C:\Users\MarcinPilzak\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk' with default cert
[ADB] Starting 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\build-tools\29.0.2\apksigner.bat' with args '["sign","--key","C:\\Users\\MarcinPilzak\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-adb\\keys\\testkey.pk8","--cert","C:\\Users\\MarcinPilzak\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-adb\\keys\\testkey.x509.pem","C:\\Users\\MarcinPilzak\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-debug-androidTest.apk"]'
[ADB] apksigner stdout:
[ADB] ERROR: No suitable Java found. In order to properly use the Android Developer
[ADB] Tools, you need a suitable version of Java JDK installed on your system.
[ADB] We recommend that you install the JDK version of JavaSE, available here:
[ADB] http://www.oracle.com/technetwork/java/javase/downloads
[ADB]
[ADB] If you already have Java installed, you can define the JAVA_HOME environment
[ADB] variable in Control Panel / System / Avanced System Settings to point to the
[ADB] JDK folder.
[ADB]
[ADB] You can find the complete Android SDK requirements here:
[ADB] http://developer.android.com/sdk/requirements.html
[ADB]
[ADB]
[UiAutomator2] Server packages are going to be (re)installed
[UiAutomator2] Full packages reinstall is going to be performed
[ADB] Uninstalling io.appium.uiautomator2.server
[ADB] Getting install status for io.appium.uiautomator2.server
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell dumpsys package io.appium.uiautomator2.server'
[ADB] 'io.appium.uiautomator2.server' is installed
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell am force-stop io.appium.uiautomator2.server'
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece uninstall io.appium.uiautomator2.server'
[ADB] 'adb uninstall io.appium.uiautomator2.server' command output: Success
[ADB] io.appium.uiautomator2.server was successfully uninstalled
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell 'ls -t -1 /data/local/tmp/appium_cache 2>&1 || echo _ERROR_''
[ADB] The count of applications in the cache: 7
[ADB] The application at 'C:\Users\MarcinPilzak\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v3.5.1.apk' is already cached to '/data/local/tmp/appium_cache/56abf1bf10f6562619a2dd8fb060718e27c4cb28.apk'
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell pm install /data/local/tmp/appium_cache/56abf1bf10f6562619a2dd8fb060718e27c4cb28.apk'
[UiAutomator2] Deleting UiAutomator2 session
[UiAutomator2] Deleting UiAutomator2 server session
[WD Proxy] Matched '/' to command name 'deleteSession'
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Trying to proxy a session command without session id
[Logcat] Stopping logcat capture
[ADB] Removing forwarded port socket connection: 8200
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece forward --remove tcp\:8200'
[UiAutomator2] Unable to remove port forward 'Error executing adbExec. Original error: 'Command 'C\:\\Users\\MarcinPilzak\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s 22545b4c16057ece forward --remove tcp\:8200' exited with code 1'; Stderr: 'adb.exe: error: listener 'tcp:8200' not found'; Code: '1''
[UiAutomator2] Restoring hidden api policy to the device default configuration
[ADB] Running 'C:\Users\MarcinPilzak\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 22545b4c16057ece shell settings delete global hidden_api_policy_pre_p_apps'
[BaseDriver] Event 'newSessionStarted' logged at 1568973003084 (11:50:03 GMT+0200 (Środkowoeuropejski czas letni))
[W3C] Encountered internal error running command: Error executing adbExec. Original error: 'Command 'C\:\\Users\\MarcinPilzak\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s 22545b4c16057ece shell settings delete global hidden_api_policy_pre_p_apps' exited with code 20'; Stderr: 'cmd: Can't find service: settings'; Code: '20'
[W3C] Error: Command 'C\:\\Users\\MarcinPilzak\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s 22545b4c16057ece shell settings delete global hidden_api_policy_pre_p_apps' exited with code 20
[W3C] at ChildProcess.proc.on.code (C:\Users\MarcinPilzak\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\teen_process\lib\exec.js:94:19)
[W3C] at ChildProcess.emit (events.js:182:13)
[W3C] at maybeClose (internal/child_process.js:961:16)
[W3C] at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
[HTTP] <-- POST /wd/hub/session 500 4600 ms - 1320
[HTTP]