Skip to content

Commit c06f413

Browse files
committed
Updated click function to wait for the alerts table to load.
1 parent a028215 commit c06f413

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

pages/base_page.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from math import e
12
from playwright.sync_api import Page, expect, Locator
23
import logging
34

@@ -144,21 +145,28 @@ def go_to_screening_subject_search_page(self) -> None:
144145
self.click(self.screening_subject_search_page)
145146

146147
def click(self, locator: Locator) -> None:
148+
#Alerts table locator
149+
alerts_table = locator.get_by_role("table", name="cockpitalertbox")
147150
"""
148151
This is used to click on a locator
149152
The reason for this being used over the normal playwright click method is due to:
150153
- BCSS sometimes takes a while to render and so the normal click function 'clicks' on a locator before its available
151154
- Increases the reliability of clicks to avoid issues with the normal click method
152155
"""
153-
try:
154-
self.page.wait_for_load_state("load")
155-
self.page.wait_for_load_state("domcontentloaded")
156-
locator.wait_for(state="attached")
157-
locator.wait_for(state="visible")
158-
locator.click()
159-
160-
except Exception as locatorClickError:
161-
logging.warning(
162-
f"Failed to click element with error: {locatorClickError}, trying again..."
163-
)
164-
locator.click()
156+
if alerts_table.is_visible():
157+
alerts_table.wait_for(state="attached")
158+
alerts_table.wait_for(state="visible")
159+
else:
160+
try:
161+
self.page.wait_for_load_state("load")
162+
self.page.wait_for_load_state("domcontentloaded")
163+
self.page.wait_for_load_state("networkidle")
164+
locator.wait_for(state="attached")
165+
locator.wait_for(state="visible")
166+
locator.click()
167+
168+
except Exception as locatorClickError:
169+
logging.warning(
170+
f"Failed to click element with error: {locatorClickError}, trying again..."
171+
)
172+
locator.click()

0 commit comments

Comments
 (0)