Skip to content

Commit 19ff575

Browse files
committed
Removed more hardcoded values from test_reports_page
1 parent 7a32ec4 commit 19ff575

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

tests/test_reports_page.py

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def test_failsafe_reports_date_report_last_requested(page: Page) -> None:
7272
Confirms 'date_report_last_requested' page loads, 'generate report' and 'refresh' buttons work as expected
7373
and the timestamp updates to current date and time when refreshed
7474
"""
75+
report_timestamp_element = page.locator("b")
76+
7577
# Go to failsafe reports page
7678
ReportsPage(page).go_to_failsafe_reports_page()
7779

@@ -85,14 +87,14 @@ def test_failsafe_reports_date_report_last_requested(page: Page) -> None:
8587
ReportsPage(page).click_generate_report_button()
8688
# Verify timestamp has updated (equals current date and time)
8789
report_timestamp = DateTimeUtils.report_timestamp_date_format()
88-
expect(page.locator("b")).to_contain_text(report_timestamp)
90+
expect(report_timestamp_element).to_contain_text(report_timestamp)
8991

9092
# Click 'refresh' button
9193
ReportsPage(page).click_refresh_button()
9294

9395
# Verify timestamp has updated (equals current date and time)
9496
report_timestamp = DateTimeUtils.report_timestamp_date_format()
95-
expect(page.locator("b")).to_contain_text(report_timestamp)
97+
expect(report_timestamp_element).to_contain_text(report_timestamp)
9698

9799

98100
@pytest.mark.only
@@ -131,7 +133,7 @@ def test_failsafe_reports_subjects_ceased_due_to_date_of_birth_changes(page: Pag
131133
"""
132134

133135
nhs_number_link = page.locator("#listReportDataTable > tbody > tr.oddTableRow > td:nth-child(1) > a")
134-
timestamp = page.locator("#displayGenerateDate > tbody > tr > td > b")
136+
report_timestamp_element = page.locator("#displayGenerateDate > tbody > tr > td > b")
135137

136138
# Go to failsafe reports page
137139
ReportsPage(page).go_to_failsafe_reports_page()
@@ -148,7 +150,7 @@ def test_failsafe_reports_subjects_ceased_due_to_date_of_birth_changes(page: Pag
148150
ReportsPage(page).click_generate_report_button()
149151
# Verify timestamp has updated to current date and time
150152
report_timestamp = DateTimeUtils.report_timestamp_date_format()
151-
expect(timestamp).to_contain_text(report_timestamp)
153+
expect(report_timestamp_element).to_contain_text(report_timestamp)
152154

153155
# Open a screening subject record from the search results
154156
nhs_number_link.click()
@@ -166,6 +168,8 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
166168
a different SC can be allocated to a patient record
167169
"""
168170

171+
report_timestamp_element = page.locator("b")
172+
169173
nhs_number_link = page.locator("//*[@id='listReportDataTable']/tbody/tr[3]/td[1]")
170174
coventry_and_warwickshire_bcs_centre = "23643"
171175

@@ -184,7 +188,7 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
184188

185189
# Verify timestamp has updated to current date and time
186190
report_timestamp = DateTimeUtils.report_timestamp_date_format()
187-
expect(page.locator("b")).to_contain_text(report_timestamp)
191+
expect(report_timestamp_element).to_contain_text(report_timestamp)
188192

189193
# Open a screening subject record from the first row/first cell of the table
190194
nhs_number_link.click()
@@ -208,6 +212,9 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_into_your_hub(page:
208212
the 'generate report' and 'refresh' buttons work as expected and
209213
the timestamp updates to current date and time when refreshed
210214
"""
215+
216+
report_timestamp_element = page.locator("b")
217+
211218
# Go to failsafe reports page
212219
ReportsPage(page).go_to_failsafe_reports_page()
213220

@@ -223,14 +230,14 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_into_your_hub(page:
223230

224231
# Verify timestamp has updated to current date and time
225232
report_timestamp = DateTimeUtils.report_timestamp_date_format()
226-
expect(page.locator("b")).to_contain_text(report_timestamp)
233+
expect(report_timestamp_element).to_contain_text(report_timestamp)
227234

228235
# Click "Refresh" button
229236
ReportsPage(page).click_refresh_button()
230237

231238
# Verify timestamp has updated to current date and time
232239
report_timestamp = DateTimeUtils.report_timestamp_date_format()
233-
expect(page.locator("b")).to_contain_text(report_timestamp)
240+
expect(report_timestamp_element).to_contain_text(report_timestamp)
234241

235242

236243
def test_failsafe_reports_identify_and_link_new_gp(page: Page) -> None:
@@ -242,7 +249,8 @@ def test_failsafe_reports_identify_and_link_new_gp(page: Page) -> None:
242249
can be opened from here
243250
"""
244251

245-
nhs_number_link = page.locator("//*[@id='listReportDataTable']/tbody/tr[3]/td[2]")
252+
nhs_number_cell_link = page.locator("//*[@id='listReportDataTable']/tbody/tr[3]/td[2]")
253+
report_timestamp_element = page.locator("b")
246254

247255
# Go to failsafe reports page
248256
ReportsPage(page).go_to_failsafe_reports_page()
@@ -258,17 +266,17 @@ def test_failsafe_reports_identify_and_link_new_gp(page: Page) -> None:
258266

259267
# Verify timestamp has updated to current date and time
260268
report_timestamp = DateTimeUtils.report_timestamp_date_format()
261-
expect(page.locator("b")).to_contain_text(report_timestamp)
269+
expect(report_timestamp_element).to_contain_text(report_timestamp)
262270

263271
# Click "Refresh" button
264272
ReportsPage(page).click_refresh_button()
265273

266274
# Verify timestamp has updated to current date and time
267275
report_timestamp = DateTimeUtils.report_timestamp_date_format()
268-
expect(page.locator("b")).to_contain_text(report_timestamp)
276+
expect(report_timestamp_element).to_contain_text(report_timestamp)
269277

270278
# Open a screening subject record from the first row/second cell of the table
271-
nhs_number_link.click()
279+
nhs_number_cell_link.click()
272280

273281
# Verify page title is "Link GP practice to Screening Centre"
274282
BasePage(page).bowel_cancer_screening_ntsh_page_title_contains_text("Link GP practice to Screening Centre")
@@ -286,6 +294,7 @@ def test_operational_reports_appointment_attendance_not_updated(page: Page) -> N
286294

287295
coventry_and_warwickshire_bcs_centre = "23643"
288296
nhs_number_link = page.locator("#listReportDataTable > tbody > tr:nth-child(3) > td:nth-child(1) > a")
297+
report_timestamp_element = page.locator("b")
289298

290299
# Go to operational reports page
291300
ReportsPage(page).go_to_operational_reports_page()
@@ -304,7 +313,7 @@ def test_operational_reports_appointment_attendance_not_updated(page: Page) -> N
304313

305314
# Verify timestamp has updated to current date and time
306315
report_timestamp = DateTimeUtils.report_timestamp_date_format()
307-
expect(page.locator("b")).to_contain_text(report_timestamp)
316+
expect(report_timestamp_element).to_contain_text(report_timestamp)
308317

309318
# Open an appointment record from the report
310319
nhs_number_link.click()
@@ -319,6 +328,9 @@ def test_operational_reports_fobt_kits_logged_but_not_read(page: Page) -> None:
319328
the 'refresh' button works as expected and
320329
the timestamp updates to current date and time when refreshed
321330
"""
331+
332+
report_generated_timestamp = page.locator("#report-generated")
333+
322334
# Go to operational reports page
323335
ReportsPage(page).go_to_operational_reports_page()
324336

@@ -333,7 +345,7 @@ def test_operational_reports_fobt_kits_logged_but_not_read(page: Page) -> None:
333345

334346
# Verify timestamp has updated to current date and time
335347
report_timestamp = DateTimeUtils.fobt_kits_logged_but_not_read_report_timestamp_date_format()
336-
expect(page.locator("#report-generated")).to_contain_text(f"Report generated on {report_timestamp}.")
348+
expect(report_generated_timestamp).to_contain_text(f"Report generated on {report_timestamp}.")
337349

338350

339351
def test_operational_reports_demographic_update_inconsistent_with_manual_update(page: Page) -> None:
@@ -361,6 +373,7 @@ def test_operational_reports_screening_practitioner_6_weeks_availability_not_set
361373
"""
362374

363375
coventry_and_warwickshire_bcs_centre = "23643"
376+
report_generated_timestamp_element = page.locator("#displayGenerateDate")
364377

365378
# Go to operational reports page
366379
ReportsPage(page).go_to_operational_reports_page()
@@ -380,14 +393,14 @@ def test_operational_reports_screening_practitioner_6_weeks_availability_not_set
380393

381394
# Verify timestamp has updated to current date and time
382395
report_timestamp = DateTimeUtils.report_timestamp_date_format()
383-
expect(page.locator("#displayGenerateDate")).to_contain_text(report_timestamp)
396+
expect(report_generated_timestamp_element).to_contain_text(report_timestamp)
384397

385398
# Click "Refresh" button
386399
ReportsPage(page).click_refresh_button()
387400

388401
# Verify timestamp has updated to current date and time
389402
report_timestamp = DateTimeUtils.report_timestamp_date_format()
390-
expect(page.locator("#displayGenerateDate")).to_contain_text(report_timestamp)
403+
expect(report_generated_timestamp_element).to_contain_text(report_timestamp)
391404

392405

393406
def test_operational_reports_screening_practitioner_appointments(page: Page) -> None:
@@ -401,6 +414,7 @@ def test_operational_reports_screening_practitioner_appointments(page: Page) ->
401414
coventry_and_warwickshire_bcs_centre = "23643"
402415
screening_practitioner_named_another_stubble = "1982"
403416
generate_report_button = page.locator("#submitThisForm") #The locator appears to be unique to this button
417+
report_timestamp_element = page.locator("b")
404418

405419
# Go to operational reports page
406420
ReportsPage(page).go_to_operational_reports_page()
@@ -422,4 +436,4 @@ def test_operational_reports_screening_practitioner_appointments(page: Page) ->
422436

423437
# Verify timestamp has updated to current date and time
424438
report_timestamp = DateTimeUtils.screening_practitioner_appointments_report_timestamp_date_format()
425-
expect(page.locator("b")).to_contain_text(report_timestamp)
439+
expect(report_timestamp_element).to_contain_text(report_timestamp)

0 commit comments

Comments
 (0)