Skip to content

Commit 9311a0b

Browse files
BCSS-20020: Compartment 1 Smokescreen Tests (#7)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description Compartment 1 Smokescreen Tests <!-- Describe your changes in detail. --> ## Context This pr covers the addition of tests and functions required for the Compartment 1 Smokescreen Tests <!-- Why is this change required? What problem does it solve? --> ## Type of changes This completes the migration of the compartment 1 tests from selenium to playwright <!-- 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 - [x] 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: Dave Harding <[email protected]>
1 parent 9cdc583 commit 9311a0b

File tree

86 files changed

+3106
-1022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+3106
-1022
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from playwright.sync_api import Page, expect
2+
from pages.base_page import BasePage
3+
4+
class AgeExtensionRolloutPlans(BasePage):
5+
def __init__(self, page: Page):
6+
super().__init__(page)
7+
self.page = page
8+
#Age Extension Rollout Plans - page locators
9+
self.age_extension_rollout_plans_title = self.page.locator("#page-title")
10+
11+
def verify_age_extension_rollout_plans_title(self) -> None:
12+
expect(self.age_extension_rollout_plans_title).to_contain_text("Age Extension Rollout Plans")

pages/base_page.py

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
from playwright.sync_api import Page, expect
2+
import logging
3+
4+
5+
class BasePage:
6+
def __init__(self, page: Page):
7+
self.page = page
8+
# Homepage/Navigation Bar links
9+
self.sub_menu_link = self.page.get_by_role("link", name="Show Sub-menu")
10+
self.hide_sub_menu_link = self.page.get_by_role("link", name="Hide Sub-menu")
11+
self.select_org_link = self.page.get_by_role("link", name="Select Org")
12+
self.back_button = self.page.get_by_role("link", name="Back", exact=True)
13+
self.release_notes_link = self.page.get_by_role("link", name="- Release Notes")
14+
self.refresh_alerts_link = self.page.get_by_role("link", name="Refresh alerts")
15+
self.user_guide_link = self.page.get_by_role("link", name="User guide")
16+
self.help_link = self.page.get_by_role("link", name="Help")
17+
self.main_menu_link = self.page.get_by_role("link", name="Main Menu")
18+
self.log_out_link = self.page.get_by_role("link", name="Log-out")
19+
# Main menu - page links
20+
self.contacts_list_page = self.page.get_by_role("link", name="Contacts List")
21+
self.bowel_scope_page = self.page.get_by_role("link", name="Bowel Scope")
22+
self.call_and_recall_page = self.page.get_by_role("link", name="Call and Recall")
23+
self.communications_production_page = self.page.get_by_role("link", name="Communications Production")
24+
self.download_page = self.page.get_by_role("link", name="Download")
25+
self.fit_test_kits_page = self.page.get_by_role("link", name="FIT Test Kits")
26+
self.gfobt_test_kits_page = self.page.get_by_role("link", name="gFOBT Test Kits")
27+
self.lynch_surveillance_page = self.page.get_by_role("link", name="Lynch Surveillance")
28+
self.organisations_page = self.page.get_by_role("link", name="Organisations")
29+
self.reports_page = self.page.get_by_role("link", name="Reports")
30+
self.screening_practitioner_appointments_page = self.page.get_by_role("link", name="Screening Practitioner")
31+
self.screening_subject_search_page = self.page.get_by_role("link", name="Screening Subject Search")
32+
# Bowel Cancer Screening System header
33+
self.bowel_cancer_screening_system_header = self.page.locator("#ntshAppTitle")
34+
# Bowel Cancer Screening Page header
35+
self.bowel_cancer_screening_page_title = self.page.locator("#page-title")
36+
self.bowel_cancer_screening_ntsh_page_title = self.page.locator("#ntshPageTitle")
37+
self.main_menu__header = self.page.locator("#ntshPageTitle")
38+
39+
def click_main_menu_link(self) -> None:
40+
for _ in range(3): # Try up to 3 times
41+
if self.main_menu_link.is_visible():
42+
self.click(self.main_menu_link)
43+
return # Exit if successful
44+
45+
def click_log_out_link(self) -> None:
46+
self.click(self.log_out_link)
47+
48+
def click_sub_menu_link(self) -> None:
49+
self.click(self.sub_menu_link)
50+
51+
def click_hide_sub_menu_link(self) -> None:
52+
self.click(self.hide_sub_menu_link)
53+
54+
def click_select_org_link(self) -> None:
55+
self.click(self.select_org_link)
56+
57+
def click_back_button(self) -> None:
58+
self.click(self.back_button)
59+
60+
def click_release_notes_link(self) -> None:
61+
self.click(self.release_notes_link)
62+
63+
def click_refresh_alerts_link(self) -> None:
64+
self.click(self.refresh_alerts_link)
65+
66+
def click_user_guide_link(self) -> None:
67+
self.click(self.user_guide_link)
68+
69+
def click_help_link(self) -> None:
70+
self.click(self.help_link)
71+
72+
def bowel_cancer_screening_system_header_is_displayed(self) -> None:
73+
expect(self.bowel_cancer_screening_system_header).to_contain_text("Bowel Cancer Screening System")
74+
75+
def main_menu_header_is_displayed(self) -> None:
76+
expect(self.main_menu__header).to_contain_text("Main Menu")
77+
78+
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:
87+
"""Asserts that the page title contains the specified text.
88+
89+
Args:
90+
text (str): The expected text that you want to assert for the page title ("#ntshPageTitle") element.
91+
"""
92+
expect(self.bowel_cancer_screening_ntsh_page_title).to_contain_text(text)
93+
94+
def go_to_contacts_list_page(self) -> None:
95+
self.click(self.contacts_list_page)
96+
97+
def go_to_bowel_scope_page(self) -> None:
98+
self.click(self.bowel_scope_page)
99+
100+
def go_to_call_and_recall_page(self) -> None:
101+
self.click(self.call_and_recall_page)
102+
103+
def go_to_communications_production_page(self) -> None:
104+
self.click(self.communications_production_page)
105+
106+
def go_to_download_page(self) -> None:
107+
self.click(self.download_page)
108+
109+
def go_to_fit_test_kits_page(self) -> None:
110+
self.click(self.fit_test_kits_page)
111+
112+
def go_to_gfobt_test_kits_page(self) -> None:
113+
self.click(self.gfobt_test_kits_page)
114+
115+
def go_to_lynch_surveillance_page(self) -> None:
116+
self.click(self.lynch_surveillance_page)
117+
118+
def go_to_organisations_page(self) -> None:
119+
self.click(self.organisations_page)
120+
121+
def go_to_reports_page(self) -> None:
122+
self.click(self.reports_page)
123+
124+
def go_to_screening_practitioner_appointments_page(self) -> None:
125+
self.click(self.screening_practitioner_appointments_page)
126+
127+
def go_to_screening_subject_search_page(self) -> None:
128+
self.click(self.screening_subject_search_page)
129+
130+
def click(self, locator) -> None:
131+
"""
132+
This is used to click on a locator
133+
The reason for this being used over the normal playwright click method is due to:
134+
- BCSS sometimes takes a while to render and so the normal click function 'clicks' on a locator before its available
135+
- Increases the reliability of clicks to avoid issues with the normal click method
136+
"""
137+
try:
138+
self.page.wait_for_load_state('load')
139+
self.page.wait_for_load_state('domcontentloaded')
140+
locator.wait_for(state="attached")
141+
locator.wait_for(state="visible")
142+
locator.click()
143+
144+
except Exception as locatorClickError:
145+
logging.warning(f"Failed to click element with error: {locatorClickError}, trying again...")
146+
locator.click()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from playwright.sync_api import Page, expect
2+
from pages.base_page import BasePage
3+
4+
class BatchDownloadRequestAndRetrieval(BasePage):
5+
def __init__(self, page: Page):
6+
super().__init__(page)
7+
self.page = page
8+
#Batch Download Request And Retrieval - page locators
9+
self.batch_download_request_and_retrieval_title = self.page.locator("#ntshPageTitle")
10+
self.page_form = self.page.locator("form[name=\"frm\"]")
11+
12+
def expect_form_to_have_warning(self) -> None:
13+
expect(self.page_form).to_contain_text("Warning - FS Screening data will not be downloaded")
14+
15+
def verify_batch_download_request_and_retrieval_title(self) -> None:
16+
expect(self.batch_download_request_and_retrieval_title).to_contain_text("Batch Download Request and Retrieval")

pages/batch_list_page.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from playwright.sync_api import Page, expect
2+
from pages.base_page import BasePage
3+
4+
class BatchList(BasePage):
5+
def __init__(self, page: Page):
6+
super().__init__(page)
7+
self.page = page
8+
#Batch List - page filters
9+
self.id_filter = self.page.locator("#batchIdFilter")
10+
self.type_filter = self.page.locator("#batchTypeFilter")
11+
self.original_filter = self.page.locator("#originalBatchIdFilter")
12+
self.event_code_filter = self.page.locator("#eventCodeFilter")
13+
self.description_filter = self.page.locator("#eventDescriptionFilter")
14+
self.batch_split_by_filter = self.page.locator("#splitByFilter")
15+
self.screening_centre_filter = self.page.locator("#screeningCentreFilter")
16+
self.count_filter = self.page.locator("#countFilter")
17+
self.table_data = self.page.locator("td")
18+
self.batch_successfully_archived_msg = self.page.locator('text="Batch Successfully Archived and Printed"')
19+
self.batch_list_page_title = self.page.locator("#page-title")
20+
21+
def verify_batch_list_page_title(self, text) -> None:
22+
expect(self.batch_list_page_title).to_contain_text(text)
23+
24+
def verify_table_data(self, value)->None:
25+
expect(self.table_data.filter(has_text=value)).to_be_visible()
26+
27+
def enter_id_filter(self, search_text: str)->None:
28+
self.id_filter.fill(search_text)
29+
self.id_filter.press("Enter")
30+
31+
def enter_type_filter(self, search_text: str)->None:
32+
self.type_filter.fill(search_text)
33+
self.type_filter.press("Enter")
34+
35+
def enter_original_filter(self, search_text: str)->None:
36+
self.original_filter.fill(search_text)
37+
self.original_filter.press("Enter")
38+
39+
def enter_event_code_filter(self, search_text: str)->None:
40+
self.event_code_filter.fill(search_text)
41+
self.event_code_filter.press("Enter")
42+
43+
def enter_description_filter(self, search_text: str)->None:
44+
self.description_filter.fill(search_text)
45+
self.description_filter.press("Enter")
46+
47+
def enter_batch_split_by_filter(self, search_text: str)->None:
48+
self.batch_split_by_filter.fill(search_text)
49+
self.batch_split_by_filter.press("Enter")
50+
51+
def enter_screening_centre_filter(self, search_text: str)->None:
52+
self.screening_centre_filter.fill(search_text)
53+
self.screening_centre_filter.press("Enter")
54+
55+
def enter_count_filter(self, search_text: str)->None:
56+
self.count_filter.fill(search_text)
57+
self.count_filter.press("Enter")
58+
59+
class ActiveBatchList(BatchList):
60+
def __init__(self, page):
61+
super().__init__(page)
62+
63+
class ArchivedBatchList(BatchList):
64+
def __init__(self, page):
65+
super().__init__(page)

pages/bcss_home_page.py

Lines changed: 0 additions & 93 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from playwright.sync_api import Page, expect
2+
from pages.base_page import BasePage
3+
4+
class BowelScopeAppointments(BasePage):
5+
def __init__(self, page: Page):
6+
super().__init__(page)
7+
self.page = page
8+
#Bowel Scope Appointments - page locators
9+
self.page_title = self.page.locator("#ntshPageTitle")
10+
11+
def verify_page_title(self) -> None:
12+
expect(self.page_title).to_contain_text("Appointment Calendar")

pages/bowel_scope_page.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from playwright.sync_api import Page, expect, Locator
2+
from pages.base_page import BasePage
3+
4+
class BowelScope(BasePage):
5+
def __init__(self, page: Page):
6+
super().__init__(page)
7+
self.page = page
8+
#Bowel Scope - page locators
9+
self.view_bowel_scope_appointments_page = self.page.get_by_role("link", name="View Bowel Scope Appointments")
10+
11+
def go_to_view_bowel_scope_appointments_page(self) -> None:
12+
self.click(self.view_bowel_scope_appointments_page)

pages/call_and_recall_page.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from playwright.sync_api import Page
2+
from pages.base_page import BasePage
3+
4+
class CallAndRecall(BasePage):
5+
def __init__(self, page: Page):
6+
super().__init__(page)
7+
self.page = page
8+
# Call and Recall - page links
9+
self.planning_and_monitoring_page = self.page.get_by_role("link", name="Planning and Monitoring")
10+
self.generate_invitations_page = self.page.get_by_role("link", name="Generate Invitations")
11+
self.invitation_generation_progress_page = self.page.get_by_role("link", name="Invitation Generation Progress")
12+
self.non_invitation_days_page = self.page.get_by_role("link", name="Non Invitation Days")
13+
self.age_extension_rollout_plans_page = self.page.get_by_role("link", name="Age Extension Rollout Plans")
14+
15+
def go_to_planning_and_monitoring_page(self)->None:
16+
self.click(self.planning_and_monitoring_page)
17+
18+
def go_to_generate_invitations_page(self)->None:
19+
self.click(self.generate_invitations_page)
20+
21+
def go_to_invitation_generation_progress_page(self)->None:
22+
self.click(self.invitation_generation_progress_page)
23+
24+
def go_to_non_invitation_days_page(self)->None:
25+
self.click(self.non_invitation_days_page)
26+
27+
def go_to_age_extension_rollout_plans_page(self)->None:
28+
self.click(self.age_extension_rollout_plans_page)

0 commit comments

Comments
 (0)