Skip to content

Commit e0be618

Browse files
Adjusting the test logic to skip S1 - digital leaflet if none is found.
Added more page object models and create a few fail scenarios so the test fails with a clear error message
1 parent ac9545d commit e0be618

File tree

4 files changed

+92
-11
lines changed

4 files changed

+92
-11
lines changed

pages/active_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/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(1000) # Wait for 1 second 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()

tests/Smokescreen/test_compartment_1.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,30 @@ def batch_processing(page: Page, batch_type: str, batch_description: str, latest
8787
NavigationBar(page).click_main_menu_link()
8888
MainMenu(page).go_to_communications_production_page()
8989
CommunicationsProduction(page).go_to_active_batch_list_page()
90-
ActiveBatchList(page).event_code_filter.click()
91-
ActiveBatchList(page).event_code_filter.fill(batch_type)
90+
ActiveBatchList(page).enter_event_code_filter(batch_type)
9291
pre_invitation_cells = page.locator(f"//td[text()='{batch_description}']")
9392

93+
if pre_invitation_cells.count() == 0 and batch_description == "Pre-invitation (FIT) (digital leaflet)":
94+
print(f"No S1 Pre-invitation (FIT) (digital leaflet) batch found. Skipping to next step")
95+
return
96+
elif page.locator("td", has_text="No matching records found"):
97+
pytest.fail(f"No {batch_type} {batch_description} batch found")
98+
9499
for i in range(pre_invitation_cells.count()):
95100
row = pre_invitation_cells.nth(i).locator("..") # Get the parent row
96101

97102
# 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:
103+
if row.locator("td", has_text="Prepared").count() > 0 or row.locator("td", has_text="Open").count() > 0:
99104
# Find the first link in that row and click it
100105
link = row.locator("a").first
101106
link_text = link.inner_text() # Get the batch id dynamically
102107
link.click()
103108
break
104109
else:
105-
pytest.fail(f"No open/prepared {batch_type} batch found")
110+
pytest.fail(f"No open/prepared '{batch_type} - {batch_description}' batch found")
106111

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

111116
#If not prepared it will click on the prepare button
@@ -145,8 +150,7 @@ def batch_processing(page: Page, batch_type: str, batch_description: str, latest
145150
NavigationBar(page).click_main_menu_link()
146151
MainMenu(page).go_to_communications_production_page()
147152
CommunicationsProduction(page).go_to_archived_batch_list_page()
148-
ArchivedBatchList(page).event_code_filter.click()
149-
ArchivedBatchList(page).event_code_filter.fill(link_text)
153+
ArchivedBatchList(page).enter_id_filter(link_text)
150154
expect(page.locator("td").filter(has_text=link_text)).to_be_visible() # Checks to see if the batch is now archived
151155

152156
subject_search_by_nhs_no(page, nhs_no, latest_event_status)

0 commit comments

Comments
 (0)