Skip to content

Commit

Permalink
Retry 5 times if login fails in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikek committed Dec 2, 2024
1 parent e8e7ec4 commit fadd350
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions ESSArch_Core/frontend/tests/test_login.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from time import sleep

from django.contrib.auth import get_user_model
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support import expected_conditions as EC
Expand All @@ -25,12 +23,15 @@ def test_login(self):

old_url = self.selenium.current_url
self.selenium.find_element("xpath", '//button[@type="submit"]').click()
try:
sleep(1)
WebDriverWait(self.selenium, 15).until(EC.title_is('Info | ESSArch'))
except TimeoutException:
sleep(30)
WebDriverWait(self.selenium, 15).until(EC.title_is('Info | ESSArch'))

max_attempts = 5
for _ in range(max_attempts):
try:
WebDriverWait(self.selenium, 10).until(EC.title_is('Info | ESSArch'))
break # Exit the loop if successful
except TimeoutException:
continue # Retry if a timeout occurs

self.assertTrue(EC.url_changes(old_url))

# logout
Expand Down

0 comments on commit fadd350

Please sign in to comment.