Skip to content

Commit 2dab159

Browse files
committed
added page object module for screening practitioner appointments page
2 parents a2a08ed + 36b2bcf commit 2dab159

File tree

6 files changed

+126
-41
lines changed

6 files changed

+126
-41
lines changed

pages/active_batch_list_page.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,48 @@ def __init__(self, page: Page):
1111
self.description_filter = self.page.locator("#eventDescriptionFilter")
1212
self.batch_split_by_filter = self.page.locator("#splitByFilter")
1313
self.screening_centre_filter = self.page.locator("#screeningCentreFilter")
14-
self.status_filter = self.page.locator("#batchStatusFilter")
1514
self.count_filter = self.page.locator("#countFilter")
15+
# self.td = self.page.locator("td")
16+
17+
# def filter_td(self, filter):
18+
# self.td.
19+
20+
def enter_id_filter(self, search_text: str):
21+
self.id_filter.click()
22+
self.id_filter.fill(search_text)
23+
self.id_filter.press("Enter")
24+
25+
def enter_type_filter(self, search_text: str):
26+
self.type_filter.click()
27+
self.type_filter.fill(search_text)
28+
self.type_filter.press("Enter")
29+
30+
def enter_original_filter(self, search_text: str):
31+
self.original_filter.click()
32+
self.original_filter.fill(search_text)
33+
self.original_filter.press("Enter")
34+
35+
def enter_event_code_filter(self, search_text: str):
36+
self.event_code_filter.click()
37+
self.event_code_filter.fill(search_text)
38+
self.event_code_filter.press("Enter")
39+
40+
def enter_description_filter(self, search_text: str):
41+
self.description_filter.click()
42+
self.description_filter.fill(search_text)
43+
self.description_filter.press("Enter")
44+
45+
def enter_batch_split_by_filter(self, search_text: str):
46+
self.batch_split_by_filter.click()
47+
self.batch_split_by_filter.fill(search_text)
48+
self.batch_split_by_filter.press("Enter")
49+
50+
def enter_screening_centre_filter(self, search_text: str):
51+
self.screening_centre_filter.click()
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):
56+
self.count_filter.click()
57+
self.count_filter.fill(search_text)
58+
self.count_filter.press("Enter")

pages/archived_batch_list_page.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,44 @@ def __init__(self, page: Page):
1111
self.description_filter = self.page.locator("#eventDescriptionFilter")
1212
self.batch_split_by_filter = self.page.locator("#splitByFilter")
1313
self.screening_centre_filter = self.page.locator("#screeningCentreFilter")
14-
self.status_filter = self.page.locator("#batchStatusFilter")
1514
self.count_filter = self.page.locator("#countFilter")
15+
16+
def enter_id_filter(self, search_text: str):
17+
self.id_filter.click()
18+
self.id_filter.fill(search_text)
19+
self.id_filter.press("Enter")
20+
21+
def enter_type_filter(self, search_text: str):
22+
self.type_filter.click()
23+
self.type_filter.fill(search_text)
24+
self.type_filter.press("Enter")
25+
26+
def enter_original_filter(self, search_text: str):
27+
self.original_filter.click()
28+
self.original_filter.fill(search_text)
29+
self.original_filter.press("Enter")
30+
31+
def enter_event_code_filter(self, search_text: str):
32+
self.event_code_filter.click()
33+
self.event_code_filter.fill(search_text)
34+
self.event_code_filter.press("Enter")
35+
36+
def enter_description_filter(self, search_text: str):
37+
self.description_filter.click()
38+
self.description_filter.fill(search_text)
39+
self.description_filter.press("Enter")
40+
41+
def enter_batch_split_by_filter(self, search_text: str):
42+
self.batch_split_by_filter.click()
43+
self.batch_split_by_filter.fill(search_text)
44+
self.batch_split_by_filter.press("Enter")
45+
46+
def enter_screening_centre_filter(self, search_text: str):
47+
self.screening_centre_filter.click()
48+
self.screening_centre_filter.fill(search_text)
49+
self.screening_centre_filter.press("Enter")
50+
51+
def enter_count_filter(self, search_text: str):
52+
self.count_filter.click()
53+
self.count_filter.fill(search_text)
54+
self.count_filter.press("Enter")

pages/navigation_bar_links.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ def __init__(self, page: Page):
1212

1313
def click_main_menu_link(self):
1414
for _ in range(3): # Try up to 3 times
15+
self.page.wait_for_timeout(2000) # Wait for 2 seconds before trying (as sometimes this button is clicked as a redirect happens)
1516
if self.main_menu_link.is_visible():
1617
self.main_menu_link.click()
1718
return # Exit if successful
18-
self.page.wait_for_timeout(200) # Wait for 0.2 seconds before retrying
19-
print("Already on Main Menu")
2019

2120
def click_back_link(self):
2221
self.back_link.click()

pages/screening_practitioner_appointments.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

tests/Smokescreen/test_compartment_1.py

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,42 @@
1515
from pages.navigation_bar_links import *
1616
from pages.subject_screening_page import *
1717

18+
# @pytest.mark.wip2 # Not working at the moment
19+
# def test_prereq():
20+
# database_connection_exec("prereq_check")
21+
22+
# paramater_32 = database_connection_query("select DEFAULT_VALUE from PARAMETERS where PARAM_ID = 32")
23+
# print(f"paramater_32: {paramater_32}")
24+
# if paramater_32[0] != "-1":
25+
# database_connection_query("UPDATE PARAMETERS SET DEFAULT_VALUE = -1 WHERE PARAM_ID = 32")
26+
# database_connection_query("COMMIT")
27+
# paramater_31 = database_connection_query("select DEFAULT_VALUE from PARAMETERS where PARAM_ID = 31")
28+
# print(f"paramater_31: {paramater_31}")
29+
# if paramater_31[0] != "-1":
30+
# database_connection_query("UPDATE PARAMETERS SET DEFAULT_VALUE = -1 WHERE PARAM_ID = 31")
31+
# database_connection_query("COMMIT")
32+
33+
34+
# To Do:
35+
# Create more POM
36+
# Remove as many hard coded timeouts as possible
37+
# Add more fail states
38+
# Add more logging to understand what is going on
39+
# Convert import pages * into 1 line
40+
# Move functions to utils
41+
1842
@pytest.mark.wip
1943
def test_example(page: Page) -> None:
2044
page.goto("/")
2145
BcssLoginPage(page).login_as_user_bcss401()
2246

23-
# Create plan
47+
# 2 - Create plan
2448
MainMenu(page).go_to_call_and_recall_page()
2549
CallAndRecall(page).go_to_planning_and_monitoring_page()
2650
page.get_by_role("link", name="BCS001").click()
2751
page.get_by_role("button", name="Create a Plan").click()
2852
page.get_by_role("link", name="Set all").click()
29-
page.get_by_placeholder("Enter weekly invitation rate").fill("1")
53+
page.get_by_placeholder("Enter daily invitation rate").fill("1")
3054
page.get_by_role("button", name="Update").click()
3155
page.get_by_role("button", name="Confirm").click()
3256
page.get_by_role("link", name="Set all").click()
@@ -54,7 +78,7 @@ def test_example(page: Page) -> None:
5478
# Loop until the table no longer contains "Queued"
5579
while elapsed < timeout:
5680
table_text = page.locator("#displayRS").text_content()
57-
if "Queued" in table_text:
81+
if "Queued" in table_text or "In Progress" in table_text:
5882
# Click the Refresh button
5983
page.get_by_role("button", name="Refresh").click()
6084
page.wait_for_timeout(wait_interval)
@@ -87,25 +111,30 @@ def batch_processing(page: Page, batch_type: str, batch_description: str, latest
87111
NavigationBar(page).click_main_menu_link()
88112
MainMenu(page).go_to_communications_production_page()
89113
CommunicationsProduction(page).go_to_active_batch_list_page()
90-
ActiveBatchList(page).event_code_filter.click()
91-
ActiveBatchList(page).event_code_filter.fill(batch_type)
114+
ActiveBatchList(page).enter_event_code_filter(batch_type)
92115
pre_invitation_cells = page.locator(f"//td[text()='{batch_description}']")
93116

117+
if pre_invitation_cells.count() == 0 and batch_description == "Pre-invitation (FIT) (digital leaflet)":
118+
print(f"No S1 Pre-invitation (FIT) (digital leaflet) batch found. Skipping to next step")
119+
return
120+
elif pre_invitation_cells.count() == 0 and page.locator("td", has_text="No matching records found"):
121+
pytest.fail(f"No {batch_type} {batch_description} batch found")
122+
94123
for i in range(pre_invitation_cells.count()):
95124
row = pre_invitation_cells.nth(i).locator("..") # Get the parent row
96125

97126
# Check if the row contains "Prepared" or "Open"
98-
if row.locator("td", has_text="Prepared").count() > 0 or row.locator("td", has_text="Open").count() > 0 or row.locator("td", has_text="Closed").count() > 0:
127+
if row.locator("td", has_text="Prepared").count() > 0 or row.locator("td", has_text="Open").count() > 0:
99128
# Find the first link in that row and click it
100129
link = row.locator("a").first
101130
link_text = link.inner_text() # Get the batch id dynamically
102131
link.click()
103132
break
104133
else:
105-
pytest.fail(f"No open/prepared {batch_type} batch found")
134+
pytest.fail(f"No open/prepared '{batch_type} - {batch_description}' batch found")
106135

107136
# Checks to see if batch is already prepared
108-
page.wait_for_timeout(1000) # Without this timeout prepare_button is always set to false
137+
page.wait_for_timeout(3000) # Without this timeout prepare_button is always set to false
109138
prepare_button = page.get_by_role("button", name="Prepare Batch").is_visible()
110139

111140
#If not prepared it will click on the prepare button
@@ -142,11 +171,12 @@ def batch_processing(page: Page, batch_type: str, batch_description: str, latest
142171
page.get_by_role("button", name="Confirm Printed").nth(0).click()
143172
page.wait_for_timeout(1000)
144173

174+
# Add wait for batch successfully archived
175+
145176
NavigationBar(page).click_main_menu_link()
146177
MainMenu(page).go_to_communications_production_page()
147178
CommunicationsProduction(page).go_to_archived_batch_list_page()
148-
ArchivedBatchList(page).event_code_filter.click()
149-
ArchivedBatchList(page).event_code_filter.fill(link_text)
179+
ArchivedBatchList(page).enter_id_filter(link_text)
150180
expect(page.locator("td").filter(has_text=link_text)).to_be_visible() # Checks to see if the batch is now archived
151181

152182
subject_search_by_nhs_no(page, nhs_no, latest_event_status)

utils/oracle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ def database_connection_query(sql: str): # To use when "select a from b"
1919
with connection.cursor() as cursor:
2020
for r in cursor.execute(sql):
2121
print(r)
22+
return r

0 commit comments

Comments
 (0)