Install dependencies:

This code uses selenium and xvfbwrapper to run tests with Firefox inside a headless display.

from django.test import LiveServerTestCase
from selenium.webdriver.firefox.webdriver import WebDriver
from xvfbwrapper import Xvfb

class SeleniumTestCase(LiveServerTestCase):

    @classmethod
    def setUpClass(cls):
        cls.xvfb = Xvfb(width=1280, height=720)
        cls.xvfb.start()
        cls.wd = WebDriver()
        super(SeleniumTestCase, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        cls.wd.quit()
        super(SeleniumTestCase, cls).tearDownClass()
        cls.xvfb.stop()