View previous topic :: View next topic |
Author |
Message |
hrnick Guru
Joined: 31 Aug 2002 Posts: 429 Location: Sweden
|
Posted: Sun Nov 10, 2024 5:09 pm Post subject: Headless selenium (Firefox) does not work |
|
|
I have problems getting Selenium to work with Firefox in headless mode. It used to work but at some point the past few months it seems to have stopped working. The following script works if I comment out the headless line, otherwise I get the error message below.
Code: | #!/usr/bin/python
from selenium import webdriver
options = webdriver.FirefoxOptions()
options.add_argument("--headless")
driver = webdriver.Firefox(options=options)
driver.get("https://google.com")
driver.quit() |
Code: | $ ./test
hrnick@crow ~/misc $ ./test
Traceback (most recent call last):
File "/home/hrnick/misc/./test", line 8, in <module>
driver = webdriver.Firefox(options=options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/selenium/webdriver/firefox/webdriver.py", line 71, in __init__
super().__init__(command_executor=executor, options=options)
File "/usr/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 238, in __init__
self.start_session(capabilities)
File "/usr/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 325, in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 380, in execute
self.error_handler.check_response(response)
File "/usr/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status signal |
I'm running...
Code: | dev-python/selenium-4.26.1
dev-util/selenium-manager-4.26.0-r1
www-client/firefox-132.0.1-r1
net-misc/geckodriver-0.35.0-r1 |
Any ideas what could be wrong? Could the separation of www-client/firefox and net-misc/geckodriver have anything to do with this? Any help would be appreciated, thanks! |
|
Back to top |
|
|
thegrind n00b
Joined: 22 Sep 2024 Posts: 26
|
Posted: Sun Nov 10, 2024 5:40 pm Post subject: |
|
|
I thought you had to import options as well
Code: | from selenium.webdriver.firefox.options import options
options = options() |
|
|
Back to top |
|
|
hrnick Guru
Joined: 31 Aug 2002 Posts: 429 Location: Sweden
|
Posted: Mon Nov 11, 2024 5:47 pm Post subject: |
|
|
thegrind wrote: | I thought you had to import options as well
Code: | from selenium.webdriver.firefox.options import options
options = options() |
|
Thanks for your reply!
I'm in no way a python expert but I would have expected to get something in line with name not defined error or similar in that case. And adding...
Code: | from selenium.webdriver.firefox.options import Options |
...does not make a difference. |
|
Back to top |
|
|
hrnick Guru
Joined: 31 Aug 2002 Posts: 429 Location: Sweden
|
Posted: Mon Nov 18, 2024 12:59 pm Post subject: |
|
|
So just downgrading to firefox-115.16.1-r1 makes the script work but with the following error message:
Code: | The geckodriver version (0.33.0) detected in PATH at /usr/bin/geckodriver might not be compatible with the detected firefox version (115.16.1); currently, geckodriver 0.35.0 is recommended for firefox 115.*, so it is advised to delete the driver in PATH and retry |
Could this be connected to the separation of geckodriver from firefox into a separate package? |
|
Back to top |
|
|
hrnick Guru
Joined: 31 Aug 2002 Posts: 429 Location: Sweden
|
Posted: Tue Dec 17, 2024 6:58 pm Post subject: |
|
|
Any other ideas? Thanks! |
|
Back to top |
|
|
|