Skip to content

selenium.common.exceptions.WebDriverException on trying to run tests in Firefox under python3.11.2 #1813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
olait2018 opened this issue Mar 20, 2023 · 7 comments · Fixed by #1815
Assignees
Labels
bug Uh oh... Something needs to be fixed workaround exists You can reach your destination if you do this...

Comments

@olait2018
Copy link

olait2018 commented Mar 20, 2023

Hello,

Recently I've upgraded python3.8 to 3.11.2 and tried to run tests in Firefox, but receive following error:
...

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

Environment:

# uname -a
Linux fba36d108b02 5.10.76-linuxkit #1 SMP PREEMPT Mon Nov 8 11:22:26 UTC 2021 x86_64 GNU/Linux

# python3 --version
Python 3.11.2

# pytest --version
pytest 7.2.2

# firefox --full-version
Mozilla Firefox 111.0 20230309232128 20230309232128

# geckodriver --version
geckodriver 0.32.0 (4563dd583110 2022-10-13 09:22 +0000)

NOTE: I tried also [latest](https://github.com/mozilla/geckodriver/releases#:~:text=0.32.2-,Latest,-0.32.2%20(2023%2D02) driver - 0.32.2, but no luck.

# pip show seleniumbase
Name: seleniumbase
Version: 4.13.15

# echo $PATH
/automation_web/new_venv/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-11-openjdk-amd64/bin:/opt/firefox:/usr/local/bin/geckodriver

I tried to run test_basic with the following command:
pytest -k test_basics --headless --browser=firefox
, but receive long stack-trace with error:

...
self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x400dbd2a90>, response = {'status': 500, 'value': '{"value":{"error":"unknown error","message":"Process unexpectedly closed with status 1","stacktrace":""}}'}
...
new_venv/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py:245: WebDriverException 
FAILED basic_test.py::MyTestClass::test_basics - selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1

Full error log is in the file full_error_log.txt

I tried to verify geckodriver as is described here , but with the only difference - headless=True , and received following error:

# python3
Python 3.11.2 (main, Mar 17 2023, 02:28:16) [GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from seleniumbase import get_driver
>>> driver = get_driver("firefox", headless=True)
Traceback (most recent call last):
  File "/automation_web/new_venv/lib/python3.11/site-packages/seleniumbase/core/browser_launcher.py", line 1958, in get_local_driver
    return webdriver.Firefox(
           ^^^^^^^^^^^^^^^^^^
  File "/automation_web/new_venv/lib/python3.11/site-packages/selenium/webdriver/firefox/webdriver.py", line 196, in __init__
    super().__init__(command_executor=executor, options=options, keep_alive=True)
  File "/automation_web/new_venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 286, in __init__
    self.start_session(capabilities, browser_profile)
  File "/automation_web/new_venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 378, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/automation_web/new_venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
    self.error_handler.check_response(response)
  File "/automation_web/new_venv/lib/python3.11/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 1


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/automation_web/new_venv/lib/python3.11/site-packages/seleniumbase/core/browser_launcher.py", line 1236, in get_driver
    return get_local_driver(
           ^^^^^^^^^^^^^^^^^
  File "/automation_web/new_venv/lib/python3.11/site-packages/seleniumbase/core/browser_launcher.py", line 1979, in get_local_driver
    return webdriver.Firefox(
           ^^^^^^^^^^^^^^^^^^
  File "/automation_web/new_venv/lib/python3.11/site-packages/selenium/webdriver/firefox/webdriver.py", line 196, in __init__
    super().__init__(command_executor=executor, options=options, keep_alive=True)
  File "/automation_web/new_venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 286, in __init__
    self.start_session(capabilities, browser_profile)
  File "/automation_web/new_venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 378, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/automation_web/new_venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
    self.error_handler.check_response(response)
  File "/automation_web/new_venv/lib/python3.11/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 1
>>> 

Could you please help to resolve this issue?
Thanks in advance!

@olait2018
Copy link
Author

In the same time simple pure selenium test works ok in the same environment:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager


options = Options()
options.add_argument('-headless')
options.add_argument('--window-size=1920,1080')
options.add_argument('start-maximized')
driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()), options=options)

driver.get("https://www.selenium.dev/")

# wait for page to load
element = WebDriverWait(driver=driver, timeout=5).until(
    EC.presence_of_element_located((By.CSS_SELECTOR, '.h3.mb-3.selenium-webdriver'))
)
assert driver.find_element(By.CSS_SELECTOR, ".h4.mb-3.selenium-webdriver").is_displayed(), "'.h3.mb-3.selenium-webdriver' not found"

driver.close()
driver.quit()

@mdmintz
Copy link
Member

mdmintz commented Mar 21, 2023

Try it with one of the 23 Syntax Formats: https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md

You used:

from seleniumbase import get_driver
driver = get_driver("firefox", headless=True)

But you might want to try this instead:

from seleniumbase import Driver
driver = Driver(browser="firefox", headless=True)

Your way was calling browser_launcher.py directly, which is missing key steps.

@olait2018
Copy link
Author

thanks @mdmintz
I've tried, but no luck, I still get error:

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

Full log and list of commands I executed is here
logs.txt

@mdmintz
Copy link
Member

mdmintz commented Mar 21, 2023

OK, I think I see the issue now. I'll ship a fix in the next release.

@mdmintz mdmintz self-assigned this Mar 21, 2023
@mdmintz mdmintz added the bug Uh oh... Something needs to be fixed label Mar 21, 2023
@mdmintz
Copy link
Member

mdmintz commented Mar 21, 2023

For the moment, here's a workaround that should work when running tests:

pytest --firefox-arg="-headless"

That works as a backup to Xvfb not running on Linux. Xvfb prevented a lot of issues with regular headless mode for Firefox on Linux, but if it's unable to run, then this will override SeleniumBase to force native Firefox headless.

In a release coming soon, I'll add error-handling so that if Process unexpectedly closed with status ... shows up on Linux with Firefox, it will retry with regular headless mode.

But until then, use pytest --firefox-arg="-headless".

@mdmintz mdmintz added the workaround exists You can reach your destination if you do this... label Mar 21, 2023
@olait2018
Copy link
Author

many thanks, @mdmintz
Workaround works good!

@mdmintz
Copy link
Member

mdmintz commented Mar 22, 2023

Resolved in 4.13.16 - https://github.com/seleniumbase/SeleniumBase/releases/tag/v4.13.16 without need of a workaround. If any issues, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Uh oh... Something needs to be fixed workaround exists You can reach your destination if you do this...
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants