from appium import webdriver
pg_file = {"platformName": "Android", "platformVersion": "7.1.2", "deviceName": "appium",
"automationName": "uiautomator2", "noReset": True}
driver = webdriver.Remote('http://127.0.0.1:4723',pg_file)
原因
这个是Appium3.0版本之前的用法,在3.0版本不再适用。因为在 Appium 3.0 版本后,引入了一个新的测试引擎-UiAutomator2。
解决方法
from appium import webdriver
from appium.options.android import UiAutomator2Options
pg_file = {"platformName": "Android", "platformVersion": "7.1.2", "deviceName": "appium",
"automationName": "uiautomator2", "noReset": True}
options = UiAutomator2Options().load_capabilities(pg_file)
driver = webdriver.Remote('http://127.0.0.1:4723',options=options)
- 再导入一个UiAutomator2Options类,对配置选项进行格式转换。
Appium、selenium、python的版本对应
Appium Python Client | Selenium binding | Python version |
---|---|---|
3.0.0 + | 4.12.0 + | 3.8+ |
2.10.0 - 2.11.1 | 4.1.0 - 4.11.2 | 3.7+ |
2.2.0 - 2.9.0 | 4.1.0 - 4.9.0 | 3.7+ |
2.0.0 - 2.1.4 | 4.0.0 | 3.7+ |
1.0.0 - 1.1.0 | 3.x | 3.7, 3.8 |
0.52 and below | 3.x | 2.7, 3.4 - 3.7 |