From c1b2093cf777824aeaa643524806afaa54f0afac Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 26 Jun 2020 16:21:59 +0200 Subject: [PATCH] e2e: add utility to wait for URL --- e2e/test_enroll.py | 1 + e2e/utils.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/e2e/test_enroll.py b/e2e/test_enroll.py index 800fac47f..38935bc94 100644 --- a/e2e/test_enroll.py +++ b/e2e/test_enroll.py @@ -345,6 +345,7 @@ class TestEnroll(SeleniumTestCase): self.wait.until(ec.presence_of_element_located((By.LINK_TEXT, "foo"))) self.driver.find_element(By.LINK_TEXT, "foo").click() + self.wait_for_url(self.url("passbook_core:user-settings")) self.assertEqual( self.driver.find_element(By.XPATH, "//a[contains(@href, '/-/user/')]").text, "foo", diff --git a/e2e/utils.py b/e2e/utils.py index 56ccc692a..f153c9e6f 100644 --- a/e2e/utils.py +++ b/e2e/utils.py @@ -66,6 +66,10 @@ class SeleniumTestCase(StaticLiveServerTestCase): self.driver.quit() super().tearDown() + def wait_for_url(self, desired_url): + """Wait until URL is `desired_url`.""" + self.wait.until(lambda driver: driver.current_url == desired_url) + def url(self, view, **kwargs) -> str: """reverse `view` with `**kwargs` into full URL using live_server_url""" return self.live_server_url + reverse(view, kwargs=kwargs)