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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77081dac0b1709cceb4176fce8cbadf6f3a3165e5b4dac13125aff2f035338e7 |
|
MD5 | 2e2f0bb9e0a0cdc751d1f9a7b6d83789 |
|
BLAKE2b-256 | 4dfcae254a211821106bf93a0ef2c437b54de2a86f18ee5a8415a1625a6b5f42 |
Hashes for django_selenium_login-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46ea9db7a7d66ae5aea6003c6ec3ef991951a716bbacf926ab0bdcfe4dc0effc |
|
MD5 | f6609eb4175fad712ca35921957420bd |
|
BLAKE2b-256 | de1b72b2d523ebc517080e1878404a4b7efe96ae008de5a3f6025e3e63505a96 |
Hashes for django_selenium_login-1.0.0-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 150cc5f0a45b883eae5a60fb469ff0b3b8e00d471d3ceccfe63aface51e32832 |
|
MD5 | 9565298457652c2d3ee7fdba80ac2ea3 |
|
BLAKE2b-256 | af0c7d6d6fc496b054899882c449320c8cb853a690620c3bc6fe120366a94a42 |