英文:
Getting TypeError: WebDriver.__init__() got an unexpected keyword argument ‘desired_capabilities’ when using Appium with Selenium 4.10
问题
Error:
HOOK-ERROR in before_scenario: TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'
你好,我们目前无法与最新的 Selenium 4.10 一起运行我们的脚本。这是 Appium 错误还是 Python 错误?
这是我们使用的能力。我们目前正在尝试通过targetOS = self.driver.capabilities['platformName']
获取 platformName 的能力,但遇到了这个错误。
capabilities = {
"platformName": "Android",
"appium:platformVersion": "11.0",
"appium:deviceName": "emulator-5554",
"appium:app": "/Users/faithberroya/Downloads/test.apk",
"appium:automationName": "UiAutomator2",
"appium:appPackage": "com.test.school.assignment.rc",
"appium:appActivity": "com.test.school.assignment.ui.SplashActivity"
}
# 启动应用
context.driver = webdriver.Remote("http://0.0.0.0:4723/wd/hub", capabilities)
# 添加等待时间
context.driver.implicitly_wait(20)
# 应用
context.app = Application(context.driver)
当前 pip 列表
Appium-Python-Client 2.10.1
behave 1.2.6
certifi 2023.5.7
pip 23.1.1
requests 2.31.0
selenium 4.9.0
英文:
Error:
HOOK-ERROR in before_scenario: TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'
Hello, we currently cannot run our script together with the latest Selenium 4.10. Is this Appium error or Python error?
Here is the capabilities that we used. We're currently trying to get the capabilities for platformName by targetOS = self.driver.capabilities['platformName']
but we're hit with this error
capabilities = {
"platformName": "Android",
"appium:platformVersion": "11.0",
"appium:deviceName": "emulator-5554",
"appium:app": "/Users/faithberroya/Downloads/test.apk",
"appium:automationName": "UiAutomator2",
"appium:appPackage": "com.test.school.assignment.rc",
"appium:appActivity": "com.test.school.assignment.ui.SplashActivity"
}
# launch app
context.driver = webdriver.Remote("http://0.0.0.0:4723/wd/hub", capabilities)
# add wait time
context.driver.implicitly_wait(20)
# app
context.app = Application(context.driver)
Current pip list
Appium-Python-Client 2.10.1
behave 1.2.6
certifi 2023.5.7
pip 23.1.1
requests 2.31.0
selenium 4.9.0
答案1
得分: 13
这是由于selenium
4.10.0
中的更改所导致的:
https://github.com/SeleniumHQ/selenium/commit/9f5801c82fb3be3d5850707c46c3f8176e3ccd8e
请注意,desired_capabilities
已从__init__
中移除,但现在有一种新的传递方式。有关如何在使用selenium
4.10.0
(或更新版本)时传递所需的功能的文档,请参见https://www.selenium.dev/documentation/webdriver/getting_started/upgrade_to_selenium_4/#capabilities。
以下是在新版本中使用功能的代码片段:
from selenium.webdriver.firefox.options import Options as FirefoxOptions
options = FirefoxOptions()
cloud_options = {}
cloud_options['build'] = "build_1"
cloud_options['name'] = "test_abc"
options.set_capability('cloud:options', cloud_options)
driver = webdriver.Remote("http://0.0.0.0:4723/wd/hub", options=options)
英文:
This is due to changes in selenium
4.10.0
:
https://github.com/SeleniumHQ/selenium/commit/9f5801c82fb3be3d5850707c46c3f8176e3ccd8e
Note that desired_capabilities
has been removed from the __init__
, but there is now another way of passing it in. See https://www.selenium.dev/documentation/webdriver/getting_started/upgrade_to_selenium_4/#capabilities for the documentation on how to pass in desired capabilities when using selenium
4.10.0
(or newer).
Here's a code snippet on using capabilities in the new version:
from selenium.webdriver.firefox.options import Options as FirefoxOptions
options = FirefoxOptions()
cloud_options = {}
cloud_options['build'] = "build_1"
cloud_options['name'] = "test_abc"
options.set_capability('cloud:options', cloud_options)
driver = webdriver.Remote("http://0.0.0.0:4723/wd/hub", options=options)
答案2
得分: 2
我遇到了类似的问题。默认情况下,Appium Python客户端使用最新的Selenium版本(4.10.0)。所以我将版本降级到4.9.0,并使用Appium Python客户端2.9.0,问题得以解决。
英文:
I face similar issue. By default Appium python client uses latest selenium release(4.10.0). So i downgraded the version to 4.9.0 with Appium-python-client as 2.9.0 and it worked fine.
答案3
得分: 1
Appium-Python-Client,版本太高,请尝试版本 Appium-Python-Client==1.2.0
英文:
Appium-Python-Client,The version is too high, try version Appium-Python-Client==1.2.0
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论