From 1b3c0adf75c3ab56a8a58abb4a1a9b8ddc3de13f Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 21 Jun 2020 15:09:01 +0200 Subject: [PATCH] e2e: cleanup, always take screenshots on teardown --- e2e/test_enroll_2_step.py | 16 +++++++--------- e2e/utils.py | 5 ++--- passbook/core/templates/base/page.html | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/e2e/test_enroll_2_step.py b/e2e/test_enroll_2_step.py index 712bc39f2..e4e7dbd0f 100644 --- a/e2e/test_enroll_2_step.py +++ b/e2e/test_enroll_2_step.py @@ -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") diff --git a/e2e/utils.py b/e2e/utils.py index 2847d9a59..81acc3739 100644 --- a/e2e/utils.py +++ b/e2e/utils.py @@ -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() diff --git a/passbook/core/templates/base/page.html b/passbook/core/templates/base/page.html index 2a25d2565..f3fea0fd7 100644 --- a/passbook/core/templates/base/page.html +++ b/passbook/core/templates/base/page.html @@ -40,7 +40,7 @@