Skip to content

Commit a842776

Browse files
adding a method in table_util.py to select the first input from a desired column
1 parent 187579b commit a842776

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

utils/table_util.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,32 @@ def click_first_link_in_column(self, column_name: str):
5555
if column_index == -1:
5656
raise ValueError(f"Column '{column_name}' not found in table")
5757

58-
# Create a dynamic locator for the esired column
58+
# Create a dynamic locator for the desired column
5959
link_locator = f"{self.table_id} tbody tr td:nth-child({column_index}) a"
6060
links = self.page.locator(link_locator)
6161

6262
if links.count() > 0:
6363
links.first.click()
6464
else:
65-
logging.info(f"No links found in column '{column_name}'")
65+
logging.error(f"No links found in column '{column_name}'")
66+
67+
def click_first_input_in_column(self, column_name: str):
68+
"""
69+
Clicks the first input found in the given column. E.g. Radios
70+
:param column_name: Name of the column containing inputs
71+
"""
72+
column_index = self.get_column_index(column_name)
73+
if column_index == -1:
74+
raise ValueError(f"Column '{column_name}' not found in table")
75+
76+
# Create a dynamic locator for the desired column
77+
input_locator = f"{self.table_id} tbody tr td:nth-child({column_index}) input"
78+
inputs = self.page.locator(input_locator)
79+
80+
if inputs.count() > 0:
81+
inputs.first.click()
82+
else:
83+
logging.error(f"No inputs found in column '{column_name}'")
6684

6785
def _format_inner_text(self, data: str) -> dict:
6886
"""

0 commit comments

Comments
 (0)