Skip to content

Commit 7a32ec4

Browse files
committed
Added additional page title function to BasePage
Removed more hardcoded values from test_reports_page Updated test_organisations_page to use new page title function
1 parent fc430b2 commit 7a32ec4

File tree

4 files changed

+51
-34
lines changed

4 files changed

+51
-34
lines changed

pages/base_page.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def __init__(self, page: Page):
3232
# Bowel Cancer Screening System header
3333
self.bowel_cancer_screening_system_header = self.page.locator("#ntshAppTitle")
3434
# Bowel Cancer Screening Page header
35-
self.bowel_cancer_screening_page_header = self.page.locator("#ntshPageTitle")
35+
self.bowel_cancer_screening_page_title = self.page.locator("#page-title")
36+
self.bowel_cancer_screening_ntsh_page_title = self.page.locator("#ntshPageTitle")
3637
self.main_menu__header = self.page.locator("#ntshPageTitle")
3738

3839
def click_main_menu_link(self) -> None:
@@ -75,12 +76,20 @@ def main_menu_header_is_displayed(self) -> None:
7576
expect(self.main_menu__header).to_contain_text("Main Menu")
7677

7778
def bowel_cancer_screening_page_title_contains_text(self, text: str) -> None:
79+
"""Asserts that the page title contains the specified text.
80+
81+
Args:
82+
text (str): The expected text that you want to assert for the page title ("#page-title") element.
83+
"""
84+
expect(self.bowel_cancer_screening_page_title).to_contain_text(text)
85+
86+
def bowel_cancer_screening_ntsh_page_title_contains_text(self, text: str) -> None:
7887
"""Asserts that the page title contains the specified text.
7988
8089
Args:
8190
text (str): The expected text that you want to assert for the page title ("#ntshPageTitle") element.
8291
"""
83-
expect(self.bowel_cancer_screening_page_header).to_contain_text(text)
92+
expect(self.bowel_cancer_screening_ntsh_page_title).to_contain_text(text)
8493

8594
def go_to_contacts_list_page(self) -> None:
8695
self.click(self.contacts_list_page)

pages/reports_page.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ def __init__(self, page):
66
super().__init__(page)
77
self.page = page
88
# Reports page main menu links
9+
self.bureau_reports_page = self.page.get_by_role("link", name="Bureau Reports")
910
self.failsafe_reports_page = self.page.get_by_role("link", name="Failsafe Reports")
1011
self.operational_reports_page = self.page.get_by_role("link", name="Operational Reports")
1112
self.strategic_reports_page = self.page.get_by_role("link", name="Strategic Reports")
1213
self.cancer_waiting_times_reports_page = self.page.get_by_role("link", name="Cancer Waiting Times Reports")
1314
self.dashboard = self.page.get_by_role("link", name="Dashboard")
15+
self.qa_report_dataset_completion_page = self.page.get_by_role("link", name="QA Report : Dataset Completion")
1416
# Reports pages shared buttons
1517
self.refresh_page_button = self.page.get_by_role("button", name="Refresh")
1618
self.generate_report_button = self.page.get_by_role("button", name="Generate Report")
@@ -45,6 +47,7 @@ def go_to_cancer_waiting_times_reports_page(self) -> None:
4547
def go_to_dashboard(self) -> None:
4648
self.click(self.dashboard)
4749

50+
# Reports pages shared buttons actions
4851
def click_refresh_button(self) -> None:
4952
self.click(self.refresh_page_button)
5053

tests/test_organisations_page.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ def test_organisations_page_navigation(page: Page) -> None:
4949
"""
5050
# Screening centre parameters page loads as expected
5151
OrganisationsPage(page).go_to_screening_centre_parameters_page()
52-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Screening Centre Parameters")
52+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Screening Centre Parameters")
5353
BasePage(page).click_back_button()
5454

5555
# Organisation parameters page loads as expected
5656
OrganisationsPage(page).go_to_organisation_parameters_page()
57-
BasePage(page).bowel_cancer_screening_page_title_contains_text("System Parameters")
57+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("System Parameters")
5858
BasePage(page).click_back_button()
5959

6060
# Organisation and site details page loads as expected
6161
OrganisationsPage(page).go_to_organisations_and_site_details_page()
62-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Organisation and Site Details")
62+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Organisation and Site Details")
6363
BasePage(page).click_back_button()
6464

6565
# The links below are visible (not clickable due to user role permissions)
@@ -68,11 +68,11 @@ def test_organisations_page_navigation(page: Page) -> None:
6868

6969
# GP practice endorsement page loads as expected
7070
OrganisationsPage(page).go_to_gp_practice_endorsement_page()
71-
BasePage(page).bowel_cancer_screening_page_title_contains_text("GP Practice Endorsement")
71+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("GP Practice Endorsement")
7272

7373
# Return to main menu
7474
BasePage(page).click_main_menu_link()
75-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Main Menu")
75+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Main Menu")
7676

7777

7878
def test_view_an_organisations_system_parameters(page: Page, tests_properties: dict) -> None:
@@ -84,4 +84,4 @@ def test_view_an_organisations_system_parameters(page: Page, tests_properties: d
8484

8585
# View an Organisation
8686
page.get_by_role("link", name=tests_properties["screening_centre_code"]).click()
87-
BasePage(page).bowel_cancer_screening_page_title_contains_text("System Parameters")
87+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("System Parameters")

tests/test_reports_page.py

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import pytest
22
from playwright.sync_api import Page, expect
33

4+
from pages.base_page import BasePage
45
from pages.reports_page import ReportsPage
56
from utils.click_helper import click
6-
from pages import reports_page
7-
from pages.base_page import BasePage
8-
from utils.user_tools import UserTools
97
from utils.date_time_utils import DateTimeUtils
8+
from utils.user_tools import UserTools
109

1110

1211
@pytest.fixture(scope="function", autouse=True)
@@ -28,27 +27,30 @@ def test_reports_page_navigation(page: Page) -> None:
2827
Confirms all menu items are displayed on the reports page, and that the relevant pages
2928
are loaded when the links are clicked
3029
"""
30+
bureau_reports_link = page.get_by_text("Bureau Reports")
31+
qa_report_data_completion_link = page.get_by_text("QA Report : Dataset Completion")
32+
3133
# Bureau reports link is visible
32-
expect(page.get_by_text("Bureau Reports")).to_be_visible()
34+
expect(bureau_reports_link).to_be_visible()
3335

3436
# Failsafe reports page opens as expected
3537
ReportsPage(page).go_to_failsafe_reports_page()
36-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Failsafe Reports")
38+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Failsafe Reports")
3739
BasePage(page).click_back_button()
3840

3941
# Operational reports page opens as expected
4042
ReportsPage(page).go_to_operational_reports_page()
41-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Operational Reports")
43+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Operational Reports")
4244
BasePage(page).click_back_button()
4345

4446
# Strategic reports page opens as expected
4547
ReportsPage(page).go_to_strategic_reports_page()
46-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Strategic Reports")
48+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Strategic Reports")
4749
BasePage(page).click_back_button()
4850

4951
# "Cancer waiting times reports" page opens as expected
5052
ReportsPage(page).go_to_cancer_waiting_times_reports_page()
51-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Cancer Waiting Times Reports")
53+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Cancer Waiting Times Reports")
5254
BasePage(page).click_back_button()
5355

5456
# Dashboard opens as expected TODO - this step may be failing legitimately
@@ -57,11 +59,11 @@ def test_reports_page_navigation(page: Page) -> None:
5759
# BasePage(page).click_back_button()
5860

5961
# QA Report : Dataset Completion link is visible
60-
expect(page.get_by_text("QA Report : Dataset Completion")).to_be_visible()
62+
expect(qa_report_data_completion_link).to_be_visible()
6163

6264
# Return to main menu
6365
BasePage(page).click_main_menu_link()
64-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Main Menu")
66+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Main Menu")
6567

6668

6769
# Failsafe Reports
@@ -77,7 +79,7 @@ def test_failsafe_reports_date_report_last_requested(page: Page) -> None:
7779
ReportsPage(page).go_to_date_report_last_requested_page()
7880

7981
# Verify 'Date Report Last Requested' is the page title
80-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Date Report Last Requested")
82+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Date Report Last Requested")
8183

8284
# Click 'generate report' button
8385
ReportsPage(page).click_generate_report_button()
@@ -93,6 +95,7 @@ def test_failsafe_reports_date_report_last_requested(page: Page) -> None:
9395
expect(page.locator("b")).to_contain_text(report_timestamp)
9496

9597

98+
@pytest.mark.only
9699
def test_failsafe_reports_screening_subjects_with_inactive_open_episode(page: Page) -> None:
97100
"""
98101
Confirms 'screening_subjects_with_inactive_open_episode' page loads, 'generate report' button works as expected
@@ -107,7 +110,7 @@ def test_failsafe_reports_screening_subjects_with_inactive_open_episode(page: Pa
107110
ReportsPage(page).go_to_screening_subjects_with_inactive_open_episode_link_page()
108111

109112
# Verify "Screening Subjects With Inactive Open Episode" is the page title
110-
expect(page.locator("#page-title")).to_contain_text("Screening Subjects With Inactive Open Episode")
113+
BasePage(page).bowel_cancer_screening_page_title_contains_text("Screening Subjects With Inactive Open Episode")
111114

112115
# Click 'Generate Report' button
113116
ReportsPage(page).click_generate_report_button()
@@ -116,7 +119,7 @@ def test_failsafe_reports_screening_subjects_with_inactive_open_episode(page: Pa
116119
nhs_number_link.click()
117120

118121
# Verify "Subject Screening Summary" is the page title
119-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Subject Screening Summary")
122+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Subject Screening Summary")
120123

121124

122125
def test_failsafe_reports_subjects_ceased_due_to_date_of_birth_changes(page: Page) -> None:
@@ -151,7 +154,7 @@ def test_failsafe_reports_subjects_ceased_due_to_date_of_birth_changes(page: Pag
151154
nhs_number_link.click()
152155

153156
# Verify page title is "Subject Demographic"
154-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Subject Demographic")
157+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Subject Demographic")
155158

156159

157160
def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundaries(page: Page) -> None:
@@ -173,7 +176,7 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
173176
ReportsPage(page).go_to_allocate_sc_for_patient_movements_within_hub_boundaries_page()
174177

175178
# Verify page title is "Allocate SC for Patient Movements within Hub Boundaries"
176-
BasePage(page).bowel_cancer_screening_page_title_contains_text(
179+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
177180
"Allocate SC for Patient Movements within Hub Boundaries")
178181

179182
# Click "Generate Report"
@@ -187,7 +190,7 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
187190
nhs_number_link.click()
188191

189192
# Verify page title is "Set Patient's Screening Centre"
190-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Set Patient's Screening Centre")
193+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Set Patient's Screening Centre")
191194

192195
# Select another screening centre
193196
page.locator("#cboScreeningCentre").select_option(coventry_and_warwickshire_bcs_centre)
@@ -212,7 +215,8 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_into_your_hub(page:
212215
ReportsPage(page).go_to_allocate_sc_for_patient_movements_into_your_hub_page()
213216

214217
# Verify page title is "Date Report Last Requested"
215-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Allocate SC for Patient Movements into your Hub")
218+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
219+
"Allocate SC for Patient Movements into your Hub")
216220

217221
# Click "Generate Report" button
218222
ReportsPage(page).click_generate_report_button()
@@ -247,7 +251,7 @@ def test_failsafe_reports_identify_and_link_new_gp(page: Page) -> None:
247251
ReportsPage(page).go_to_identify_and_link_new_gp_page()
248252

249253
# Verify page title is "Identify and link new GP practices"
250-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Identify and link new GP practices")
254+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Identify and link new GP practices")
251255

252256
# Click on "Generate Report"
253257
ReportsPage(page).click_generate_report_button()
@@ -267,7 +271,7 @@ def test_failsafe_reports_identify_and_link_new_gp(page: Page) -> None:
267271
nhs_number_link.click()
268272

269273
# Verify page title is "Link GP practice to Screening Centre"
270-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Link GP practice to Screening Centre")
274+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Link GP practice to Screening Centre")
271275

272276

273277
# Operational Reports
@@ -290,7 +294,7 @@ def test_operational_reports_appointment_attendance_not_updated(page: Page) -> N
290294
ReportsPage(page).go_to_appointment_attendance_not_updated_page()
291295

292296
# Verify page title is "Appointment Attendance Not Updated"
293-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Appointment Attendance Not Updated")
297+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Appointment Attendance Not Updated")
294298

295299
# Select a screening centre from the drop-down options
296300
page.get_by_label("Screening Centre").select_option(coventry_and_warwickshire_bcs_centre)
@@ -306,7 +310,7 @@ def test_operational_reports_appointment_attendance_not_updated(page: Page) -> N
306310
nhs_number_link.click()
307311

308312
# Verify the page title is "Appointment Detail"
309-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Appointment Detail")
313+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Appointment Detail")
310314

311315

312316
def test_operational_reports_fobt_kits_logged_but_not_read(page: Page) -> None:
@@ -322,7 +326,7 @@ def test_operational_reports_fobt_kits_logged_but_not_read(page: Page) -> None:
322326
ReportsPage(page).go_to_fobt_kits_logged_but_not_read_page()
323327

324328
# Verify page title is "FOBT Kits Logged but Not Read - Summary View"
325-
expect(page.locator("#page-title")).to_contain_text("FOBT Kits Logged but Not Read - Summary View")
329+
BasePage(page).bowel_cancer_screening_page_title_contains_text("FOBT Kits Logged but Not Read - Summary View")
326330

327331
# Click refresh button
328332
ReportsPage(page).click_refresh_button()
@@ -345,7 +349,7 @@ def test_operational_reports_demographic_update_inconsistent_with_manual_update(
345349
ReportsPage(page).go_to_demographic_update_inconsistent_with_manual_update_page()
346350

347351
# Verify page title is "Demographic Update Inconsistent With Manual Update"
348-
expect(page.locator("#page-title")).to_contain_text("Demographic Update Inconsistent With Manual Update")
352+
BasePage(page).bowel_cancer_screening_page_title_contains_text("Demographic Update Inconsistent With Manual Update")
349353

350354

351355
def test_operational_reports_screening_practitioner_6_weeks_availability_not_set_up(page: Page) -> None:
@@ -365,7 +369,7 @@ def test_operational_reports_screening_practitioner_6_weeks_availability_not_set
365369
ReportsPage(page).go_to_screening_practitioner_6_weeks_availability_not_set_up_report_page()
366370

367371
# Verify page title is "Screening Practitioner 6 Weeks Availability Not Set Up"
368-
BasePage(page).bowel_cancer_screening_page_title_contains_text(
372+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text(
369373
"Screening Practitioner 6 Weeks Availability Not Set Up")
370374

371375
# Select a screening centre
@@ -396,6 +400,7 @@ def test_operational_reports_screening_practitioner_appointments(page: Page) ->
396400

397401
coventry_and_warwickshire_bcs_centre = "23643"
398402
screening_practitioner_named_another_stubble = "1982"
403+
generate_report_button = page.locator("#submitThisForm") #The locator appears to be unique to this button
399404

400405
# Go to operational reports page
401406
ReportsPage(page).go_to_operational_reports_page()
@@ -404,7 +409,7 @@ def test_operational_reports_screening_practitioner_appointments(page: Page) ->
404409
ReportsPage(page).go_to_screening_practitioner_appointments_page()
405410

406411
# Verify page title is "Screening Practitioner Appointments"
407-
BasePage(page).bowel_cancer_screening_page_title_contains_text("Screening Practitioner Appointments")
412+
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Screening Practitioner Appointments")
408413

409414
# Select a screening centre
410415
page.get_by_label("Screening Centre").select_option(coventry_and_warwickshire_bcs_centre)
@@ -413,7 +418,7 @@ def test_operational_reports_screening_practitioner_appointments(page: Page) ->
413418
page.locator("#A_C_NURSE").select_option(screening_practitioner_named_another_stubble)
414419

415420
# Click "Generate Report"
416-
click(page, page.locator("#submitThisForm"))
421+
generate_report_button.click()
417422

418423
# Verify timestamp has updated to current date and time
419424
report_timestamp = DateTimeUtils.screening_practitioner_appointments_report_timestamp_date_format()

0 commit comments

Comments
 (0)