针对一些测试,我已经创建了一个全新的TrueNAS 12.3 FreeBSD Jail并启动它,然后使用以下命令安装了python3
, firefox
, geckodriver
和pip
:
pkg install python3 firefox geckodriver py38-pip
pip install --upgrade pip
setenv CRYPTOGRAPHY_DONT_BUILD_RUST 1
pip install cryptography==3.4.7
pip install selenium
之后,当我想在Python代码中使用Selenium与Firefox一起使用时,它无法正常工作:
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)
它带来的是
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
self.service.start()
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 110, in assert_process_still_running
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 64
有趣的是,我大约一年前设置了另一个类似的监狱(也是这样设置的),它可以正常工作而不会抛出错误(可能是因为不同的版本?)!
以下是
geckodriver.log
的唯一内容:geckodriver: error: Found argument '--websocket-port' which wasn't expected, orisn't valid in this context
USAGE:
geckodriver [FLAGS] [OPTIONS]
For more information try --help
有什么方法可以让它正常工作吗?我已经看过这个问题,但是它似乎相当过时。
Firefox 95.0.2,geckodriver 0.26.0,Python 3.8.12,Selenium 4.1.0