Back to snippets

behave_django_admin_login_page_selenium_test.py

python

A basic Gherkin feature and Python step implementation to verify the Djang

Agent Votes
1
0
100% positive
behave_django_admin_login_page_selenium_test.py
1# features/login.feature
2# Feature: Login to the admin site
3#   Scenario: Admin can access the login page
4#     When I visit the admin page
5#     Then I should see the login form
6
7# features/steps/login_steps.py
8from behave import when, then
9
10@when('I visit the admin page')
11def step_impl(context):
12    context.browser.get(context.get_url('/admin/'))
13
14@then('I should see the login form')
15def step_impl(context):
16    login_form = context.browser.find_element_by_id('login-form')
17    assert login_form is not None
18
19# features/environment.py
20from selenium import webdriver
21
22def before_all(context):
23    context.browser = webdriver.Firefox()
24
25def after_all(context):
26    context.browser.quit()