@@ -36,7 +36,7 @@ def __init__(self, page: Page):
3636 self .organisations_page = self .page .get_by_role ("link" , name = "Organisations" )
3737 self .reports_page = self .page .get_by_role ("link" , name = "Reports" )
3838 self .screening_practitioner_appointments_page = self .page .get_by_role (
39- "link" , name = "Screening Practitioner"
39+ "link" , name = "Screening Practitioner Appointments "
4040 )
4141 self .screening_subject_search_page = self .page .get_by_role (
4242 "link" , name = "Screening Subject Search"
@@ -51,10 +51,8 @@ def __init__(self, page: Page):
5151 self .main_menu__header = self .page .locator ("#ntshPageTitle" )
5252
5353 def click_main_menu_link (self ) -> None :
54- for _ in range (3 ): # Try up to 3 times
55- if self .main_menu_link .is_visible ():
56- self .click (self .main_menu_link )
57- return # Exit if successful
54+ if self .main_menu_link .is_visible ():
55+ self .click (self .main_menu_link )
5856
5957 def click_log_out_link (self ) -> None :
6058 self .click (self .log_out_link )
@@ -144,15 +142,22 @@ def go_to_screening_subject_search_page(self) -> None:
144142 self .click (self .screening_subject_search_page )
145143
146144 def click (self , locator : Locator ) -> None :
145+ # Alerts table locator
146+ alerts_table = locator .get_by_role ("table" , name = "cockpitalertbox" )
147147 """
148148 This is used to click on a locator
149149 The reason for this being used over the normal playwright click method is due to:
150150 - BCSS sometimes takes a while to render and so the normal click function 'clicks' on a locator before its available
151151 - Increases the reliability of clicks to avoid issues with the normal click method
152152 """
153+ if alerts_table .is_visible ():
154+ alerts_table .wait_for (state = "attached" )
155+ alerts_table .wait_for (state = "visible" )
156+
153157 try :
154158 self .page .wait_for_load_state ("load" )
155159 self .page .wait_for_load_state ("domcontentloaded" )
160+ self .page .wait_for_load_state ("networkidle" )
156161 locator .wait_for (state = "attached" )
157162 locator .wait_for (state = "visible" )
158163 locator .click ()
0 commit comments