Skip to content

Commit 323bc06

Browse files
Altering method to raise an error if main menu is not clicking within defined loops
1 parent f4a8ce3 commit 323bc06

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pages/base_page.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def __init__(self, page: Page):
5757
def click_main_menu_link(self) -> None:
5858
"""Click the Base Page 'Main Menu' link if it is visible."""
5959
loops = 0
60+
text = None
61+
6062
while loops <= 3:
6163
if self.main_menu_link.is_visible():
6264
self.click(self.main_menu_link)
@@ -70,13 +72,17 @@ def click_main_menu_link(self) -> None:
7072
text = None
7173

7274
if text and self.main_menu_string in text:
73-
break
75+
return # Success
7476
else:
7577
logging.warning("Main Menu click failed, retrying after 0.2 seconds")
7678
# The timeout is in place here to allow the page ample time to load if it has not already been loaded
7779
self.page.wait_for_timeout(200)
7880

7981
loops += 1
82+
# All attempts failed
83+
raise RuntimeError(
84+
f"Failed to navigate to Main Menu after {loops} attempts. Last page title was: '{text or 'unknown'}'"
85+
)
8086

8187
def click_log_out_link(self) -> None:
8288
"""Click the Base Page 'Log-out' link."""

0 commit comments

Comments
 (0)