Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -r47d1778fc71b2031e3c5efbefdc54873ff3baa8d -r7a928840e1bf52ae1af839a48dce76a0320c35e7 --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 47d1778fc71b2031e3c5efbefdc54873ff3baa8d) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 7a928840e1bf52ae1af839a48dce76a0320c35e7) @@ -110,10 +110,7 @@ def verify_create_treatment_parameters(): test.startSection("Pre treatment parameters") - Button = setObjectText(names.o_preTreatmentStack_Text, "Next") - - for i in range(4): - squish.mouseClick(waitForObject(Button)) + navigation_titleBar("Rx") squish.mouseClick(waitForObject(names.o_PreTreatmentCreate_pretreatmentPatientIDEntry_TextEntry)) squish.waitForObject(names.o_PreTreatmentCreate_pretreatmentPatientIDEntry_TextEntry).text ="abcd" set_value_based_on_target(names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster, 60) @@ -157,5 +154,37 @@ # td.td_operation_mode(TDOpModes.MODE_PRET.value, 0) test.endSection() +def findAllObjectsById(parent, target_id): + """ + Recursively finds all child objects by their id property. + Returns a list of all matching objects found. + """ + results = [] + + # Use hasattr to safely check for 'id' property + if hasattr(parent, 'id') and str(parent.id) == target_id: + results.append(parent) + # Recurse through all children to collect all instances + for child in object.children(parent): + results.extend(findAllObjectsById(child, target_id)) + return results + +def navigation_titleBar(targetStep): + test.startSection("Method to navigation in the pretreatment page ") + stepId = waitForObjectExists(names.o_preTreatmentStack_stepIndicator_StepIndicator) + values = findAllObjectsById(stepId, "_text") + for index, input_field in enumerate(values[2:]): + test.log(str(index)); + test.log(str(input_field.text)) + if str(input_field.text) == targetStep: + test.log("Reached the target step") + break + else: + Nextbutton = setObjectText(names.o_preTreatmentStack_Text, "Next") + squish.mouseClick(Nextbutton) + test.endSection() + + +