Appium踩坑总结--解决方法

目录:
一、电脑存在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()方法
解决方法:升级桌面版本,,或者利用高版本的命令行来启动

评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值