@@ -83,6 +83,29 @@ def __init__(self, page: Page):
8383 self .redirect_to_reestablish_suitability_for_diagnostic_test_repatient_contact = self .page .get_by_role (
8484 "button" , name = "Redirect to re-establish"
8585 )
86+ # Contact recording locators
87+ self .contact_direction_dropdown = self .page .get_by_label ("Contact Direction" )
88+ self .contact_type_dropdown = self .page .get_by_label (
89+ "Contact made between patient"
90+ )
91+ self .call_date_input = self .page .locator ("#UI_CALL_DATE" )
92+ self .start_time_input = self .page .locator ("#UI_START_TIME" )
93+ self .end_time_input = self .page .locator ("#UI_END_TIME" )
94+ self .duration_input = self .page .locator ("#UI_DURATION" )
95+ self .note_input = self .page .get_by_text ("(up to 500 char)" )
96+ self .patient_contacted_dropdown = self .page .get_by_label ("Patient Contacted" )
97+ self .outcome_dropdown = self .page .get_by_label ("Outcome" )
98+ self .save_button = self .page .locator ("input[name='UI_BUTTON_SAVE']" )
99+ # CT Colonography invitation locators
100+ self .ct_colonography_appointment_date_input = self .page .locator (
101+ "#UI_APPT_DATE_38"
102+ )
103+ self .ct_colonography_test_type_dropdown = self .page .locator (
104+ "#UI_EXT_TEST_TYPE_38"
105+ )
106+ self .invite_for_diagnostic_test_button = self .page .get_by_role (
107+ "button" , name = "Invite for Diagnostic Test >>"
108+ )
86109
87110 def click_suitable_for_endoscopic_test_button (self ) -> None :
88111 """Click the 'Suitable for Endoscopic Test' button."""
@@ -207,19 +230,15 @@ def select_ct_colonography_and_invite(self) -> None:
207230
208231 # Step 1: Enter today's date
209232 today = date .today ().strftime ("%d/%m/%Y" )
210- self .page . locator ( "#UI_APPT_DATE_38" ) .fill (today )
233+ self .ct_colonography_appointment_date_input .fill (today )
211234 logging .info (f"[ADVANCE EPISODE] Entered appointment date: { today } " )
212235
213236 # Step 2: Select 'CT Colonography' from dropdown
214- self .page . locator ( "#UI_EXT_TEST_TYPE_38" ) .select_option (label = "CT Colonography" )
237+ self .ct_colonography_test_type_dropdown .select_option (label = "CT Colonography" )
215238 logging .info ("[ADVANCE EPISODE] Selected test type: CT Colonography" )
216239
217240 # Step 3: Click 'Invite for Diagnostic Test'
218- invite_button = self .page .get_by_role (
219- "button" , name = "Invite for Diagnostic Test >>"
220- )
221- self .safe_accept_dialog (invite_button )
222-
241+ self .safe_accept_dialog (self .invite_for_diagnostic_test_button )
223242 logging .info ("[ADVANCE EPISODE] Invite for diagnostic test completed" )
224243
225244 def record_contact_close_episode_no_contact (self ) -> None :
@@ -241,40 +260,38 @@ def record_contact_close_episode_no_contact(self) -> None:
241260 )
242261
243262 # Step 1: Select direction and contact type
244- self .page . get_by_label ( "Contact Direction" ) .select_option ("20159" )
245- self .page . get_by_label ( "Contact made between patient" ) .select_option ("1171" )
263+ self .contact_direction_dropdown .select_option ("20159" )
264+ self .contact_type_dropdown .select_option ("1171" )
246265 logging .info ("[CONTACT RECORD] Selected direction and contact type" )
247266
248267 # Step 2: Pick calendar date using V1 calendar picker
249268 calendar_picker = CalendarPicker (self .page )
250269 today = datetime .today ()
251- calendar_picker .calendar_picker_ddmmyyyy (
252- today , self .page .locator ("#UI_CALL_DATE" )
253- )
270+ calendar_picker .calendar_picker_ddmmyyyy (today , self .call_date_input )
254271 logging .info (
255272 f"[CONTACT RECORD] Selected calendar date: { today .strftime ('%d/%m/%Y' )} "
256273 )
257274
258275 # Step 3: Enter time details
259- self .page . locator ( "#UI_START_TIME" ) .fill ("08:00" )
260- self .page . locator ( "#UI_END_TIME" ) .fill ("08:10" )
261- self .page . locator ( "#UI_DURATION" ) .fill ("10" )
276+ self .start_time_input .fill ("08:00" )
277+ self .end_time_input .fill ("08:10" )
278+ self .duration_input .fill ("10" )
262279 logging .info ("[CONTACT RECORD] Entered time details: 08:00–08:10" )
263280
264281 # Step 4: Enter note
265- self .page . get_by_text ( "(up to 500 char)" ) .fill ("Automation test record" )
282+ self .note_input .fill ("Automation test record" )
266283 logging .info ("[CONTACT RECORD] Entered note: Automation test record" )
267284
268285 # Step 5: Select 'Patient Contacted' as 'No'
269- self .page . get_by_label ( "Patient Contacted" ) .select_option ("N" )
286+ self .patient_contacted_dropdown .select_option ("N" )
270287 logging .info ("[CONTACT RECORD] Selected 'Patient Contacted': No" )
271288
272289 # Step 6: Select outcome
273- self .page . get_by_label ( "Outcome" ) .select_option ("20202" )
290+ self .outcome_dropdown .select_option ("20202" )
274291 logging .info ("[CONTACT RECORD] Selected outcome: Close Episode - No Contact" )
275292
276293 # Step 7: Click save
277- self .page . locator ( "input[name='UI_BUTTON_SAVE']" ). click ()
294+ self .click (self . save_button )
278295 logging .info ("[CONTACT RECORD] Contact recording flow completed successfully" )
279296
280297 def click_not_suitable_for_diagnostic_tests_button (self ) -> None :
0 commit comments