e2e: cleanup, always take screenshots on teardown

This commit is contained in:
Jens Langhammer 2020-06-21 15:09:01 +02:00
parent 0838f518d4
commit 1b3c0adf75
3 changed files with 10 additions and 13 deletions

View file

@ -141,7 +141,9 @@ class TestEnroll2Step(SeleniumTestCase):
self.driver.find_element(By.ID, "id_name").send_keys(
"policy-enrollment-password-equals"
)
self.wait.until(ec.presence_of_element_located((By.CSS_SELECTOR, ".CodeMirror-scroll")))
self.wait.until(
ec.presence_of_element_located((By.CSS_SELECTOR, ".CodeMirror-scroll"))
)
self.driver.find_element(By.CSS_SELECTOR, ".CodeMirror-scroll").click()
self.driver.find_element(By.CSS_SELECTOR, ".CodeMirror textarea").send_keys(
"return request.context['password'] == request.context['password_repeat']"
@ -264,32 +266,28 @@ class TestEnroll2Step(SeleniumTestCase):
# Create Stage binding for user login stage
self.driver.find_element(By.LINK_TEXT, "Create").click()
self.driver.find_element(By.ID, "id_flow").click()
dropdown = self.driver.find_element(By.ID, "id_flow")
dropdown.find_element(
By.XPATH, '//option[. = "Flow Welcome (default-enrollment-flow)"]'
).click()
self.driver.find_element(By.ID, "id_stage").click()
dropdown = self.driver.find_element(By.ID, "id_stage")
dropdown.find_element(
By.XPATH, '//option[. = "Stage enroll-user-login"]'
).click()
self.driver.find_element(By.ID, "id_order").click()
self.driver.find_element(By.ID, "id_order").send_keys("3")
self.driver.find_element(
By.CSS_SELECTOR, ".pf-c-form__actions > .pf-m-primary"
).click()
self.driver.find_element(
By.CSS_SELECTOR, "#page-default-nav-example div.pf-m-icons > a"
).click()
self.driver.find_element(By.CSS_SELECTOR, "[aria-label=logout]").click()
def test_enroll_2_step(self):
"""Test 2-step enroll flow"""
self.driver.get(self.live_server_url)
self.setup_test_enroll_2_step()
self.driver.get(self.live_server_url)
self.wait.until(ec.presence_of_element_located((By.CSS_SELECTOR, "[role=enroll]")))
self.wait.until(
ec.presence_of_element_located((By.CSS_SELECTOR, "[role=enroll]"))
)
self.driver.find_element(By.CSS_SELECTOR, "[role=enroll]").click()
self.driver.find_element(By.ID, "id_username").send_keys("foo")

View file

@ -1,9 +1,9 @@
"""passbook e2e testing utilities"""
from functools import lru_cache
from os import makedirs
from glob import glob
from importlib.util import module_from_spec, spec_from_file_location
from inspect import getmembers, isfunction
from os import makedirs
from Cryptodome.PublicKey import RSA
from django.apps import apps
@ -55,8 +55,7 @@ class SeleniumTestCase(StaticLiveServerTestCase):
)
def tearDown(self):
if self.failureException:
self.driver.save_screenshot("out/{self.__class__.__name__}.png")
self.driver.save_screenshot(f"out/{self.__class__.__name__}.png")
self.driver.quit()
super().tearDown()

View file

@ -40,7 +40,7 @@
</div>
<div class="pf-c-page__header-tools">
<div class="pf-c-page__header-tools-group pf-m-icons">
<a href="{% url 'passbook_flows:default-invalidation' %}" class="pf-c-button pf-m-plain" type="button">
<a href="{% url 'passbook_flows:default-invalidation' %}" class="pf-c-button pf-m-plain" type="button" aria-label="logout">
<i class="fas fa-sign-out-alt" aria-hidden="true"></i>
</a>
</div>