'selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1 running Selenium Chrome Driver inside Python project

I am running the following code:

from selenium import webdriver

driver = webdriver.Firefox()  
driver.get("https://web.whatsapp.com/")

I have installed firefox under /usr/bin/firefox and geckodriver (same version) under /usr/bin/geckodriver

However, I am getting the following stacktrace error when the Python code is run:

selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1

Full code is here: https://github.com/harshitsidhwa/WhatsApp-bot-selenium/blob/master/whatsapp.py



Solution 1:[1]

This error message...

selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1

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

Possibly there are some incompatibility between the version of the binaries you are using.


Solution

Ensure that:

  • JDK is upgraded to current levels JDK 8u311.
  • Selenium is upgraded to current levels Version 4.1.3.
  • GeckoDriver is upgraded to GeckoDriver v0.30.0 level.
  • Firefox is upgraded to current Firefox v98.0.2 levels.
  • GeckoDriver is present in the desired location.
  • GeckoDriver is having executable permission for non-root users.

Solution 2:[2]

I have the same error message when I running Selenium 4 + Firefox on Centos 8

I check the log file geckodriver.log

It is showing

Running Firefox as root in a regular user's session is not supported.

so I'm using a non-root user to run the same Python script, It is working now.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 undetected Selenium
Solution 2 jasondayee