Python3+Appium学习笔记05-报错及解决方法

记录一下使用期间各种报错和解决方法,毕竟搜了半天才找到解决方法。另外提示一下。优先看官方文档。

报错前面都是一样,就是说在处理的时候,服务器发生了一个未知的错误。然后才是具体报错信息

1)selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Unknown error

'automationName':'uiautomator2'

添加这行参数

最新的appium desktop 是使用了Uiautomator2驱动的。

2)selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission

这个报错是发生在执行click()方法的时候,提示说没有权限。

解决方法是开发者选项中打开USB模拟点击权限

3)selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session

新版的appium desktop已经不使用name方法来定位元素

4)在执行多个.py文件的测试用例时发现,有一部分用例报错,然后发现这些用例单个执行是没有问题的。但是放在一起执行就会报错。最后发现是quit()和close_app()的区别-。close_app()只是关闭app,而不会把appium实例关闭。会有部分信息还在app里面。quit会把appium实例关闭,每次启动相当于一个刚安装的状态。

5)DeprecationWarning: desired_capabilities argument is deprecated and will be removed in future versions. Use options instead.

driver = webdriver.Remote(self.server_url,self.desired_caps)

提示desired_capabilities这个参数将在之后作废

from appium.options.common import AppiumOptions

option = AppiumOptions()
option.set_capability('platformName', 'android')
driver = webdriver.Remote(self.server_url,options=self.option)

更改成这样即可

6)DeprecationWarning: URLs without a scheme (ie 'https://') are deprecated and will raise an error in a future version of urllib3. To avoid this DeprecationWarning ensure all URLs start with 'https://' or 'http://

server_url = "127.0.0.1:4723/wd/hub"

server_url = "http://localhost:4723/wd/hub"

把地址改成http或https的形式即可。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值