From 3a51bcd890739fa0e24707b3305e8cf3b419f4dc Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 12 Nov 2021 09:37:05 +0100 Subject: [PATCH] tests/e2e: add retry for webdriver init Signed-off-by: Jens Langhammer --- tests/e2e/utils.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/e2e/utils.py b/tests/e2e/utils.py index e548d4398..7535c3ed5 100644 --- a/tests/e2e/utils.py +++ b/tests/e2e/utils.py @@ -106,10 +106,16 @@ class SeleniumTestCase(StaticLiveServerTestCase): return None def _get_driver(self) -> WebDriver: - return webdriver.Remote( - command_executor="http://localhost:4444/wd/hub", - desired_capabilities=DesiredCapabilities.CHROME, - ) + count = 0 + while count < RETRIES: + try: + return webdriver.Remote( + command_executor="http://localhost:4444/wd/hub", + desired_capabilities=DesiredCapabilities.CHROME, + ) + except WebDriverException: + count += 1 + raise ValueError(f"Webdriver failed after {RETRIES}.") def tearDown(self): if "TF_BUILD" in environ: