Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Headless selenium (Firefox) does not work
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
hrnick
Guru
Guru


Joined: 31 Aug 2002
Posts: 429
Location: Sweden

PostPosted: Sun Nov 10, 2024 5:09 pm    Post subject: Headless selenium (Firefox) does not work Reply with quote

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
View user's profile Send private message
thegrind
n00b
n00b


Joined: 22 Sep 2024
Posts: 26

PostPosted: Sun Nov 10, 2024 5:40 pm    Post subject: Reply with quote

I thought you had to import options as well

Code:
from selenium.webdriver.firefox.options import options
options = options()
Back to top
View user's profile Send private message
hrnick
Guru
Guru


Joined: 31 Aug 2002
Posts: 429
Location: Sweden

PostPosted: Mon Nov 11, 2024 5:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
hrnick
Guru
Guru


Joined: 31 Aug 2002
Posts: 429
Location: Sweden

PostPosted: Mon Nov 18, 2024 12:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
hrnick
Guru
Guru


Joined: 31 Aug 2002
Posts: 429
Location: Sweden

PostPosted: Tue Dec 17, 2024 6:58 pm    Post subject: Reply with quote

Any other ideas? Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum