@@ -25,6 +25,8 @@ def __init__(self, page: Page, table_locator: str) -> None:
2525 table_locator
2626 ) # Create a locator object for the table
2727
28+ self .tbody_tr_string = "tbody tr"
29+
2830 def get_column_index (self , column_name : str ) -> int :
2931 """
3032 Finds the column index dynamically based on column name.
@@ -41,7 +43,9 @@ def get_column_index(self, column_name: str) -> int:
4143 if not header_row .locator ("th" ).count ():
4244 # Fallback: look for header in <tbody> if <thead> is missing or empty
4345 header_row = (
44- self .table .locator ("tbody tr" ).filter (has = self .page .locator ("th" )).first
46+ self .table .locator (self .tbody_tr_string )
47+ .filter (has = self .page .locator ("th" ))
48+ .first
4549 )
4650
4751 headers = header_row .locator ("th" )
@@ -163,7 +167,9 @@ def get_table_headers(self) -> dict:
163167
164168 # Strategy 3: Last resort — try to find header from tbody row (some old tables use <tbody> only)
165169 fallback_row = (
166- self .table .locator ("tbody tr" ).filter (has = self .page .locator ("th" )).first
170+ self .table .locator (self .tbody_tr_string )
171+ .filter (has = self .page .locator ("th" ))
172+ .first
167173 )
168174 if fallback_row .locator ("th" ).count ():
169175 try :
@@ -372,7 +378,7 @@ def click_surname_if_bcss_user_and_has_code(self):
372378 if - 1 in (surname_col , user_code_col , bcss_col ):
373379 raise ValueError ("One or more required columns not found" )
374380
375- rows = self .table .locator ("tbody tr" )
381+ rows = self .table .locator (self . tbody_tr_string )
376382
377383 for i in range (rows .count ()):
378384 row = rows .nth (i )
0 commit comments