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.
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-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe9ecd34402b665c5e1879c18d75d1ebffc2b8c6477a08f874c0127bc6ccb05e |
|
MD5 | 8b1c81e9b349bf3c7163345560c43b0e |
|
BLAKE2b-256 | 1febad9b83dc215e32dabb229b74b5073f1acdbba3664af4e872eb6187f9d000 |
Hashes for django_selenium_login-0.1.0-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | b110c02bea96a75b9da6d2d71e4081da3fc954b29ac67055eb4a664ced05e0d5 |
|
MD5 | cfdb9edc836f5136cb4b7bf34647739c |
|
BLAKE2b-256 | ba22a99d483bcbf8da656b72eb75263812667a6f504b8095a180f93ed00387dc |
Hashes for django_selenium_login-0.1.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60c2fa7d1dc1ef7b1e49ae2bb5a36d5f42864c793f4842291fa5c6db45550866 |
|
MD5 | 43c32095693836137b91e33f394bc481 |
|
BLAKE2b-256 | 97d888f8e62ea78ffe342fa48dba997093e8eb6d7c859f83e472abd50ced74a0 |