@@ -101,7 +101,6 @@ def enter_type_filter(self, option_text: str) -> None:
101101 self .type_filter .select_option (label = option_text )
102102 logging .info (f"[FILTER] Type filter set to '{ option_text } '" )
103103
104-
105104 def enter_original_filter (self , search_text : str ) -> None :
106105 self .original_filter .fill (search_text )
107106 self .original_filter .press ("Enter" )
@@ -200,19 +199,19 @@ def get_open_original_batch_row(self) -> Locator | None:
200199 Returns:
201200 Locator of the matching <tr> element, or None if not found.
202201 """
203- rows = self .page .locator (f"{ self .table_selector } tbody tr" )
204- for i in range (rows .count ()):
205- row = rows .nth (i )
206- type_cell = row .locator ("td" ).nth (1 ) # Assuming Type is 2nd column
207- status_cell = row .locator ("td" ).nth (8 ) # Assuming Status is 9th column
202+ table = TableUtils (self .page , "table#batchList" )
203+ row_count = table .get_row_count ()
208204
205+ for i in range (row_count ):
206+ row_data = table .get_row_data_with_headers (i )
209207 if (
210- "Original" in type_cell . inner_text ()
211- and "Open" in status_cell . inner_text ()
208+ row_data . get ( "Type" , "" ). strip () == "Original"
209+ and row_data . get ( "Status" , "" ). strip () == "Open"
212210 ):
213- return row
211+ return table . pick_row ( i )
214212 return None
215213
214+
216215 def assert_s83f_batch_present (self ) -> None :
217216 self .enter_type_filter ("Original" )
218217 self .enter_event_code_filter ("S83" )
@@ -232,9 +231,8 @@ def __init__(self, page: Page):
232231
233232 def select_first_archived_batch (self ) -> None :
234233 """Clicks the first batch ID link in the archived batch list."""
235- first_batch_link = self .page .locator (
236- f"{ self .table_selector } tbody tr td.id a"
237- ).first
234+ first_batch_link = self .page .locator ("table#batchList tbody tr td.id a" ).first
235+ first_batch_link .wait_for (timeout = 10000 )
238236 assert first_batch_link .count () > 0 , "No archived batch links found"
239237 first_batch_link .click ()
240238
@@ -310,8 +308,9 @@ def assert_letter_component_present(self, letter_type: str, format: str) -> None
310308 match_found = True
311309 break
312310
313- assert match_found , f"Letter type '{ letter_type } ' with format '{ format } ' not found"
314-
311+ assert (
312+ match_found
313+ ), f"Letter type '{ letter_type } ' with format '{ format } ' not found"
315314
316315 def get_first_subject_nhs_number (self ) -> str :
317316 """
@@ -322,11 +321,12 @@ def get_first_subject_nhs_number(self) -> str:
322321 """
323322 table_utils = TableUtils (self .page , "table#letterBatchDetails" )
324323 row_data = table_utils .get_row_data_with_headers (0 ) # First row (0-based index)
325-
324+
326325 nhs_number = row_data .get ("NHS Number" )
327326 if not nhs_number :
328- raise RuntimeError ("NHS Number not found in the first row of the letter batch table" )
327+ raise RuntimeError (
328+ "NHS Number not found in the first row of the letter batch table"
329+ )
329330
330331 logging .info (f"Retrieved NHS number from batch: { nhs_number } " )
331332 return nhs_number
332-
0 commit comments