😄作者简介: 小曾同学.com,一个致力于测试开发的博主⛽️,主要职责:测试开发、CI/CD
如果文章知识点有错误的地方,还请大家指正,让我们一起学习,一起进步。
😊 座右铭:不想当开发的测试,不是一个好测试✌️。
如果感觉博主的文章还不错的话,还请点赞、收藏哦!👍
如果你在使用Appium中出现以下三个问题,那么这篇文章一定会帮你解决问题。
连接 Appium Server 出现 404 问题
Message: 'automationName' can't be blank
AttributeError: can‘t set attribute
问题一: 连接 Appium Server 出现 404 问题
如果你在运行 Python时出现 raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
找不到请求的资源,或者使用映射资源不支持的HTTP方法接受请求。
这可能是因为你的连接地址出现了问题,解决方法:
# 如果你的Appium Server版本是2.11.3 应该写成
driver = webdriver.Remote('http://127.0.0.1:4723', desired_caps)
不要写成 driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
⚠️ 因为新版本 v2.11.3 要求这样写,如果你的 Appium 版本是 1.21.0,需要将地址写成 http://127.0.0.1:4723/wd/hub形式,这个是 Remote path路径。
问题二: Message: 'automationName' can't be blank
如果运行出现 raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidArgumentException: Message: 'automationName' can't be blank
。一般出现在 Appium Server 新版本中,我用的是v2.11.3 就会出现这个问题,原因是说明代码中缺少automationName 属性。在新版本中需要安装 UiAutomator2。默认情况下是没有的,需要先下载 Appium 插件。
appium driver list
appium driver install uiautomator2
问题三:AttributeError: can‘t set attribute
AttributeError: can‘t set attribute
无法在appium-python中设置属性,如果出现了这个问题,估计需要更新下Appium-Python-Client ,实在不行就直接安装下:
pip3 install Appium-Python-Client
我目前的版本是v1.2.0,解决了该问题。
对于Appium Server新版本可能还需要注意,如果指定端口号运行服务的话,可能和之前的启动参数有点不一样,旧版本是-p参数,而新版本是–rest-port
➜ ~ appium --address 127.0.0.1 --rest-port 4723
appium-inspector 下载地址:appium-inspector