当前位置: 首页 > news >正文

记录使用appium+夜神模拟器测试多设备时selenium和appium版本不兼容带来的问题

记录使用appium+夜神模拟器测试多设备时selenium和appium版本不兼容带来的问题

好不容易解决了selenium和appium的版本冲突问题(导致:AttributeError: ‘NoneType’ object has no attribute 'to_capabilities’异常发生)

第二天运行代码发现出现了连接Appium 服务器被拒绝

http://127.0.0.1:4723/wd/hub
Exception in thread Thread-2 (appim_desired_01):
Traceback (most recent call last):File "E:\anaconda3\Lib\site-packages\urllib3\connection.py", line 174, in _new_connconn = connection.create_connection(^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "E:\anaconda3\Lib\site-packages\urllib3\util\connection.py", line 95, in create_connectionraise errFile "E:\anaconda3\Lib\site-packages\urllib3\util\connection.py", line 85, in create_connectionsock.connect(sa)
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

后来发现Appium 服务器没有启动成功

[ERROR] Unrecognized arguments: -bp 4724

在使用 start 命令启动 Appium 时,如果遇到“Unrecognized arguments: -bp 4724”错误,这可能是因为你使用的 Appium 版本不支持 -bp 参数。看来是解决selenium和appium版本冲突问题时降低了appium版本导致的

解决方法

  1. 对于 Appium,通常需要指定的参数为 --port 和 --base-path。如果你想设置基础路径,可以使用 --base-path 替代 -bp。因此,修改后的命令如下:
start /b appium -a 127.0.0.1 -p 4723 --base-path /wd/hub

在这里插入图片描述

  1. 在连接到 Appium 服务器时,所请求的会话缺少 automationName 参数的话会出现错误Error connecting to Appium server: Message: 'automationName' can't be blank。automationName 是 Appium 的一个重要配置项,用于指定使用的自动化引擎,比如:
  • UiAutomator2(适用于 Android)
  • XCUITest(适用于 iOS)
desired_caps = {'platformName': 'Android','platformVersion': '5.1.1',  # 确保这个版本与你的设备匹配'deviceName': '127.0.0.1:62025','appPackage': 'com.android.settings','appActivity': '.Settings',  # 等待的活动'noReset': False,"automationName": "UiAutomator2"
}
  1. 设置参数后需要安装相应的驱动。 否则Appium 没有找到与 automationName 为 UiAutomator2 和 platformName 为 Android 的配置相匹配的驱动程序会出现错误Error connecting to Appium server: Message: An unknown server-side error occurred while processing the command. Original error: Could not find a driver for automationName 'UiAutomator2' and platformName 'Android'. Have you installed a driver that supports those capabilities? Run 'appium driver list --installed' to see. (Lower-level error: Could not find installed driver to support given caps)v

  2. 解决步骤
    1)检查已安装的驱动:
    运行以下命令查看已安装的驱动程序:

appium driver list --installed

确保 appium-uiautomator2-driver 驱动程序已安装。如果没有,你需要安装它。

2)安装 UiAutomator2 驱动:
如果你没有安装 UiAutomator2 驱动,可以通过以下命令安装:

appium driver install uiautomator2

再次运行代码-成功

在这里插入图片描述
在这里插入图片描述


http://www.mrgr.cn/news/49006.html

相关文章:

  • 限界上下文(Bounded Context)
  • 开发指南072-模型定义
  • 【Power Query】List.Max List.Min
  • unpacking
  • 软考高级软件架构师论文——论Web系统的测试技术及其应用
  • 力扣刷题之3158.求出出现两次数字的XOR值
  • javaScripts 知识点一 (面试题)
  • InfluxDB持久层封装
  • 全能PDF工具集 | PDF Shaper Ultimate v14.6 便携版
  • 【藏于山中的妖怪,隐入尘烟山海】
  • 【ICESat-2(Ice, Cloud and land Elevation Satellite-2)简介】
  • 计算机毕设选题推荐【软件工程专业】
  • 【分布式微服务云原生】 选择SOAP还是RESTful API?深入探讨与实践指南
  • 【LeetCode】动态规划—95. 不同的二叉搜索树 II(附完整Python/C++代码)
  • javaweb笔记汇总
  • 华为云ECS部署DR模式的LVS
  • 【分布式微服务云原生】 探索SOAP协议:简单对象访问协议的深度解析与实践
  • windows C++-轻量级任务
  • 大模型生图安全疫苗注入赛题解析(DataWhale组队学习)
  • R语言统计分析——折线图