1414from pages .archived_batch_list_page import *
1515from pages .navigation_bar_links import *
1616from pages .subject_screening_page import *
17-
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-
17+ from pages .manage_active_batch_page import *
18+ from pages .invitations_monitoring_page import *
19+ from pages .create_a_plan_page import *
20+ from pages .invitations_plans_page import *
3321
3422# To Do:
35- # Create more POM
36- # Remove as many hard coded timeouts as possible
23+ # Create more POMs
3724# Add more fail states
3825# Add more logging to understand what is going on
3926# Convert import pages * into 1 line
4027# Move functions to utils
28+ # Remove as many hard coded timeouts as possible
29+ # Create a generic click() function -> this aims to solve an issue where sometimes it thinks it has clicked the element but the page does not change
4130
4231@pytest .mark .wip
4332def test_example (page : Page ) -> None :
4433 page .goto ("/" )
4534 BcssLoginPage (page ).login_as_user_bcss401 ()
4635
47- # 2 - Create plan
36+ # Create plan
4837 MainMenu (page ).go_to_call_and_recall_page ()
4938 CallAndRecall (page ).go_to_planning_and_monitoring_page ()
50- page .get_by_role ("link" , name = "BCS001" ).click ()
51- page .get_by_role ("button" , name = "Create a Plan" ).click ()
52- page .get_by_role ("link" , name = "Set all" ).click ()
53- page .get_by_placeholder ("Enter daily invitation rate" ).fill ("1" )
54- page .get_by_role ("button" , name = "Update" ).click ()
55- page .get_by_role ("button" , name = "Confirm" ).click ()
56- page .get_by_role ("link" , name = "Set all" ).click ()
57- page .get_by_role ("button" , name = "Close" ).click ()
58- page .get_by_role ("button" , name = "Save" ).click ()
59- page .get_by_placeholder ("Enter note" ).fill ("test data" )
60- page .locator ("#saveNote" ).get_by_role ("button" , name = "Save" ).click ()
39+ InvitationsMonitoring (page ).go_to_bcss001_invitations_plan_page ()
40+ InvitationsPlans (page ).go_to_create_a_plan_page ()
41+ CreateAPlan (page ).click_set_all_button ()
42+ CreateAPlan (page ).fill_daily_invitation_rate_field ("1" )
43+ CreateAPlan (page ).click_update_button ()
44+ CreateAPlan (page ).click_confirm_button ()
45+ CreateAPlan (page ).click_save_button ()
46+ CreateAPlan (page ).fill_note_field ("test data" )
47+ CreateAPlan (page ).click_saveNote_button ()
6148
6249 # Generate Invitations
6350 NavigationBar (page ).click_main_menu_link ()
@@ -135,21 +122,21 @@ def batch_processing(page: Page, batch_type: str, batch_description: str, latest
135122
136123 # Checks to see if batch is already prepared
137124 page .wait_for_timeout (3000 ) # Without this timeout prepare_button is always set to false
138- prepare_button = page . get_by_role ( "button" , name = "Prepare Batch" ) .is_visible ()
125+ prepare_button = ManageActiveBatch ( page ). prepare_button_text .is_visible ()
139126
140127 #If not prepared it will click on the prepare button
141128 if prepare_button :
142- page . get_by_role ( "button" , name = "Prepare Batch" ). click ()
129+ ManageActiveBatch ( page ). click_prepare_button ()
143130
144- page . locator ( 'text="Retrieve"' ) .nth (0 ).wait_for ()
131+ ManageActiveBatch ( page ). retrieve_button_text .nth (0 ).wait_for ()
145132 page .wait_for_timeout (5000 ) # This 5 second wait is to allow other Retrieve buttons to show as they do not show up at the same time
146133
147134 # This loops through each Retrieve button and clicks each one
148- for retrieve_button in range (page . get_by_role ( "button" , name = "Retrieve" ) .count ()):
135+ for retrieve_button in range (ManageActiveBatch ( page ). retrieve_button .count ()):
149136 # Start waiting for the pdf download
150137 with page .expect_download () as download_info :
151138 # Perform the action that initiates download
152- page . get_by_role ( "button" , name = "Retrieve" ) .nth (retrieve_button - 1 ).click ()
139+ ManageActiveBatch ( page ). retrieve_button .nth (retrieve_button - 1 ).click ()
153140 download_file = download_info .value
154141 file = download_file .suggested_filename
155142 # Wait for the download process to complete and save the downloaded file in a temp folder
@@ -162,13 +149,13 @@ def batch_processing(page: Page, batch_type: str, batch_description: str, latest
162149 csv_df = csv_Reader (file ) # Currently no use in compartment 1, will be necessary for future compartments
163150 os .remove (file ) # Deletes the file after extracting the necessary data
164151
165- page . locator ( 'text="Confirm Printed"' ) .nth (0 ).wait_for ()
152+ ManageActiveBatch ( page ). confirm_button_text .nth (0 ).wait_for ()
166153 page .wait_for_timeout (1000 ) # This 1 second wait is to allow other Confirm printed buttons to show as they do not show up at the same time
167154
168155 # This loops through each Confirm printed button and clicks each one
169- for _ in range (page . get_by_role ( "button" , name = "Confirm Printed" ) .count ()):
156+ for _ in range (ManageActiveBatch ( page ). confirm_button .count ()):
170157 page .on ("dialog" , lambda dialog : dialog .accept ())
171- page . get_by_role ( "button" , name = "Confirm Printed" ) .nth (0 ).click ()
158+ ManageActiveBatch ( page ). confirm_button .nth (0 ).click ()
172159 page .wait_for_timeout (1000 )
173160
174161 # Add wait for batch successfully archived
@@ -193,7 +180,7 @@ def pdf_Reader(file: str):
193180 for split_text in text :
194181 if "NHS No" in split_text :
195182 # If a string is found containing "NHS No" only digits are stored into nhs_no
196- nhs_no = res = "" .join ([ele for ele in split_text if ele .isdigit ()])
183+ nhs_no = "" .join ([ele for ele in split_text if ele .isdigit ()])
197184 break
198185 return nhs_no
199186
0 commit comments