目录:
一、电脑存在appium命令版以及appium-desktop版本
二、华为手机手动卸载appium settings和uiautomator2软件后,再次运行脚本报错
三、IOS手机元素定位
四、滑动页面查找到指定的元素并点击
五、利用self.driver.start_activity方法调用app时appium报错:<-- POST /wd/hub/session/545435435-b6fc-400b-b4e0-54554/appium/device/start_activity 500
一、电脑存在appium命令版以及appium-desktop版本
开启appium-desktop版本后执行脚本报错:
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Cannot start the ‘com.xxxx’ application.
主要意思:处理命令时发生未知服务器端错误
检查:
我这边查看到命令行版本(1.20.2)与桌面版本(1.14.1)不一致,appium -v,查看版本
解决方法:
关闭桌面版本,cmd中输入appium执行命令行版本,执行脚本,可成功运行
解决2:升级桌面appium版本或者降低appium命令行版本
二、华为手机手动卸载appium settings和uiautomator2软件后,再次运行脚本报错
报错内容:
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
原因:手动卸载软件没有卸载干净,无法继续安装程序
解决:adb命令卸载,卸载两个软件:
adb uninstall io.appium.settings
adb uninstall io.appium.uiautomator2.server
三、IOS手机元素定位
注意当visible为false时,表示元素不可见,定位时可能会定位不到,一般当visible为false不建议使用这个元素来做操作
四、滑动页面查找到指定的元素并点击
i = 1
while i < 6:
try:
driver.find_element_by_accessibility_id("Summer Dress >").click() # 尝试点击元素
break
except Exception as e:
#longPress()多了一个入参duration,因为需要长按,所以须有一个按的时间。它以毫秒为单位。1000表示按一秒钟。
TouchAction(driver).long_press(x=194, y=728, duration=1000).move_to(x=193, y=300).release().perform() # 长按滑动屏幕
i = i + 1
五、Android启动指定activity时报错 <-- POST /wd/hub/session/545435435-b6fc-400b-b4e0-54554/appium/device/start_activity 500
原因:发现appium桌面版本为1.12.1,命令行版本为1.20.2,估计低版本不支持self.driver.start_activity()方法
解决方法:升级桌面版本,,或者利用高版本的命令行来启动