我正在尝试使用 Python 练习 Appium 自动化。我有以下代码:
from appium import webdriver
desired_caps = {}
desired_caps['platformName'] = 'iOS'
desired_caps['platformVersion'] = '17.0'
desired_caps['deviceName'] = 'iPhone 15 Pro'
desired_caps['udid'] = 'dummy_udid_here'
desired_caps['bundleId'] = 'com.dummyname.IntegrationApp'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
driver.implicitly_wait(10)
time.sleep(2)
driver.quit()
但是,将所需的上限传递给驱动程序时出现错误,显示
Expected type 'bool', got 'dict[str, str]' instead.
我尝试改变定义desired_caps的方式,包括字典文字。我还尝试在另一个文件中初始化网络驱动程序。我期望 webdriver.Remote 按原样接受所需的_caps,但我无法弄清楚为什么会出现此变量类型错误。
我所在的工作分支还包括初始化本地和 Jenkins Chrome webdrivers。
我不确定自 Appium 2 以来此 webdriver.Remote 是否发生了变化,或者是否与使用 Appium Python Client 3.0.0 发生了变化。
有更新吗?我在desired_caps上遇到了同样的错误。
webdriver.Remote 建议语法:command_executor:str | AppiumConnection = 'http://127.0.0.1.4444/wd/hub', keep_alive:bool = True, direct_connection: bool = True, ......