Я получил это для работы в Jessie / Stretch с предыдущими версиями Firefox, но, похоже, не могу заставить его работать с Raspberry Pi 3B или 4 под управлением Raspbian Buster и последней Selenium, 3.141.0 в Python.
Так как iceweasel больше не доступен, я устанавливаю firefox-esr
через apt и получаю последний ARK geckodriver, который в настоящее время равен 0.23.0, из https://github.com/mozilla/geckodriver/releases, затем запускаю код ниже:
from selenium import webdriver
from pyvirtualdisplay import Display
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
capabilities = webdriver.DesiredCapabilities().FIREFOX
capabilities["marionette"] = False
driver = webdriver.Firefox(options=options, executable_path='/usr/bin/geckodriver', capabilities=capabilities)
driver.get('https://www.google.com')
print(driver.page_source)
driver.close()
display.stop()
Это возвращает ошибку:
Message: Can't load the profile. Possible firefox version mismatch. You must use GeckoDriver instead for Firefox 48+. Profile Dir: /tmp/tmpxMUUcF If you specified a log_file in the FirefoxBinary constructor, check it for details.
Traceback (most recent call last):
File "SeleniumDebugExample.py", line 50, in <module>
driver = webdriver.Firefox(options=options, executable_path='/srv/main/geckodriver', capabilities=capabilities)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 191, in __init__
self.binary, timeout)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 52, in __init__
self.binary.launch_browser(self.profile, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 73, in launch_browser
self._wait_until_connectable(timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 114, in _wait_until_connectable
% (self.profile.path))
WebDriverException: Message: Can't load the profile. Possible firefox version mismatch. You must use GeckoDriver instead for Firefox 48+. Profile Dir: /tmp/tmpxMUUcF If you specified a log_file in the FirefoxBinary constructor, check it for details.
Я указываю geckodriver, хотя, поэтому я не уверен, в чем проблема ...
Если кто-то получил безголовый селен для работы на Raspbian Busterи может поделиться некоторыми, это было бы очень ценно!