Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Helpers for creating functional tests in Django, with a unified API for WebTest and Selenium tests.

Project description


.. image::

.. image::

.. image::

Helpers for creating high-level functional tests in Django, with a unified API
for WebTest and Selenium tests.


The full documentation is at



pip install django-functest

See also the `dependencies documentation
for important compatibility information.


* A simplified API for writing functional tests in Django (tests that check the
behaviour of entire views, or sets of views, e.g. a checkout process).

* A unified API that abstracts over both `WebTest
<>`_ and `Selenium
<>`_ - write two tests at once!

* Many of the gotchas and difficulties of using WebTest and Selenium ironed out
for you.

* Well tested - as well as its own test suite, which is run against Firefox
and Chrome, it is also used by `Wolf & Badger
<>`_ for tests covering many business critical

Typical usage

In your

from django.test import LiveServerTestCase, TestCase
from django_functest import FuncWebTestMixin, FuncSeleniumMixin, FuncBaseMixin

class ContactTestBase(FuncBaseMixin):
# Abstract class, doesn't inherit from TestCase

def test_contact_form(self):
self.fill({'#id_name': 'Joe',
'#id_message': 'Hello'})
self.assertTextPresent("Thanks for your message")

class ContactWebTest(ContactTestBase, FuncWebTestMixin, TestCase):

class ContactSeleniumTest(ContactTestBase, FuncSeleniumMixin, LiveServerTestCase):

In this way, you can write a single test with a high-level API, and run it in
two ways - using a fast, WSGI-based method which emulates typical HTTP usage of a
browser, and using a full browser that actually executes Javascript (if present)

Under the hood, the WSGI-based method uses and builds upon `WebTest
<>`_ and `django-webtest

django-functest provides its functionality as mixins, so that you can have your
own base class for tests.

Contributing and tests

See CONTRIBUTING.rst for information about running the test suite and
contributing to django-functest.


This library was built by developers at `Wolf & Badger
<>`_, released with the kind permission of that

Tools used in rendering this package:

* Cookiecutter_
* `cookiecutter-djangopackage`_

.. _Cookiecutter:
.. _`cookiecutter-djangopackage`:



* Fixed bug with setting checkboxes if a form with multiple checkboxes of the same name
* Enabled installation on PyPy (doesn't necessarily work completely).
* Test against Django 2.1
* Removed tests and official support for PhantomJS. (No actual functionality
was changed regarding PhantomJS).


* Deprecated ``fill_by_id``. Instead of ``fill_by_id({'foo': 'bar'})`` you
should do ``fill({'#foo': 'bar'})``, because it is shorter and more flexible.
* Test against latest Firefox
* Django 2.0 compatibility
* Fix for Django 1.11.2 and later for MultiThreadedLiveServerMixin


* Fixes to cope with WebTest 2.0.28. We now require django-webtest 1.9.2 or
later, and only test against the latest WebTest.
* Fixed some deprecation warnings


* Fixed incompatibility with django-webtest 1.9.0 and later


* Added Django 1.11 support.
* Dropped official Django 1.7 support (may still work).


* Made :meth:`~django_functest.FuncCommonApi.get_literal_url` accept
absolute URLs for Selenium (WebTest already worked by accident).


* Added :meth:`~django_functest.FuncCommonApi.new_browser_session` and
:meth:`~django_functest.FuncCommonApi.switch_browser_session` to the common
API. These can be used to simulate multiple devices or users accessing the
site. See the docs for important usage information.


* Fix for scrolling to exactly the right place.
* Added docstrings everywhere, and a base class you can inherit from
for the purpose of providing autocomplete help.


* Django 1.10 compatibility


* Fixed performance/reliability issue caused by browsers attempting
to retrieve ``/favicon.ico`` after visiting ``emptypage``.


* Fixed bug where elements wouldn't scroll into view if html height is set to
* New method :meth:`~django_functest.FuncSeleniumMixin.get_webdriver_options`
for customizing WebDriver behaviour.


* Added get_session_data()
* Improved reliability of ``FuncSeleniumMixin.get_literal_url()``
* Allow ``<select>`` elements to be set using integers for values.
* Fixed issues with ``.value()`` for radio buttons and text areas
* Fixed bug with setting radio buttons when there are more than
one set of radio buttons in the form.


* Added support for file uploads


* Support for filling radio buttons
* More convenient support for quotes and apostrophes (" ') in text assertion methods.


* Fixed wheel building - again!


* Fixed packaging bug that caused wheels to fail on Python 3.


* First release on PyPI.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-functest, version 1.0.4
Filename, size File type Python version Upload date Hashes
Filename, size django_functest-1.0.4-cp2-none-any.whl (39.2 kB) File type Wheel Python version cp2 Upload date Hashes View
Filename, size django_functest-1.0.4-cp3-none-any.whl (39.1 kB) File type Wheel Python version cp3 Upload date Hashes View
Filename, size django_functest-1.0.4-pp-none-any.whl (36.9 kB) File type Wheel Python version pp Upload date Hashes View
Filename, size django-functest-1.0.4.tar.gz (51.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page