Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -r7a928840e1bf52ae1af839a48dce76a0320c35e7 -rfb27385d1c510f6d3b433ace7e2f2e7d5dda4012 --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 7a928840e1bf52ae1af839a48dce76a0320c35e7) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision fb27385d1c510f6d3b433ace7e2f2e7d5dda4012) @@ -1,18 +1,12 @@ import squish import test import object -from squish import * import names from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.common.td_defs import TDOpModes,TDTreatmentStates +from configuration import config, navigation td =TD_Messaging() - - -ACID_CONCENTRATE = ["1.0 K, 2.50 Ca, 1 Mg","2.0 K, 2.50 Ca, 1 Mg","3.0 K, 2.50 Ca, 1 Mg"] -DIALYZER_TYPE = ["Diacap Pro 13H","Diacap Pro 16H", "Diacap Pro 19H", "Optiflux F160NRe", "Optiflux F180NRe", "Optiflux F200NRe","Optiflux F250NRe"] -VITALS = ["OFF","5","10","15","20","30","60"] -BICARBONATE = ["Sodium Bicarbonate"] def get_object_from_names(names_dict, error_message = "Missing object", timeout_ms = 200): """ @@ -75,29 +69,28 @@ right_arrow =findObjectById(parent_obj, "_rightArrow") # Read current value (supports invisible text too) - try: - current_value = round(float(findObject(obj).value),1) - except LookupError: - current_value = float(findObject(obj).property("value")) - + + current_value = round(float(squish.findObject(obj).value),1) + # Determine direction while current_value != float(target_value): if current_value < float(target_value): squish.mouseClick(squish.waitForObject(right_arrow)) elif current_value > float(target_value): squish.mouseClick(squish.waitForObject(left_arrow)) - # Update current value after click - try: - current_value = round(float(findObject(obj).value),1) - except Exception: - current_value = float(findObject(obj).property("value")) - + + current_value = round(float(squish.findObject(obj).value),1) + test.log(f"Updated value: {current_value}") test.log(f"✅ Target value reached: {current_value}") def select_different_dropdown(object,type,whichTypeIndex): + """ + Selects a value from a dropdown using a doc string. + + """ type_combo_box = get_object_from_names(object, error_message="Combo box object is missing") if type_combo_box is not None: squish.mouseClick(squish.waitForObjectExists(object)) @@ -110,23 +103,23 @@ def verify_create_treatment_parameters(): test.startSection("Pre treatment parameters") - navigation_titleBar("Rx") - squish.mouseClick(waitForObject(names.o_PreTreatmentCreate_pretreatmentPatientIDEntry_TextEntry)) + navigation.navigation_pageIndicator_step(config.CREATERX) + squish.mouseClick(squish.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) set_value_based_on_target(names.o_PreTreatmentCreate_dialysateFlowRateControl_ValueAdjuster, 75) set_value_based_on_target(names.o_PreTreatmentCreate_durationControl_ValueAdjuster, 75) set_value_based_on_target(names.o_PreTreatmentCreate_heparinBolusVolumeControl_ValueAdjuster, 0.4) set_value_based_on_target(names.o_PreTreatmentCreate_heparinDispensingRateControl_ValueAdjuster, 0.5) set_value_based_on_target(names.o_PreTreatmentCreate_heparinStopTimeControl_ValueAdjuster, 60) - select_different_dropdown(names.o_PreTreatmentCreate_acidConcentrateComboBox_BaseComboBox,ACID_CONCENTRATE,2) + select_different_dropdown(names.o_PreTreatmentCreate_acidConcentrateComboBox_BaseComboBox,config.ACID_CONCENTRATE,2) set_value_based_on_target(names.o_PreTreatmentCreate_dialysateTemperatureControl_ValueAdjuster,37.0) - select_different_dropdown(names.o_PreTreatmentCreate_dialyzerTypeComboBox_BaseComboBox,DIALYZER_TYPE,2) + select_different_dropdown(names.o_PreTreatmentCreate_dialyzerTypeComboBox_BaseComboBox,config.DIALYZER_TYPE,2) set_value_based_on_target(names.o_PreTreatmentCreate_salineBolusVolumeControl_ValueAdjuster, 200) - select_different_dropdown(names.o_PreTreatment_vitalsCombobox_BaseCombobox,VITALS,1) - select_different_dropdown(names.o_PreTreatmentCreate_bicarbonateConcentrateComboBox_BaseComboBox,BICARBONATE,0) - Validatebutton = setObjectText(names.o_preTreatmentStack_Text, "VALIDATE") - squish.mouseClick(waitForObject(Validatebutton)) + select_different_dropdown(names.o_PreTreatment_vitalsCombobox_BaseCombobox,config.VITALS,1) + select_different_dropdown(names.o_PreTreatmentCreate_bicarbonateConcentrateComboBox_BaseComboBox,config.BICARBONATE,0) + Validatebutton = setObjectText(names.o_preTreatmentStack_Text, config.VALIDATE) + squish.mouseClick(squish.waitForObject(Validatebutton)) td.td_Treatment_Parameters_Validation( vAccepted = 1, vBloodFlowRateRejectReason = 0, vDialysateFlowRateRejectReason = 0, @@ -149,9 +142,8 @@ vHeparinBolusVolumeRejectReason = 0 ) - confirmButton = setObjectText(names.o_preTreatmentStack_Text, "CONFIRM") - squish.mouseClick(waitForObject(confirmButton)) - # td.td_operation_mode(TDOpModes.MODE_PRET.value, 0) + confirmButton = setObjectText(names.o_preTreatmentStack_Text,config.CONFIRM ) + squish.mouseClick(squish.waitForObject(confirmButton)) test.endSection() def findAllObjectsById(parent, target_id): @@ -171,20 +163,6 @@ 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() - +