in pages/desktop/base.py [0:0]
def logged_in(self):
"""Returns True if a user is logged in. Since the user element can become
stale sometimes and causes the login test to fail, a StaleElementReferenceException
was added to catch this error and wait for the element to be located again"""
count = 0
while count < 5:
try:
self.wait.until(
EC.visibility_of_element_located(
(
By.CSS_SELECTOR,
".Header-user-and-external-links .DropdownMenu-button-text",
)
),
message="LOGIN FAILED: The user name was not displayed in the header after login.",
)
break
except StaleElementReferenceException as exception:
print(f"{exception}: Try to find the element again")
count += 1
return self