While trying to run functional tests in python on an Ubuntu EC2 instance using
python manage.py test functional_tests --liveserver=superlist-staging.tk
I got this error
RuntimeError: Could not find firefox in your system PATH. Please specify the firefox binary location or install firefox
So I did sudo apt-get install firefox
to install firefox.
Afterwards I tried running the tests again and got another error:
WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
The issue is Selenium needs a display and as Linux does not have one , you need to download a virtual display (xvnc/xvfb).
So I installed xfvb
with sudo apt-get install xvfb
Then I ran the tests with xvfb
like this -
xvfb-run python manage.py test functional_tests --liveserver=superlist-staging.tk
I got another error:
WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.
Turns out the reason is a version problem between the selenium server and python library.
I updated selenium with pip install -U selenium
and that resolved the issue.