![Show Menu](styles/mobile-menu.png)
![Page Background](./../common/page-substrates/page0400.png)
2. At the time of writing, the latest Selenium (2.41) was causing me
some trouble ,so that’s why I’m pinning it
to 2.39 here. By all means experiment with newer versions!
Destroying test database for alias 'default'...
+ python manage.py test functional_tests
ImportError: No module named 'selenium'
Build step 'Virtualenv Builder' marked build as failure
Ah. We need Selenium in our virtualenv.
Let’s add a manual installation of Selenium to our build steps:
2
pip install -r requirements.txt
pip install selenium==2.39
python manage.py test accounts lists
python manage.py test functional_tests
Some people like to use a file called
test-requirements.txt
to
specify packages that are needed for the tests, but not the
main app.
Now what?
File
"/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.
line 100, in _wait_until_connectable
self._get_firefox_output())
selenium.common.exceptions.WebDriverException: Message: 'The browser appears to
have exited before we could connect. The output was: b"\\n(process:19757):
GLib-CRITICAL **: g_slice_set_config: assertion \'sys_page_size == 0\'
failed\\nError: no display specified\\n"'
Setting Up a Virtual Display so the FTs Can Run Headless
As you can see from the traceback, Firefox is unable to start because the server doesn’t
have a display.
There are two ways to deal with this problem. The first is to switch to using a headless
browser, like PhantomJS or SlimerJS. Those tools definitely have their place—they’re
faster, for one thing—but they also have disadvantages. The first is that they’re not “real”
web browsers, so you can’t be sure you’re going to catch all the strange quirks and
behaviours of the actual browsers your users use. The second is that they behave quite
differently inside Selenium, and will require substantial amounts of rewriting of FT
code.
372
|
Chapter 20: Continuous Integration (CI)