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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2a6608a9086c0435c4a34a4e206993619bcfab4ac8b19ff752a78626282ec89 |
|
MD5 | cb87c01c7c1770384de21539ecf57b1d |
|
BLAKE2b-256 | 13a3ede664ba6f4805968086a72118354fc9fcd3775ed3977a0ea17e2417b7cc |
Hashes for django_selenium_login-1.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15029a4d5a4b6d7ac1bb2f52cf8c8cf9d332a88127978f20ffba14e8ee0d988a |
|
MD5 | 1de9b360a5bff05e8496a837cfb73940 |
|
BLAKE2b-256 | 494c4186a16383cc553f0ce358cbb285c37f87a55aa4d7327978a5733608fc6c |
Hashes for django_selenium_login-1.0.2-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | e56924f584968dee0200d87bf2e226959afa504c7ea23b14c23e8b2cafcff349 |
|
MD5 | 7a11dc57d0c66b2a33181b1f73a2e628 |
|
BLAKE2b-256 | ddb7710c40913062b1098d08f51d69fa66a748bdf790620a27d12f971b1cbf89 |