How do you determine why Firefox is crashing when run from inside some Django unittests via Selenium?
My testcase is:
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from pyvirtualdisplay import Display
from selenium import webdriver
class Tests(StaticLiveServerTestCase):
def setUp(self):
super(Tests, self).setUp()
self.vdisplay = Display(visible=0, size=(1920, 1080), backend='xvfb')
self.vdisplay.start()
profile = webdriver.FirefoxProfile()
log_path = '/tmp/tests.log'
self.driver = webdriver.Firefox(profile, log_path=log_path)
def test_abc(self):
blah
When I run this on a headless server with:
python manage.py test functional_tests --nomigrations --failfast
it almost immediately errors with:
ERROR: test_abc (myproject.functional_tests.tests.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/myproject/src/buildbot/worker3/myproject_runtests/build/src/myproject/functional_tests/tests.py", line 15, in setUp
self.driver = webdriver.Firefox(profile, log_path=log_path)
File "/usr/local/myproject/src/buildbot/worker3/myproject_runtests/build/.env/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 158, in __init__
keep_alive=True)
File "/usr/local/myproject/src/buildbot/worker3/myproject_runtests/build/.env/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/local/myproject/src/buildbot/worker3/myproject_runtests/build/.env/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/myproject/src/buildbot/worker3/myproject_runtests/build/.env/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "/usr/local/myproject/src/buildbot/worker3/myproject_runtests/build/.env/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: Process unexpectedly closed with status: 1
So webdriver
is having trouble initializing a Firefox instance. However, the log file only shows:
1528498122788 geckodriver INFO geckodriver 0.19.0
1528498122799 geckodriver INFO Listening on 127.0.0.1:39255
1528498123950 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.LrTWF7H6fk2y"
My versions are:
Ubuntu Version is 16.04
Selenium Version is 3.8.1
Geckodriver Version is 0.19.0
Firefox Version is 58.0.1
I tried upgrading to the most recent Selenium 3.12, Geckodriver 0.20.1, and Firefox 60, but I get the exact same error.
I also tried running all system package upgrades, and rebooting, but that had no effect.
How do I fix this, or at least get a better error message about why Firefox is crashing?
Edit: This is not the same as this question, which returns a very different error message. It's solution does not resolve my error.