Skip to content

Commit b9e4bcb

Browse files
Feature/bcss 20023–write an if statement for page title contains text functions (#18)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> ## Context Refactored both methods that verify the text of the bcss screening page titles into one method. <!-- Why is this change required? What problem does it solve? --> ## Type of changes Removes repetition as two methods are doing the same thing. <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [ ] 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) - [ ] 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: adrianoaru-nhs <[email protected]> Co-authored-by: Adriano Aru <[email protected]>
1 parent f1ca66b commit b9e4bcb

File tree

3 files changed

+33
-43
lines changed

3 files changed

+33
-43
lines changed

pages/base_page.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,17 @@ def bowel_cancer_screening_page_title_contains_text(self, text: str) -> None:
9595
"""Asserts that the page title contains the specified text.
9696
9797
Args:
98-
text (str): The expected text that you want to assert for the page title ("#page-title") element.
98+
text (str): The expected text that you want to assert for the page title element.
99+
Page elements of interest:
100+
self.bowel_cancer_screening_page_title
101+
self.bowel_cancer_screening_ntsh_page_title
99102
"""
100-
expect(self.bowel_cancer_screening_page_title).to_contain_text(text)
101-
102-
def bowel_cancer_screening_ntsh_page_title_contains_text(self, text: str) -> None:
103-
"""Asserts that the page title contains the specified text.
104-
105-
Args:
106-
text (str): The expected text that you want to assert for the page title ("#ntshPageTitle") element.
107-
"""
108-
expect(self.bowel_cancer_screening_ntsh_page_title).to_contain_text(text)
103+
self.page.wait_for_load_state("load")
104+
self.page.wait_for_load_state("domcontentloaded")
105+
if self.bowel_cancer_screening_page_title.is_visible():
106+
expect(self.bowel_cancer_screening_page_title).to_contain_text(text)
107+
else:
108+
expect(self.bowel_cancer_screening_ntsh_page_title).to_contain_text(text)
109109

110110
def go_to_contacts_list_page(self) -> None:
111111
self.click(self.contacts_list_page)

tests/test_organisations_page.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,19 @@ def test_organisations_page_navigation(page: Page) -> None:
3636
"""
3737
# Screening centre parameters page loads as expected
3838
OrganisationsPage(page).go_to_screening_centre_parameters_page()
39-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
39+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
4040
"Screening Centre Parameters"
4141
)
4242
BasePage(page).click_back_button()
4343

4444
# Organisation parameters page loads as expected
4545
OrganisationsPage(page).go_to_organisation_parameters_page()
46-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
47-
"System Parameters"
48-
)
46+
BasePage(page).bowel_cancer_screening_page_title_contains_text("System Parameters")
4947
BasePage(page).click_back_button()
5048

5149
# Organisation and site details page loads as expected
5250
OrganisationsPage(page).go_to_organisations_and_site_details_page()
53-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
51+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
5452
"Organisation and Site Details"
5553
)
5654
BasePage(page).click_back_button()
@@ -61,13 +59,13 @@ def test_organisations_page_navigation(page: Page) -> None:
6159

6260
# GP practice endorsement page loads as expected
6361
OrganisationsPage(page).go_to_gp_practice_endorsement_page()
64-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
62+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
6563
"GP Practice Endorsement"
6664
)
6765

6866
# Return to main menu
6967
BasePage(page).click_main_menu_link()
70-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Main Menu")
68+
BasePage(page).bowel_cancer_screening_page_title_contains_text("Main Menu")
7169

7270

7371
def test_view_an_organisations_system_parameters(
@@ -81,6 +79,4 @@ def test_view_an_organisations_system_parameters(
8179

8280
# View an Organisation
8381
page.get_by_role("link", name=general_properties["screening_centre_code"]).click()
84-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
85-
"System Parameters"
86-
)
82+
BasePage(page).bowel_cancer_screening_page_title_contains_text("System Parameters")

tests/test_reports_page.py

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,24 @@ def test_reports_page_navigation(page: Page) -> None:
3939

4040
# Failsafe reports page opens as expected
4141
ReportsPage(page).go_to_failsafe_reports_page()
42-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
43-
"Failsafe Reports"
44-
)
42+
BasePage(page).bowel_cancer_screening_page_title_contains_text("Failsafe Reports")
4543
BasePage(page).click_back_button()
4644

4745
# Operational reports page opens as expected
4846
ReportsPage(page).go_to_operational_reports_page()
49-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
47+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
5048
"Operational Reports"
5149
)
5250
BasePage(page).click_back_button()
5351

5452
# Strategic reports page opens as expected
5553
ReportsPage(page).go_to_strategic_reports_page()
56-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
57-
"Strategic Reports"
58-
)
54+
BasePage(page).bowel_cancer_screening_page_title_contains_text("Strategic Reports")
5955
BasePage(page).click_back_button()
6056

6157
# "Cancer waiting times reports" page opens as expected
6258
ReportsPage(page).go_to_cancer_waiting_times_reports_page()
63-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
59+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
6460
"Cancer Waiting Times Reports"
6561
)
6662
BasePage(page).click_back_button()
@@ -75,7 +71,7 @@ def test_reports_page_navigation(page: Page) -> None:
7571

7672
# Return to main menu
7773
BasePage(page).click_main_menu_link()
78-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Main Menu")
74+
BasePage(page).bowel_cancer_screening_page_title_contains_text("Main Menu")
7975

8076

8177
# Failsafe Reports
@@ -93,7 +89,7 @@ def test_failsafe_reports_date_report_last_requested(page: Page) -> None:
9389
ReportsPage(page).go_to_date_report_last_requested_page()
9490

9591
# Verify 'Date Report Last Requested' is the page title
96-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
92+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
9793
"Date Report Last Requested"
9894
)
9995

@@ -140,7 +136,7 @@ def test_failsafe_reports_screening_subjects_with_inactive_open_episode(
140136
nhs_number_link.click()
141137

142138
# Verify "Subject Screening Summary" is the page title
143-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
139+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
144140
"Subject Screening Summary"
145141
)
146142

@@ -183,7 +179,7 @@ def test_failsafe_reports_subjects_ceased_due_to_date_of_birth_changes(
183179
nhs_number_link.click()
184180

185181
# Verify page title is "Subject Demographic"
186-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
182+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
187183
"Subject Demographic"
188184
)
189185

@@ -211,7 +207,7 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
211207
failsafe_report_page.go_to_allocate_sc_for_patient_movements_within_hub_boundaries_page()
212208

213209
# Verify page title is "Allocate SC for Patient Movements within Hub Boundaries"
214-
failsafe_report_page.bowel_cancer_screening_ntsh_page_title_contains_text(
210+
failsafe_report_page.bowel_cancer_screening_page_title_contains_text(
215211
"Allocate SC for Patient Movements within Hub Boundaries"
216212
)
217213

@@ -226,7 +222,7 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
226222
nhs_number_link.click()
227223

228224
# Verify page title is "Set Patient's Screening Centre"
229-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
225+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
230226
"Set Patient's Screening Centre"
231227
)
232228

@@ -262,7 +258,7 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_into_your_hub(
262258
ReportsPage(page).go_to_allocate_sc_for_patient_movements_into_your_hub_page()
263259

264260
# Verify page title is "Date Report Last Requested"
265-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
261+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
266262
"Allocate SC for Patient Movements into your Hub"
267263
)
268264

@@ -302,7 +298,7 @@ def test_failsafe_reports_identify_and_link_new_gp(page: Page) -> None:
302298
ReportsPage(page).go_to_identify_and_link_new_gp_page()
303299

304300
# Verify page title is "Identify and link new GP practices"
305-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
301+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
306302
"Identify and link new GP practices"
307303
)
308304

@@ -324,7 +320,7 @@ def test_failsafe_reports_identify_and_link_new_gp(page: Page) -> None:
324320
nhs_number_cell_link.click()
325321

326322
# Verify page title is "Link GP practice to Screening Centre"
327-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
323+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
328324
"Link GP practice to Screening Centre"
329325
)
330326

@@ -354,7 +350,7 @@ def test_operational_reports_appointment_attendance_not_updated(
354350
ReportsPage(page).go_to_appointment_attendance_not_updated_page()
355351

356352
# Verify page title is "Appointment Attendance Not Updated"
357-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
353+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
358354
"Appointment Attendance Not Updated"
359355
)
360356

@@ -374,9 +370,7 @@ def test_operational_reports_appointment_attendance_not_updated(
374370
nhs_number_link.click()
375371

376372
# Verify the page title is "Appointment Detail"
377-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
378-
"Appointment Detail"
379-
)
373+
BasePage(page).bowel_cancer_screening_page_title_contains_text("Appointment Detail")
380374

381375

382376
def test_operational_reports_fobt_kits_logged_but_not_read(page: Page) -> None:
@@ -453,7 +447,7 @@ def test_operational_reports_screening_practitioner_6_weeks_availability_not_set
453447
).go_to_screening_practitioner_6_weeks_availability_not_set_up_report_page()
454448

455449
# Verify page title is "Screening Practitioner 6 Weeks Availability Not Set Up"
456-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
450+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
457451
"Screening Practitioner 6 Weeks Availability Not Set Up"
458452
)
459453

@@ -502,7 +496,7 @@ def test_operational_reports_screening_practitioner_appointments(
502496
ReportsPage(page).go_to_screening_practitioner_appointments_page()
503497

504498
# Verify page title is "Screening Practitioner Appointments"
505-
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
499+
BasePage(page).bowel_cancer_screening_page_title_contains_text(
506500
"Screening Practitioner Appointments"
507501
)
508502

0 commit comments

Comments
 (0)