[英]Selenium 4 and webdriver manager for firefox fails to run in Ubuntu
Apologies I am quite new to all this so trying to figure out if I am doing the right thing.抱歉,我对这一切都很陌生,所以想弄清楚我是否做对了。 I am running Ubuntu 22.04 and Selenium 4.8我正在运行 Ubuntu 22.04 和 Selenium 4.8
I installed latest Geckodriver from Mozilla GitHub, converted it into executable and then moved it to /usr/local/bin/
我从 Mozilla GitHub 安装了最新的 Geckodriver,将其转换为可执行文件,然后将其移动到/usr/local/bin/
I then downloaded webdriver manager and tried to run the following snippet for Firefox:然后我下载了 webdriver manager 并尝试为 Firefox 运行以下代码片段:
# selenium 4 - updating geckodriver for firefox
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager
driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))
When I run that, it starts downloading: [WDM] - Downloading: 19.0kB [00:00, 13.9MB/s]
and then it fails I get following error: selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 127
当我运行它时,它开始下载: [WDM] - Downloading: 19.0kB [00:00, 13.9MB/s]
然后失败我收到以下错误: selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 127
full error:完整错误:
[WDM] - Downloading: 19.0kB [00:00, 13.9MB/s]
Traceback (most recent call last):
File "/home/gizmo/PycharmProject/PythonProjects/web/firefox_selenium.py", line 6, in <module>
driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()))
File "/home/gizmo/PycharmProject/PythonProjects/venv/lib/python3.10/site-packages/selenium/webdriver/firefox/webdriver.py", line 196, in __init__
super().__init__(command_executor=executor, options=options, keep_alive=True)
File "/home/gizmo/PycharmProject/PythonProjects/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 286, in __init__
self.start_session(capabilities, browser_profile)
File "/home/gizmo/PycharmProject/PythonProjects/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 378, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/gizmo/PycharmProject/PythonProjects/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
self.error_handler.check_response(response)
File "/home/gizmo/PycharmProject/PythonProjects/venv/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 127
Where am I going wrong?我哪里错了?
Goal: tried to get the webdriver manager to update my geckodriver for Firefox - ran it as a test to see if it is all setup correctly.目标:试图让 webdriver 管理器为 Firefox 更新我的 geckodriver - 运行它作为测试以查看它是否全部设置正确。
Ensure that:确保这件事:
Selenium is upgraded to v4.0.0 or above Selenium升级到v4.0.0以上
pip3 install -U selenium
Webdriver Manager for Python is installed已安装Python 的 Webdriver Manager
pip3 install webdriver-manager
You can find a detailed discussion on installing Webdriver Manager for Python in ModuleNotFoundError: No module named 'webdriver_manager' error even after installing webdrivermanager您可以在ModuleNotFoundError: No module named 'webdriver_manager' error even after installing webdrivermanager中找到有关为 Python 安装 Webdriver Manager的详细讨论
You don't have to cast to FirefoxService
instance and can use the Service
instance.您不必强制转换为FirefoxService
实例并且可以使用Service
实例。 You can use:您可以使用:
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from webdriver_manager.firefox import GeckoDriverManager
driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.