Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A quick login for selenium tests to be used in Django projects

Project Description

django-selenium-login sets a session cookie for the Selenium driver and a creates a session object for the Django backend in order to force a user to quickly login.


With django-selenium-login you can use the force_login function to force a user to qucikly login before using the the Selenium driver to proceeds on pages that requires login. The function takes a Django user, a Selenium driver, and the base url for the live server. Here is an example of how to use the force_login function in a test:

from seleniumlogin import force_login

def test_use_django_selenium_login_to_force_login(selenium, live_server):
    User = get_user_model()
    user = User.objects.create_user(username='myuser', password='password')
    force_login(user, selenium, live_server.url)

Before setting the session cookie for the Selenium driver, the driver must access a page in the project. By default it will try to access the /page_404/ page. This can be changed by changing the SELENIUM_LOGIN_START_PAGE setting in the settings file for your tests. A blank page is used for the tests in this lib.


Use pip to install django-selenium-login:

pip install django-selenium-login

For developers

Create venv using:

make venv

Run tests for multiple versions of Python and Django for a specific browser using tox:

tox -- --driver=Chrome

Use environment variable SESSION_ENGINE to change authentication backend.

To run tests for all authentication backends for Chrome, Firefox, and PhantomJS:


Release History

This version
History Node


History Node


History Node


History Node


Download Files

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

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(4.1 kB) Copy SHA256 Hash SHA256
2.7 Egg Nov 11, 2016
(6.2 kB) Copy SHA256 Hash SHA256
py2.py3 Wheel Nov 11, 2016
(3.4 kB) Copy SHA256 Hash SHA256
Source Nov 11, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting