Skip to content

Commit d99552f

Browse files
Feature/bcss 22016 surveillanceregressiontests scenario 4 (#158)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> Migrating scenario 4 of SurveillanceRegressionTests from selenium to playwright. ## Context <!-- Why is this change required? What problem does it solve? --> Migrating scenario 4 of SurveillanceRegressionTests from selenium to playwright. ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [x] I have followed the code style of the project - [x] I have added tests to cover my changes (where appropriate) - [x] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
1 parent cee24b5 commit d99552f

File tree

3 files changed

+495
-7
lines changed

3 files changed

+495
-7
lines changed

pages/datasets/subject_datasets_page.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from playwright.sync_api import Page, expect
1+
from playwright.sync_api import Page, expect, Locator
22
from 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 Colonoscopy Assessment
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:

pages/screening_subject_search/advance_surveillance_episode_page.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ def __init__(self, page: Page):
2121
name="Discharge from Screening and Surveillance - Clinical Decision",
2222
)
2323
)
24+
self.discharge_from_screening_and_surveillance_patient_choice_button = (
25+
self.page.get_by_role(
26+
"button",
27+
name="Discharge from Screening and Surveillance - Patient Choice",
28+
)
29+
)
30+
2431
self.book_surveillance_appointment_button = self.page.get_by_role(
2532
"button", name="Book Surveillance Appointment"
2633
)
@@ -41,6 +48,12 @@ def click_discharge_from_screening_and_surveillance_clinical_decision_button(
4148
self.discharge_from_screening_and_surveillance_clinical_decision_button
4249
)
4350

51+
def click_discharge_from_screening_and_surveillance_patient_choice_button(
52+
self,
53+
) -> None:
54+
"""Click on the 'Discharge from Screening and Surveillance - Patient Choice' button."""
55+
self.click(self.discharge_from_screening_and_surveillance_patient_choice_button)
56+
4457
def click_book_surveillance_appointment_button(self) -> None:
4558
"""Click on the 'Book Surveillance Appointment' button."""
4659
self.safe_accept_dialog(self.book_surveillance_appointment_button)

0 commit comments

Comments
 (0)