|
| 1 | +from math import e |
1 | 2 | from playwright.sync_api import Page, expect, Locator |
2 | 3 | import logging |
3 | 4 |
|
@@ -144,21 +145,28 @@ def go_to_screening_subject_search_page(self) -> None: |
144 | 145 | self.click(self.screening_subject_search_page) |
145 | 146 |
|
146 | 147 | def click(self, locator: Locator) -> None: |
| 148 | + #Alerts table locator |
| 149 | + alerts_table = locator.get_by_role("table", name="cockpitalertbox") |
147 | 150 | """ |
148 | 151 | This is used to click on a locator |
149 | 152 | The reason for this being used over the normal playwright click method is due to: |
150 | 153 | - BCSS sometimes takes a while to render and so the normal click function 'clicks' on a locator before its available |
151 | 154 | - Increases the reliability of clicks to avoid issues with the normal click method |
152 | 155 | """ |
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