2020-05-28 22:45:56 +00:00
|
|
|
"""test default login flow"""
|
|
|
|
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
|
|
|
from selenium import webdriver
|
|
|
|
from selenium.webdriver.common.by import By
|
|
|
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
|
|
|
from selenium.webdriver.common.keys import Keys
|
2020-06-19 17:34:27 +00:00
|
|
|
|
2020-06-07 17:30:56 +00:00
|
|
|
from e2e.utils import apply_default_data
|
2020-05-28 22:45:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestLogin(StaticLiveServerTestCase):
|
|
|
|
"""test default login flow"""
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
self.driver = webdriver.Remote(
|
2020-06-19 16:19:20 +00:00
|
|
|
command_executor="http://localhost:4444/wd/hub",
|
2020-05-28 22:45:56 +00:00
|
|
|
desired_capabilities=DesiredCapabilities.CHROME,
|
|
|
|
)
|
2020-06-07 17:30:56 +00:00
|
|
|
self.driver.implicitly_wait(5)
|
|
|
|
apply_default_data()
|
2020-05-28 22:45:56 +00:00
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
super().tearDown()
|
|
|
|
self.driver.quit()
|
|
|
|
|
|
|
|
def test_login(self):
|
|
|
|
"""test default login flow"""
|
2020-06-19 17:34:27 +00:00
|
|
|
self.driver.get(f"{self.live_server_url}/flows/default-authentication-flow/")
|
2020-05-28 22:45:56 +00:00
|
|
|
self.driver.find_element(By.ID, "id_uid_field").click()
|
2020-06-07 17:30:56 +00:00
|
|
|
self.driver.find_element(By.ID, "id_uid_field").send_keys("pbadmin")
|
2020-05-28 22:45:56 +00:00
|
|
|
self.driver.find_element(By.ID, "id_uid_field").send_keys(Keys.ENTER)
|
2020-06-07 17:30:56 +00:00
|
|
|
self.driver.find_element(By.ID, "id_password").send_keys("pbadmin")
|
2020-05-28 22:45:56 +00:00
|
|
|
self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER)
|
|
|
|
self.assertEqual(
|
|
|
|
self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").text,
|
|
|
|
"pbadmin",
|
|
|
|
)
|