11import pytest
22from playwright .sync_api import Page , expect
3-
3+ from sys import platform
44from pages .base_page import BasePage
55from pages .reports_page import ReportsPage
66from utils .click_helper import click
77from utils .date_time_utils import DateTimeUtils
88from utils .user_tools import UserTools
9+ from jproperties import Properties
10+
11+
12+ @pytest .fixture
13+ def tests_properties () -> dict :
14+ """
15+ Reads the 'bcss_tests.properties' file and populates a 'Properties' object.
16+ Returns a dictionary of properties for use in tests.
17+
18+ Returns:
19+ dict: A dictionary containing the values loaded from the 'bcss_tests.properties' file.
20+ """
21+ configs = Properties ()
22+ if platform == "win32" : # File path from content root is required on Windows OS
23+ with open ('tests/bcss_tests.properties' , 'rb' ) as read_prop :
24+ configs .load (read_prop )
25+ elif platform == "darwin" : # Only the filename is required on macOS
26+ with open ('bcss_tests.properties' , 'rb' ) as read_prop :
27+ configs .load (read_prop )
28+ return configs .properties
929
1030
1131@pytest .fixture (scope = "function" , autouse = True )
@@ -97,13 +117,12 @@ def test_failsafe_reports_date_report_last_requested(page: Page) -> None:
97117 expect (report_timestamp_element ).to_contain_text (report_timestamp )
98118
99119
100- @pytest .mark .only
101120def test_failsafe_reports_screening_subjects_with_inactive_open_episode (page : Page ) -> None :
102121 """
103122 Confirms 'screening_subjects_with_inactive_open_episode' page loads, 'generate report' button works as expected
104123 and that a screening subject record can be opened
105124 """
106- nhs_number_link = page .get_by_role ("cell" , name = "7652" )
125+ nhs_number_link = page .get_by_role ("cell" , name = "7652" ) # This value is specific to this test only
107126
108127 # Go to failsafe reports page
109128 ReportsPage (page ).go_to_failsafe_reports_page ()
@@ -159,7 +178,9 @@ def test_failsafe_reports_subjects_ceased_due_to_date_of_birth_changes(page: Pag
159178 BasePage (page ).bowel_cancer_screening_ntsh_page_title_contains_text ("Subject Demographic" )
160179
161180
162- def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundaries (page : Page ) -> None :
181+ @pytest .mark .only
182+ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundaries (page : Page ,
183+ tests_properties : dict ) -> None :
163184 """
164185 Confirms 'allocate_sc_for_patient_movements_within_hub_boundaries' page loads,
165186 the 'generate report' button works as expected
@@ -169,9 +190,7 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
169190 """
170191
171192 report_timestamp_element = page .locator ("b" )
172-
173193 nhs_number_link = page .locator ("//*[@id='listReportDataTable']/tbody/tr[3]/td[1]" )
174- coventry_and_warwickshire_bcs_centre = "23643"
175194
176195 # Go to failsafe reports page
177196 ReportsPage (page ).go_to_failsafe_reports_page ()
@@ -197,13 +216,13 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
197216 BasePage (page ).bowel_cancer_screening_ntsh_page_title_contains_text ("Set Patient's Screening Centre" )
198217
199218 # Select another screening centre
200- page .locator ("#cboScreeningCentre" ).select_option (coventry_and_warwickshire_bcs_centre )
219+ page .locator ("#cboScreeningCentre" ).select_option (tests_properties [ " coventry_and_warwickshire_bcs_centre" ] )
201220
202221 # Click update
203222 ReportsPage (page ).click_reports_pages_update_button ()
204223
205224 # Verify new screening centre has saved
206- expect (page .locator ("#cboScreeningCentre" )).to_have_value (coventry_and_warwickshire_bcs_centre )
225+ expect (page .locator ("#cboScreeningCentre" )).to_have_value (tests_properties [ " coventry_and_warwickshire_bcs_centre" ] )
207226
208227
209228def test_failsafe_reports_allocate_sc_for_patient_movements_into_your_hub (page : Page ) -> None :
@@ -413,7 +432,7 @@ def test_operational_reports_screening_practitioner_appointments(page: Page) ->
413432
414433 coventry_and_warwickshire_bcs_centre = "23643"
415434 screening_practitioner_named_another_stubble = "1982"
416- generate_report_button = page .locator ("#submitThisForm" ) # The locator appears to be unique to this button
435+ generate_report_button = page .locator ("#submitThisForm" ) # The locator appears to be unique to this button
417436 report_timestamp_element = page .locator ("b" )
418437
419438 # Go to operational reports page
0 commit comments