0

Apologies I am quite new to all this so trying to figure out if I am doing the right thing. I am running Ubuntu 22.04 and Selenium 4.8

I installed latest Geckodriver from Mozilla GitHub, converted it into executable and then moved it to /usr/local/bin/

I then downloaded webdriver manager and tried to run the following snippet for Firefox:

# selenium 4 - updating geckodriver for firefox
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))

When I run that, it starts downloading: [WDM] - Downloading: 19.0kB [00:00, 13.9MB/s] and then it fails I get following error: selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 127

full error:

[WDM] - Downloading: 19.0kB [00:00, 13.9MB/s]                   
Traceback (most recent call last):
  File "/home/gizmo/PycharmProject/PythonProjects/web/firefox_selenium.py", line 6, in <module>
    driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()))
  File "/home/gizmo/PycharmProject/PythonProjects/venv/lib/python3.10/site-packages/selenium/webdriver/firefox/webdriver.py", line 196, in __init__
    super().__init__(command_executor=executor, options=options, keep_alive=True)
  File "/home/gizmo/PycharmProject/PythonProjects/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 286, in __init__
    self.start_session(capabilities, browser_profile)
  File "/home/gizmo/PycharmProject/PythonProjects/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 378, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/gizmo/PycharmProject/PythonProjects/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
    self.error_handler.check_response(response)
  File "/home/gizmo/PycharmProject/PythonProjects/venv/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 127

Where am I going wrong?

Goal: tried to get the webdriver manager to update my geckodriver for Firefox - ran it as a test to see if it is all setup correctly.

Gizmo
  • 1
  • 2

1 Answers1

1

Pre-requisites

Ensure that:

  • Selenium is upgraded to v4.0.0 or above

    pip3 install -U selenium
    
  • Webdriver Manager for Python is installed

    pip3 install webdriver-manager
    

You can find a detailed discussion on installing Webdriver Manager for Python in ModuleNotFoundError: No module named 'webdriver_manager' error even after installing webdrivermanager


You don't have to cast to FirefoxService instance and can use the Service instance. You can use:

from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()))

Note: Ensure that your is updated to the latest version.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Isn't that for Chrome? I am specifically using FireFox – Gizmo Jan 25 '23 at 14:11
  • Ahhh, you were too early ;) – undetected Selenium Jan 25 '23 at 14:12
  • Sorry:). Ok, tried the above, still getting same error. It starts downloading and then fails – Gizmo Jan 25 '23 at 14:21
  • So the error _selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 127_ is no more reproducible and the new issue sounds to be a different issue all together. Feel free to raise a new question with all the relevant details. – undetected Selenium Jan 25 '23 at 14:24
  • what do you mean, its the same issue as before, it starts downloading then fails? I'll update original as that was always the case – Gizmo Jan 25 '23 at 14:27
  • it throws the status 127 error as per original error and with your code snippet. – Gizmo Jan 25 '23 at 14:30
  • Checkout the updated answer and let me know the ststus. – undetected Selenium Jan 25 '23 at 19:31
  • Ran the commands `Requirement already satisfied: selenium in ./venv/lib/python3.10/site-packages (4.8.0)` and same for webdriver-manager `Requirement already satisfied: webdriver-manager in ./venv/lib/python3.10/site-packages (3.8.5)` it did 3 downloads [WDM] - Downloading: 19.0kB [00:00, 15.8MB/s] [WDM] - Downloading: 19.0kB [00:00, 17.6MB/s] [WDM] - Downloading: 100%|██████████| 2.85M/2.85M [00:00<00:00, 16.1MB/s] then 5 lines failed and same error: selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 127 ` – Gizmo Jan 27 '23 at 13:11
  • does this simply mean the webdriver is up to date or it's still failing? – Gizmo Jan 27 '23 at 13:12
  • I can see _`Downloading: 100%`_. Do you have the latest Firefox binary? – undetected Selenium Jan 27 '23 at 18:11
  • sorry for such a basic question - how do I check if my firefox has latest binary? do you mean is it up to date? – Gizmo Jan 27 '23 at 20:33
  • @Gizmo Check if Mozilla browser is updated to the latest version. – undetected Selenium Jan 27 '23 at 20:39
  • Checked - `(venv) gizmo@vm:~/PycharmProject/PythonProjects$ firefox --version Mozilla Firefox 109.0` – Gizmo Jan 29 '23 at 13:39