Appium 避坑指南之 解决AttributeError: can‘t set attribute、The requested resource could not be found问题

😄作者简介: 小曾同学.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

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小曾同学.com

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值