欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【已解决】【Appium】请教大神,Appium配置正常,但是运行脚本异常停止,提示[UiAutomator] Moving to state 'stopped'

程序员文章站 2022-07-12 21:03:01
...

【已解决】

Appium默认的UiAutomator支持API 17以上,也就是Android 4.1以上,所以重新配置AVD就好了

如果需要使用Android4.1以下版本,需要搭建配置selendroid


------------------------------分割线-------------------------------------------------------------------


Appium已经正常配置

【已解决】【Appium】请教大神,Appium配置正常,但是运行脚本异常停止,提示[UiAutomator] Moving to state 'stopped'


正常开启AVD


开启Appium服务

【已解决】【Appium】请教大神,Appium配置正常,但是运行脚本异常停止,提示[UiAutomator] Moving to state 'stopped'


运行脚本(脚本中的Android配置与PC上的模拟器一致)

#coding=utf-8
from appium import webdriver

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '2.3.3'
desired_caps['deviceName'] = 'emulator-5554'
desired_caps['appPackage'] = 'com.android.calculator2'
desired_caps['appActivity'] = .Calculator'

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
driver.find_element_by_name("1").click()
driver.find_element_by_name("5").click()
driver.find_element_by_name("9").click()
driver.find_element_by_name("delete").click()
driver.find_element_by_name("9").click()
driver.find_element_by_name("5").click()
driver.find_element_by_name("+").click()
driver.find_element_by_name("6").click()
driver.find_element_by_name("=").click()
driver.quit()

然后Appium窗口显示log结尾如下后就停止不动了:

【已解决】【Appium】请教大神,Appium配置正常,但是运行脚本异常停止,提示[UiAutomator] Moving to state 'stopped'


全部log如下:

C:\Users\Administrator>appium
[Appium] Welcome to Appium v1.6.5
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"capabilities":{"firstMatch":[{}],"alwaysMatch"
:{"platformName":"Android"}},"desiredCapabilities":{"platformName":"Android","pl
atformVersion":"2.3.3","deviceName":"emulator-5554","appPackage":"com.android.ca
lculator2","appActivity":"com.android.calculator2.Calculator"}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"platformNam
e":"Android","platformVersion":"2.3.3","deviceName":"emulator-5554","appPackage"
:"com.android.calculator2","appActivity":"com.android.calculator2.Calculator"},n
ull,{"firstMatch":[{}],"alwaysMatch":{"platformName":"Android"}}]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1505719363333 (15:22:
43 GMT+0800 (中国标准时间))
[Appium] Creating new AndroidDriver (v1.20.0) session
[Appium] Capabilities:
[Appium]   platformName: 'Android'
[Appium]   platformVersion: '2.3.3'
[Appium]   deviceName: 'emulator-5554'
[Appium]   appPackage: 'com.android.calculator2'
[Appium]   appActivity: 'com.android.calculator2.Calculator'
[debug] [AndroidDriver] AndroidDriver version: 1.20.0
[BaseDriver] Session created with session id: eb7f6dab-bf89-4901-8341-c32f369204
ad
[debug] [AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_91
[ADB] Checking whether adb is present
[ADB] Using adb.exe from D:\android-sdk-windows\platform-tools\adb.exe
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[AndroidDriver] Looking for a device with Android '2.3.3'
[debug] [ADB] Setting device id to emulator-5554
[ADB] Getting device platform version
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","getprop","ro.build.version.release"]
[AndroidDriver] Using device: emulator-5554
[ADB] Checking whether adb is present
[ADB] Using adb.exe from D:\android-sdk-windows\platform-tools\adb.exe
[debug] [ADB] Setting device id to emulator-5554
[AndroidDriver] App file was not listed, instead we're going to run com.android.
calculator2 directly on the device
[debug] [AndroidDriver] Checking whether package is present on the device
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","pm","list","packages","com.android.cal
culator2"]
[AndroidDriver] Starting Android session
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","wait-for-device"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","echo","ping"]
[debug] [Logcat] Starting logcat capture
[debug] [AndroidDriver] Pushing settings apk to device...
[debug] [ADB] Getting install status for io.appium.settings
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","pm","list","packages","io.appium.setti
ngs"]
[debug] [ADB] App is not installed
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","install","C:\\Users\\Administrator\\AppData\\R
oaming\\npm\\node_modules\\appium\\node_modules\\io.appium.settings\\app\\build\
\outputs\\apk\\settings_apk-debug.apk"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","getprop","ro.build.version.sdk"]
[debug] [ADB] Device API level: 10
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","dumpsys","package","io.appium.settings
"]
[debug] [AndroidDriver] Pushing unlock helper app to device...
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","install","C:\\Users\\Administrator\\AppData\\R
oaming\\npm\\node_modules\\appium\\node_modules\\appium-unlock\\bin\\unlock_apk-
debug.apk"]
[debug] [ADB] Device API level: 10
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","settings","put","secure","mock_locatio
n","1"]
[ADB] Getting device platform version
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","getprop","ro.build.version.release"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","wm","size"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","getprop","ro.product.model"]
[debug] [ADB] Current device property 'ro.product.model': sdk
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","getprop","ro.product.manufacturer"]
[debug] [ADB] Current device property 'ro.product.manufacturer': unknown
[AndroidDriver] No app sent in, not parsing package/activity
[debug] [AndroidDriver] No app capability. Assuming it is already on the device
[debug] [AndroidDriver] Running fast reset (stop and clear)
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","am","force-stop","com.android.calculat
or2"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","pm","clear","com.android.calculator2"]

[debug] [AndroidBootstrap] Watching for bootstrap disconnect
[debug] [ADB] Forwarding system: 4724 to device: 4724
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","forward","tcp:4724","tcp:4724"]
[debug] [UiAutomator] Starting UiAutomator
[debug] [UiAutomator] Moving to state 'starting'
[debug] [UiAutomator] Parsing uiautomator jar
[debug] [UiAutomator] Found jar name: 'AppiumBootstrap.jar'
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","push","C:\\Users\\Administrator\\AppData\\Roam
ing\\npm\\node_modules\\appium\\node_modules\\appium-android-bootstrap\\bootstra
p\\bin\\AppiumBootstrap.jar","/data/local/tmp/"]
[debug] [ADB] Attempting to kill all uiautomator processes
[debug] [ADB] Getting all processes with uiautomator
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\android-sdk-windows\platform-tools\adb.exe' with args:
 ["-P",5037,"-s","emulator-5554","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[debug] [UiAutomator] Starting UIAutomator
[debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","emulator-5554"
,"shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.b
ootstrap.Bootstrap","-e","pkg","com.android.calculator2","-e","disableAndroidWat
chers",false,"-e","acceptSslCerts",false]
[UiAutomator] UiAutomator exited unexpectedly with code 0, signal null
[debug] [UiAutomator] Moving to state 'stopped'


求教,这一直停止不动是为何?AVD也没有任何反应?