WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 64 error using Selenium Geckodriver Firefox in FreeBSD jail
Asked Answered
M

2

17

For some tests, I've set up a plain new TrueNAS 12.3 FreeBSD Jail and started it, then installed python3, firefox, geckodriver and pip using the following commands:

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

Afterwards, when I want to use Selenium with Firefox in my Python code, it does not work:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)

it brings

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

Funnily, on another Jail that I've set up approximately a year ago (approximately in the mentioned way as well), it just works and does not throw the error (so different versions maybe?)!

This is the only content of 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

Is there anything I could try to get it working? I've already seen this question, but it seems fairly outdated.

Firefox 95.0.2, geckodriver 0.26.0, Python 3.8.12, Selenium 4.1.0

Merrill answered 23/1, 2022 at 11:50 Comment(4)
What is the Selenium and GeckoDriver version you are using?Ferreous
@undetectedSelenium Firefox 95.0.2, geckodriver 0.26.0, Python 3.8.12, Selenium 4.1.0Merrill
oops, possibly looking into the error I missed out the last line of the question. I can see it there nowFerreous
TL;DR for people with same error message: (a solution may be to) update to: github.com/mozilla/geckodriver/releases/tag/v0.30.0Santosantonica
F
26

This error message...

selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: 64

and the GeckoDriver log...

geckodriver: error: Found argument '--websocket-port' which wasn't expected, or isn't valid in this context

...implies that the GeckoDriver was unable to initiate/spawn a new Browsing Context i.e. session.


Your main issue is the incompatibility between the version of the binaries you are using as follows:

  • Your Selenium Client version is 4.1.0.
  • But your GeckoDriver version is 0.26.0.

As @ernstki mentions in their comment:

You are running a geckodriver older than 0.30.0, and it is missing the --websocket-port option, which newer/new-ish versions of Selenium seem to depend on.

To put it in simple words, till the previous GeckoDriver release of v0.29.0 the --websocket-port option wasn't in use, which is now mandatory with Selenium v4.0.1.

Further @whimboo also confirmed in his comment:

As it has been manifested the problem here is not geckodriver but Selenium. As such you should create an issue on the Selenium repository instead, so that an option could be added to not always pass the --websocket-port argument. If that request gets denied you will have to use older releases of Selenium if testing with older geckodriver releases is really needed.


Solution

Ensure that:

  • Selenium is upgraded to current levels Version 4.1.0.
  • GeckoDriver is upgraded to GeckoDriver v0.30.0 level.
  • Firefox is upgraded to current Firefox v96.0.2 levels.

FreeBSD versions

Incase you are using FreeBSD versions where the GeckoDriver versions are older, in those cases you have to downgrade Selenium to v3.x levels.

Commands (courtesy: Kurtibert):

  • Uninstall Selenium:

    pip3 uninstall selenium;
    
  • Install Selenium:

    pip3 install 'selenium<4.0.0'
    
Ferreous answered 23/1, 2022 at 12:43 Comment(4)
Since my pkg doesn't give me anything newer than 0.26.0, I guess someone has to build a FreeBSD version of geckodriver before new Selenium versions are useable on FreeBSD? Or am I missing something here?Merrill
@Merrill In that case you have to downgrade Selenium to v3.x levels. I'd add even that clause to the answer.Ferreous
Yeeeees =) I've found out that v3.141.0 works (if you wish to add it to the answer). pip3 uninstall selenium; pip3 install 'selenium<4.0.0'Merrill
Done updating with the commandsFerreous
E
3

I added the following codes to my dockerfile and my problem was solved. My problems were with the version.

My problem is solved with Selenium 4.1.0 and geckodriver v30.

RUN pip install -U selenium==4.1.0
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz
RUN tar -x geckodriver -zf geckodriver-v0.30.0-linux64.tar.gz -O > /usr/local/bin/geckodriver
RUN chmod +x /usr/local/bin/geckodriver
RUN rm geckodriver-v0.30.0-linux64.tar.gz
Ekaterinburg answered 1/4, 2022 at 7:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.