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.
Usage
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)
selenium.get('{}/a/url/which/requires/login/'.format(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.
Installation
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:
./run_tests.sh
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for django-selenium-login-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a1812d458a839e8823bf02838df4db18ce811a2778b88880539c5bc1cfce7bd |
|
MD5 | 9321c7b2dc362c7c0de7695a9aacccf2 |
|
BLAKE2b-256 | a1873532d4530f52f57ed1a46d19990be717501448a6c480190a78a9cd4abcd4 |
Hashes for django_selenium_login-1.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dd387bec3aaf19d7f2bf10eeeff77dcce9eb410964beffa579a49e5d18e8fb5 |
|
MD5 | 255cffd736a276108f37c67218914164 |
|
BLAKE2b-256 | d645e8c3eb60efa96b25c88e486223bec9e3920578a0a74949f3df5839748b58 |
Hashes for django_selenium_login-1.0.1-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65fe9687f91c3a495f1676e0cbecade4c0939356bb1c32aa652d8d02838bed6d |
|
MD5 | 3c589c6f0602d45cacec72cd308fbbed |
|
BLAKE2b-256 | 08e53e3f58604107d1b4b7186294ce2eaf0d96331f421a0ddbab725e6a50f4e6 |