appium按照老师的方法最后还是失败了,真机模拟器都不行

pycharm报错如下:
Traceback (most recent call last):
File “C:\Users\amadeusmao\Desktop\python_study\appium_demo.py”, line 13, in
driver=webdriver.Remote(‘http://localhost:4723/wd/hub’,desired_caps)
File “C:\Users\amadeusmao\AppData\Roaming\Python\Python38\site-packages\appium\webdriver\webdriver.py”, line 230, in init
super().init(
File “C:\Users\amadeusmao\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\remote\webdriver.py”, line 286, in init
self.start_session(capabilities, browser_profile)
File “C:\Users\amadeusmao\AppData\Roaming\Python\Python38\site-packages\appium\webdriver\webdriver.py”, line 320, in start_session
response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
File “C:\Users\amadeusmao\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\remote\webdriver.py”, line 440, in execute
self.error_handler.check_response(response)
File “C:\Users\amadeusmao\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\remote\errorhandler.py”, line 245, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Appium Settings app is not running after 5000ms
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: Appium Settings app is not running after 5000ms
at getResponseForW3CError (C:\Users\amadeusmao\AppData\Local\Programs\Appium Server GUI\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:804:9)
at asyncHandler (C:\Users\amadeusmao\AppData\Local\Programs\Appium Server GUI\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:380:37)

appium日志如下:
→ POST /wd/hub/session

[HTTP] {“capabilities”:{“firstMatch”:[{}],“alwaysMatch”:{“platformName”:“Android”,“appium:platformVersion”:“6.0”,“appium:deviceName”:“127.0.0.1:7555”,“appium:appPackage”:“com.android.settings”,“appium:appActivity”:“com.android.settings.Settings”}}}

[W3C] Calling AppiumDriver.createSession() with args: [null,null,{“firstMatch”:[{}],“alwaysMatch”:{“platformName”:“Android”,“appium:platformVersion”:“6.0”,“appium:deviceName”:“127.0.0.1:7555”,“appium:appPackage”:“com.android.settings”,“appium:appActivity”:“com.android.settings.Settings”}}]

[BaseDriver] Event ‘newSessionRequested’ logged at 1677468964489 (11:36:04 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.22.2 creating new AndroidUiautomator2Driver (v1.70.1) session

[Appium] Applying relaxed security to ‘AndroidUiautomator2Driver’ as per server command line argument. All insecure features will be enabled unless explicitly disabled by --deny-insecure

[BaseDriver] Creating session with W3C capabilities: {

[BaseDriver] “alwaysMatch”: {

[BaseDriver] “platformName”: “Android”,

[BaseDriver] “appium:platformVersion”: “6.0”,

[BaseDriver] “appium:deviceName”: “127.0.0.1:7555”,

[BaseDriver] “appium:appPackage”: “com.android.settings”,

[BaseDriver] “appium:appActivity”: “com.android.settings.Settings”

[BaseDriver] },

[BaseDriver] “firstMatch”: [

[BaseDriver] {}

[BaseDriver] ]

[BaseDriver] }

[BaseDriver] Session created with session id: 7af4623a-5045-4745-a0b9-a540157f0e51

[UiAutomator2] Starting ‘com.android.settings’ directly on the device

[ADB] Found 2 ‘build-tools’ folders under ‘D:\appium_package\android-sdk-windows’ (newest first):

[ADB] D:/appium_package/android-sdk-windows/build-tools/33.0.2

[ADB] D:/appium_package/android-sdk-windows/build-tools/30.0.0-preview

[ADB] Using ‘adb.exe’ from ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe’

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 start-server’

[AndroidDriver] Retrieving device list

[ADB] Trying to find a connected android device

[ADB] Getting connected devices

[ADB] Connected devices: [{“udid”:“127.0.0.1:7555”,“state”:“device”}]

[AndroidDriver] Looking for a device with Android ‘6.0.0’

[ADB] Setting device id to 127.0.0.1:7555

[ADB] Getting device platform version

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell getprop ro.build.version.release’

[ADB] Current device property ‘ro.build.version.release’: 6.0.1

[ADB] Setting device id to 127.0.0.1:7555

[AndroidDriver] Using device: 127.0.0.1:7555

[ADB] Using ‘adb.exe’ from ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe’

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 start-server’

[ADB] Setting device id to 127.0.0.1:7555

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell getprop ro.build.version.sdk’

[ADB] Current device property ‘ro.build.version.sdk’: 23

[ADB] Device API level: 23

[AndroidDriver] No app sent in, not parsing package/activity

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 wait-for-device’

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell echo ping’

[AndroidDriver] Pushing settings apk to device…

[ADB] Getting install status for io.appium.settings

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell dumpsys package io.appium.settings’

[ADB] ‘io.appium.settings’ is installed

[ADB] Getting package info for ‘io.appium.settings’

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell dumpsys package io.appium.settings’

[ADB] The version name of the installed ‘io.appium.settings’ is greater or equal to the application version name (‘3.4.0’ >= ‘3.4.0’)

[ADB] There is no need to install/upgrade ‘C:\Users\amadeusmao\AppData\Local\Programs\Appium Server GUI\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 ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell ‘pgrep --help; echo $?’’

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[AndroidDriver] Granting permissions SET_ANIMATION_SCALE,CHANGE_CONFIGURATION,ACCESS_FINE_LOCATION to ‘io.appium.settings’

[ADB] Granting permissions [“android.permission.SET_ANIMATION_SCALE”,“android.permission.CHANGE_CONFIGURATION”,“android.permission.ACCESS_FINE_LOCATION”] to ‘io.appium.settings’

[ADB] Got the following command chunks to execute: [[“pm”,“grant”,“io.appium.settings”,“android.permission.SET_ANIMATION_SCALE”,“;”,“pm”,“grant”,“io.appium.settings”,“android.permission.CHANGE_CONFIGURATION”,“;”,“pm”,“grant”,“io.appium.settings”,“android.permission.ACCESS_FINE_LOCATION”,“;”]]

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pm grant io.appium.settings android.permission.SET_ANIMATION_SCALE ; pm grant io.appium.settings android.permission.CHANGE_CONFIGURATION ; pm grant io.appium.settings android.permission.ACCESS_FINE_LOCATION ;’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Starting Appium Settings app

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell am start -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’

[AndroidDriver] Error: Appium Settings app is not running after 5000ms

[AndroidDriver] at ADB.requireRunningSettingsApp (C:\Users\amadeusmao\AppData\Local\Programs\Appium Server GUI\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\settings-client-commands.js:72:11)

[UiAutomator2] Deleting UiAutomator2 session

[ADB] Running ‘D:\appium_package\android-sdk-windows\platform-tools\adb.exe -P 5037 -s 127.0.0.1:7555 shell am force-stop com.android.settings’

[BaseDriver] Event ‘newSessionStarted’ logged at 1677468971852 (11:36:11 GMT+0800 (中国标准时间))

[W3C] Encountered internal error running command: Error: Appium Settings app is not running after 5000ms

[W3C] at ADB.requireRunningSettingsApp (C:\Users\amadeusmao\AppData\Local\Programs\Appium Server GUI\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\settings-client-commands.js:72:11)

[HTTP] ← POST /wd/hub/session 500 7439 ms - 741

[HTTP]

试试卸载看看

adb uninstall io.appium.settings
adb uninstall io.appium.uiautomator2.server
adb uninstall io.appium.uiautomator2.server.test
adb uninstall io.appium.unlock

恩,应该是版本不对,或者被手机拦截不让启动了,也可以单独启动下这个命令看看什么报错。实在搞不定可以找助教解决下。

adb.exe -P 5037 -s 127.0.0.1:7555 shell am start -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER