Skip to content

Commit 98f135f

Browse files
Feature/bcss 20478 c6 pom handover into symptomatic care page (#65)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> Newly created POM for handover into symptomatic care page. ## Context <!-- Why is this change required? What problem does it solve? --> Allows the reusablity of locators across tests. ## 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 - [ ] 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. --------- Co-authored-by: Adriano Aru <[email protected]>
1 parent f87a688 commit 98f135f

File tree

2 files changed

+67
-17
lines changed

2 files changed

+67
-17
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from playwright.sync_api import Page
2+
from pages.base_page import BasePage
3+
from datetime import datetime
4+
5+
class HandoverIntoSymptomaticCarePage(BasePage):
6+
"""
7+
HandoverIntoSymptomaticCarePage class for interacting with the 'Handover Into Symptomatic Care' page elements.
8+
"""
9+
def __init__(self, page: Page):
10+
self.page = page
11+
self.referral_dropdown = self.page.get_by_label("Referral")
12+
self.calendar_button = self.page.get_by_role("button", name="Calendar")
13+
self.consultant_link = self.page.locator("#UI_NS_CONSULTANT_PIO_SELECT_LINK")
14+
self.notes_textbox = self.page.get_by_role("textbox", name="Notes")
15+
self.save_button = self.page.get_by_role("button", name="Save")
16+
17+
def select_referral_dropdown_option(self, value: str) -> None:
18+
"""
19+
Select a given option from the Referral dropdown.
20+
21+
Args:
22+
value (str): The value of the option you want to select
23+
"""
24+
self.referral_dropdown.select_option(value)
25+
26+
def click_calendar_button(self) -> None:
27+
"""Click the calendar button to open the calendar picker."""
28+
self.click(self.calendar_button)
29+
30+
def select_consultant(self, value: str) -> None:
31+
"""
32+
Select a consultant from the consultant dropdown using the given value.
33+
34+
Args:
35+
value (str): The value attribute of the consultant option to select.
36+
"""
37+
self.consultant_link.click()
38+
option_locator = self.page.locator(f'[value="{value}"]:visible')
39+
option_locator.wait_for(state="visible")
40+
self.click(option_locator)
41+
42+
def fill_notes(self, notes: str) -> None:
43+
"""
44+
Fill the 'Notes' textbox with the provided text.
45+
46+
Args:
47+
notes (str): The text to enter into the notes textbox.
48+
"""
49+
self.notes_textbox.click()
50+
self.notes_textbox.fill(notes)
51+
52+
def click_save_button(self) -> None:
53+
"""Click the save button to save the changes."""
54+
self.safe_accept_dialog(self.save_button)

tests/smokescreen/test_compartment_6.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
from utils.batch_processing import batch_processing
1010
from pages.logout.log_out_page import LogoutPage
1111
from pages.datasets.subject_datasets_page import SubjectDatasetsPage
12+
from pages.screening_subject_search.handover_into_symptomatic_care_page import (
13+
HandoverIntoSymptomaticCarePage
14+
)
1215
from utils.calendar_picker import CalendarPicker
1316
from datetime import datetime
1417
from pages.screening_subject_search.record_diagnosis_date_page import (
@@ -247,19 +250,12 @@ def handover_subject_to_symptomatic_care(page: Page) -> None:
247250
page.get_by_role("button", name="Handover into Symptomatic Care").click()
248251

249252
# The following code is on the handover into symptomatic care page
250-
page.get_by_label("Referral").select_option("20445")
251-
page.get_by_role("button", name="Calendar").click()
253+
HandoverIntoSymptomaticCarePage(page).select_referral_dropdown_option("20445")
254+
HandoverIntoSymptomaticCarePage(page).click_calendar_button()
252255
CalendarPicker(page).v1_calender_picker(datetime.today())
253-
page.locator("#UI_NS_CONSULTANT_PIO_SELECT_LINK").click()
254-
option_locator = page.locator(
255-
'[value="201"]:visible'
256-
) # Here value '201' is referring to Consultant B, Frame
257-
option_locator.wait_for(state="visible")
258-
option_locator.click()
259-
page.get_by_role("textbox", name="Notes").click()
260-
page.get_by_role("textbox", name="Notes").fill("Test Automation")
261-
page.once("dialog", lambda dialog: dialog.accept())
262-
page.get_by_role("button", name="Save").click()
256+
HandoverIntoSymptomaticCarePage(page).select_consultant("201")
257+
HandoverIntoSymptomaticCarePage(page).fill_notes("Test Automation")
258+
HandoverIntoSymptomaticCarePage(page).click_save_button()
263259

264260
SubjectScreeningSummaryPage(page).wait_for_page_title()
265261
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
@@ -285,7 +281,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
285281

286282
# This needs to be repeated for two subjects, one old and one not - High Risk Result
287283
# Older patient
288-
nhs_no = "9109877185"
284+
nhs_no = "9577049095"
289285
go_to_investigation_datasets_page(page, nhs_no)
290286

291287
# The following code is on the investigation datasets page
@@ -300,7 +296,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
300296
handover_subject_to_symptomatic_care(page)
301297

302298
# Younger patient
303-
nhs_no = "9624131880"
299+
nhs_no = "9567180636"
304300
go_to_investigation_datasets_page(page, nhs_no)
305301

306302
# The following code is on the investigation datasets page
@@ -330,7 +326,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
330326

331327
# This needs to be repeated for two subjects, one old and one not - LNPCP Result
332328
# Older patient
333-
nhs_no = "9648064792"
329+
nhs_no = "9237051190"
334330
go_to_investigation_datasets_page(page, nhs_no)
335331

336332
# The following code is on the investigation datasets page
@@ -345,7 +341,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
345341
handover_subject_to_symptomatic_care(page)
346342

347343
# Younger patient
348-
nhs_no = "9627060208"
344+
nhs_no = "9564243211"
349345
go_to_investigation_datasets_page(page, nhs_no)
350346

351347
# The following code is on the investigation datasets page
@@ -373,7 +369,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
373369
)
374370

375371
# This needs to be repeated for 1 subject, age does not matter - Normal Result
376-
nhs_no_normal = "9965184321"
372+
nhs_no_normal = "9648226105"
377373
go_to_investigation_datasets_page(page, nhs_no_normal)
378374

379375
# The following code is on the investigation datasets page

0 commit comments

Comments
 (0)