1.启动Appium客户端运行脚本时时可以正常通过
2.终端输入appium,再运行脚本就报错,麻烦老师帮忙看看
版本信息:
appium: 1.20.2
脚本内容:
from appium import webdriver
desired_caps={}
desired_caps['platformName']='Android'
desired_caps['platformVersion']='6.0'
desired_caps['deviceName']='emulator-5554'
# com.android.settings/com.android.settings.Settings
desired_caps['appPackage']='com.android.settings'
desired_caps['appActivity']='com.android.settings.Settings'
driver=webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
print("启动【设置】应用")
driver.quit()
报错信息:
[Appium] Welcome to Appium v1.20.2
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[debug] [HTTP] Request idempotency key: b82fe51b-7770-408c-a4f7-03110cab62fb
[HTTP] → POST /wd/hub/session
[HTTP] {“capabilities”:{“alwaysMatch”:{“platformName”:“Android”,“appium:platformVersion”:“6.0”,“appium:deviceName”:“emulator-5554”,“appium:appPackage”:“com.android.settings”,“appium:appActivity”:“com.android.settings.Settings”},“firstMatch”:[{}]},“desiredCapabilities”:{“platformName”:“Android”,“platformVersion”:“6.0”,“deviceName”:“emulator-5554”,“appPackage”:“com.android.settings”,“appActivity”:“com.android.settings.Settings”}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{“platformName”:“Android”,“platformVersion”:“6.0”,“deviceName”:“emulator-5554”,“appPackage”:“com.android.settings”,“appActivity”:“com.android.settings.Settings”},null,{“alwaysMatch”:{“platformName”:“Android”,“appium:platformVersion”:“6.0”,“appium:deviceName”:“emulator-5554”,“appium:appPackage”:“com.android.settings”,“appium:appActivity”:“com.android.settings.Settings”},“firstMatch”:[{}]}]
[debug] [BaseDriver] Event ‘newSessionRequested’ logged at 1638185152337 (19:25:52 GMT+0800 (中国标准时间))
[Appium]
[Appium] ======================================================================
[Appium] DEPRECATION WARNING:
[Appium]
[Appium] The ‘automationName’ capability was not provided in the desired
[Appium] capabilities for this Android session
[Appium]
[Appium] Setting ‘automationName=UiAutomator2’ by default and using the
[Appium] UiAutomator2 Driver
[Appium]
[Appium] The next major version of Appium (2.x) will require the
[Appium] ‘automationName’ capability to be set for all sessions on all
[Appium] platforms
[Appium]
[Appium] In previous versions (Appium <= 1.13.x), the default was
[Appium] ‘automationName=UiAutomator1’
[Appium]
[Appium] If you wish to use that automation instead of UiAutomator2, please
[Appium] add ‘automationName=UiAutomator1’ to your desired capabilities
[Appium]
[Appium] For more information about drivers, please visit
[Appium] http://appium.io/docs/en/about-appium/intro/ and explore the
[Appium] ‘Drivers’ menu
[Appium]
[Appium] ======================================================================
[Appium]
[Appium] Appium v1.20.2 creating new AndroidUiautomator2Driver (v1.61.2) session
[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {
[debug] [BaseDriver] “alwaysMatch”: {
[debug] [BaseDriver] “platformName”: “Android”,
[debug] [BaseDriver] “appium:platformVersion”: “6.0”,
[debug] [BaseDriver] “appium:deviceName”: “emulator-5554”,
[debug] [BaseDriver] “appium:appPackage”: “com.android.settings”,
[debug] [BaseDriver] “appium:appActivity”: “com.android.settings.Settings”
[debug] [BaseDriver] },
[debug] [BaseDriver] “firstMatch”: [
[debug] [BaseDriver] {}
[debug] [BaseDriver] ]
[debug] [BaseDriver] }
[BaseDriver] Session created with session id: 2c1882a2-2c45-4a67-a97b-b792d9b76bc0
[UiAutomator2] Starting ‘com.android.settings’ directly on the device
[ADB] Found 1 ‘build-tools’ folders under ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx’ (newest first):
[ADB] /Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/build-tools/30.0.0-preview
[ADB] Using ‘adb’ from ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 start-server’
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices
[debug] [ADB] Connected devices: [{“udid”:“emulator-5554”,“state”:“device”}]
[AndroidDriver] Looking for a device with Android ‘6.0.0’
[debug] [ADB] Setting device id to emulator-5554
[ADB] Getting device platform version
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.release’
[debug] [ADB] Current device property ‘ro.build.version.release’: 6.0.1
[debug] [ADB] Setting device id to emulator-5554
[AndroidDriver] Using device: emulator-5554
[ADB] Using ‘adb’ from ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 start-server’
[debug] [ADB] Setting device id to emulator-5554
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk’
[debug] [ADB] Current device property ‘ro.build.version.sdk’: 23
[debug] [ADB] Device API level: 23
[AndroidDriver] No app sent in, not parsing package/activity
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 wait-for-device’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell echo ping’
[debug] [AndroidDriver] Pushing settings apk to device…
[debug] [ADB] Getting install status for io.appium.settings
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.settings’
[debug] [ADB] ‘io.appium.settings’ is installed
[debug] [ADB] Getting package info for ‘io.appium.settings’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.settings’
[debug] [ADB] The version name of the installed ‘io.appium.settings’ is greater or equal to the application version name (‘3.2.1’ >= ‘3.2.1’)
[debug] [ADB] There is no need to install/upgrade ‘/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk’
[debug] [ADB] Getting IDs of all ‘io.appium.settings’ processes
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell ‘pgrep --help; echo $?’’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’
[debug] [AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[debug] [Logcat] Starting logs capture with command: /Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 logcat -v threadtime
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to local port 8200
[debug] [ADB] Forwarding system: 8200 to device: 6790
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 forward tcp:8200 tcp:6790’
[UiAutomator2] Server package at ‘/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.17.4.apk’ is not writeable. Will copy it into the temporary location at ‘/var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211029-21272-13ppkt0.73l8’ as a workaround. Consider making this file writeable manually in order to improve the performance of session startup.
[UiAutomator2] Server package at ‘/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk’ is not writeable. Will copy it into the temporary location at ‘/var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211029-21272-13ppkt0.73l8’ as a workaround. Consider making this file writeable manually in order to improve the performance of session startup.
[debug] [ADB] Getting install status for io.appium.uiautomator2.server
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.uiautomator2.server’
[debug] [ADB] ‘io.appium.uiautomator2.server’ is installed
[debug] [ADB] Getting package info for ‘io.appium.uiautomator2.server’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.uiautomator2.server’
[debug] [ADB] The installed ‘io.appium.uiautomator2.server’ package is older than ‘/var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211029-21272-13ppkt0.73l8/appium-uiautomator2-server-v4.17.4.apk’ (41 < 79 or ‘4.3.0’ < ‘4.17.4’)’
[debug] [UiAutomator2] io.appium.uiautomator2.server installation state: olderVersionInstalled
[debug] [ADB] Checking app cert for /var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211029-21272-13ppkt0.73l8/appium-uiautomator2-server-v4.17.4.apk
[ADB] Using ‘apksigner.jar’ from ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/build-tools/30.0.0-preview/lib/apksigner.jar’
[debug] [ADB] Starting apksigner: ‘/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java’ -Xmx1024M -Xss1m -jar /Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/build-tools/30.0.0-preview/lib/apksigner.jar verify --print-certs /var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211029-21272-13ppkt0.73l8/appium-uiautomator2-server-v4.17.4.apk
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[debug] [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
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop com.android.settings’
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 forward --remove tcp:8200’
[debug] [BaseDriver] Event ‘newSessionStarted’ logged at 1638185153550 (19:25:53 GMT+0800 (中国标准时间))
[debug] [W3C] Encountered internal error running command: Error: Cannot verify the signature of ‘/var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211029-21272-13ppkt0.73l8/appium-uiautomator2-server-v4.17.4.apk’. Original error: Error: A JNI error has occurred, please check your installation and try again
[debug] [W3C] Exception in thread “main” java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
[debug] [W3C] at java.lang.ClassLoader.defineClass1(Native Method)
[debug] [W3C] at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
[debug] [W3C] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
[debug] [W3C] at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
[debug] [W3C] at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
[debug] [W3C] at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
[debug] [W3C] at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
[debug] [W3C] at java.security.AccessController.doPrivileged(Native Method)
[debug] [W3C] at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
[debug] [W3C] at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
[debug] [W3C] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
[debug] [W3C] at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
[debug] [W3C] at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
[debug] [W3C]
[debug] [W3C] at ADB.checkApkCert (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/tools/apk-signing.js:270:11)
[debug] [W3C] at UiAutomator2Server.installServerApk (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/uiautomator2.js:111:13)
[debug] [W3C] at AndroidUiautomator2Driver.initUiAutomator2Server (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:485:7)
[debug] [W3C] at AndroidUiautomator2Driver.startUiAutomator2Session (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:379:5)
[debug] [W3C] at AndroidUiautomator2Driver.createSession (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:224:7)
[debug] [W3C] at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:371:35)
[HTTP] ← POST /wd/hub/session 500 1276 ms - 3227
[HTTP]