英文:
RobotFramework error - TypeError: WebDriver.__init__() got an unexpected keyword argument 'service_log_path'
问题
我正在尝试首次安装和使用RobotFramework。我已经完成了所有安装,并有一个测试机器人,只是尝试打开Chrome。每次运行它时,我都会收到以下错误...
TypeError: WebDriver.init()得到了一个意外的关键字参数'service_log_path'
这是我的安装环境
Macbook M1 Pro
Chrome 版本 114.0.5735.106(官方版本)(arm64)
Python 3.11
PyCharm 2023.1.2 CE
Robotframework 6.0.2
robotframework-seleniumlibrary 6.1.0
selenium 4.10.0
chromedriver 114.0.5735.90
我已经完全重新安装了所有东西,但Chrome除外。
英文:
I am trying to install and use RobotFramework for the first time. I've done all the installations and have a test robot that simply tries to open Chrome. Every time I run it, I get the following error...
TypeError: WebDriver.init() got an unexpected keyword argument 'service_log_path'
Here are my installed environment
Macbook M1 Pro
Chrome Version 114.0.5735.106 (Official Build) (arm64)
Python 3.11
PyCharm 2023.1.2 CE
Robotframework 6.0.2
robotframework-seleniumlibrary 6.1.0
selenium 4.10.0
chromedriver 114.0.5735.90
I've completely reinstalled everything but Chrome.
答案1
得分: 9
使用selenium 4.9.1暂时:
pip install selenium==4.9.1
英文:
Use selenium 4.9.1 for the time being:
pip install selenium==4.9.1
答案2
得分: 5
这个错误是由于selenium
的4.10.0
版本中的更改引起的:https://github.com/SeleniumHQ/selenium/commit/9f5801c82fb3be3d5850707c46c3f8176e3ccd8e
注意,service_log_path
已从__init__
中移除,但现在有一种通过新版本中的service
参数传递它的方法。以下是通过新版本中的service
参数传递service_log_path
的代码片段:
import os
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
service = Service(
executable_path=r'/usr/bin/chromedriver',
service_log_path=os.devnull,
)
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(service=service, options=options)
# ...
driver.quit()
如果这部分应该由Robot Framework直接完成,您应该直接在他们的GitHub页面上联系他们并提出问题:https://github.com/robotframework/robotframework
英文:
That error is due to changes in selenium
4.10.0
:
https://github.com/SeleniumHQ/selenium/commit/9f5801c82fb3be3d5850707c46c3f8176e3ccd8e
Note that service_log_path
has been removed from the __init__
, but there is now another way of passing it in. Here's a code snippet on passing service_log_path
via the service
arg in the new version:
import os
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
service = Service(
executable_path=r'/usr/bin/chromedriver',
service_log_path=os.devnull,
)
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(service=service, options=options)
# ...
driver.quit()
If that part is supposed to be done by Robot Framework directly, you should reach out to them on their GitHub page and open an issue directly with them: https://github.com/robotframework/robotframework
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论