出现这个错误是因为selenium与Appium-Python-Client版本不匹配。

appium:

selenium:

selenium要4.0版本以上
卸载selenium3.141:
pip uninstall selenium

如果安装selenium4.0
pip install selenium==4.0

**
会提示如果安装了,appium-python-client 2.7.1,那就要安装selenium~=4.1,这样依赖才匹配。selenium3.141和selenium4.0,4.1相差不是很大,但是selenium不同版本里的依赖需要与appium里的依赖要相匹配。以后要注意每个包都尽量安装最新的,因为我们不晓得每个包的依赖之间的关系,过低版本会使得其他的包的依赖不匹配,报系统性的一些错误。(系统性的一些错误多是环境错误)
**
那我们重新安装selenium=4.1
pip install selenium==4.1
可以顺利安装成功!
代码也可以正常运行
from time import sleep
from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy
des_cap = {}
des_cap['platformName'] = 'Android'
des_cap['appPackage'] = 'com.kejia.mine'
des_cap['appActivity'] = '.app.Mine'
des_cap['noReset'] = True
driver = webdriver.Remote(command_executor='http://127.0.0.1:4723/wd/hub',
desired_capabilities=des_cap)
sleep(5)
ele_newgame = driver.find_element(AppiumBy.ID, 'com.kejia.mine:id/btn_newgame')
print(ele_newgame.text)
ele_newgame.click()
本文档介绍了在使用Python的selenium和appium时遇到的版本不匹配问题,以及如何通过升级selenium到4.1版本来解决这个问题。通过正确的版本匹配,确保代码能够正常运行。涉及的关键技术包括自动化测试、移动应用测试和Python库的管理。

921

被折叠的 条评论
为什么被折叠?



