'Selenium Firefox webdriver issues

Below is the python code that I am trying to run

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options

binary = '/usr/bin/firefox'
options = webdriver.FirefoxOptions()
options.binary = binary
options.add_argument('start-maximized')
options.add_argument('--headless')
options.headless=False
options.binary_location = '/usr/bin/firefox'
driverService = Service('/usr/bin/geckodriver')
options.add_argument('window-size=1920x1080')
options.add_argument('--no-sandbox')
options.add_argument('--ignore-certificate-errors')
options.add_argument('--disable-dev-shm-usage')
cap = DesiredCapabilities().FIREFOX
cap["marionette"] = True

driver = Firefox(capabilities=cap, options=options, service=driverService)
driver.capabilities['browserVersion']
print(driver.capabilities['browserVersion'])

I don't know what version of firefox I'm using and I don't know how to find that out, selenium is 4.1.5 and geckodriver is 0.31 On running this, I get

  driver = Firefox(capabilities=cap, options=options, service=driverService)
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/xtesting/ci/./ui_testing_firefox.py", line 30, in <module>
    driver = Firefox(capabilities=cap, options=options, service=driverService)
  File "/usr/lib/python3.9/site-packages/selenium/webdriver/firefox/webdriver.py", line 180, in __init__
    RemoteWebDriver.__init__(
  File "/usr/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 275, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 365, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 430, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status signal

I am unable to find a specific solution to resolve this issue, I would really appreciate the help.



Sources

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

Source: Stack Overflow

Solution Source