1- from playwright .sync_api import Page , expect
1+ from playwright .sync_api import Page , expect , Locator
22from pages .base_page import BasePage
33
44
@@ -24,20 +24,36 @@ def __init__(self, page: Page):
2424 self .add_link = self .page .get_by_role ("link" , name = "Add" )
2525
2626 def click_add_link (self ) -> None :
27- """Clicks on the 'Add' link on the Subject Datasets Page."""
28- self .click (self .add_link )
27+ """Clicks on the first 'Add' link on the Subject Datasets Page."""
28+ self .click (self .add_link . first )
2929
3030 def click_colonoscopy_show_datasets (self ) -> None :
31- """Clicks on the 'Show Dataset' button for the Colonoscopy Assessment row on the Subject Datasets Page."""
32- self .click (self .colonoscopy_show_dataset_button )
31+ """
32+ Clicks on the 'Show Dataset(s)' button for the Colonoscopy Assessment row on the Subject Datasets Page.
33+ If the button text is "Show Datasets", also clicks the first 'Add' link.
34+ """
35+ # Find the DatasetHeader div with Investigation
36+ header = self .page .locator (
37+ "div.DatasetHeader h4:has-text('Colonoscopy Assessment')"
38+ )
39+ self .click_show_datasets_button (header )
3340
3441 def click_investigation_show_datasets (self ) -> None :
3542 """
3643 Clicks on the 'Show Dataset(s)' link for the Investigation row on the Subject Datasets Page.
37- If the button text is "Show Datasets", also clicks the 'Add' link.
44+ If the button text is "Show Datasets", also clicks the first 'Add' link.
3845 """
3946 # Find the DatasetHeader div with Investigation
4047 header = self .page .locator ("div.DatasetHeader h4:has-text('Investigation')" )
48+ self .click_show_datasets_button (header )
49+
50+ def click_show_datasets_button (self , header : Locator ) -> None :
51+ """
52+ Clicks on the 'Show Dataset(s)' link for the specified header.
53+ If the button text is "Show Datasets", also clicks the first 'Add' link.
54+ Args:
55+ header (Locator): The Locator for the DatasetHeader h4 element.
56+ """
4157 header .wait_for (state = "visible" , timeout = 10000 )
4258 # Get the dataset count text from the span inside the h4
4359 dataset_count_text = header .locator ("span.DatasetSubLabel" ).text_content ()
@@ -49,7 +65,7 @@ def click_investigation_show_datasets(self) -> None:
4965 show_link .wait_for (state = "visible" , timeout = 10000 )
5066 self .click (show_link )
5167 # If plural, also click Add
52- if dataset_count_text and "2 Datasets" in dataset_count_text :
68+ if dataset_count_text and "Datasets" in dataset_count_text :
5369 self .click_add_link ()
5470
5571 def check_investigation_dataset_complete (self ) -> None :
0 commit comments