Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -rd94d75c2c397752dfee66870ad4cee7dd913651d -rccc837e1c29f80a5c280de09ff637e280bd9333c --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision d94d75c2c397752dfee66870ad4cee7dd913651d) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision ccc837e1c29f80a5c280de09ff637e280bd9333c) @@ -2,10 +2,12 @@ import test import object import names -from squish import * from leahi_dialin.ui import utils from builtins import int as pyInt - +from configuration import config,navigation +from leahi_dialin.ui.td_messaging import TD_Messaging +td =TD_Messaging() + def get_object_from_names(names_dict, error_message = "Missing object", timeout_ms = 200): """ To get an object with try..except catching to prevent script errors when the object is not found on the GUI @@ -84,35 +86,37 @@ target_value: integer or string number, e.g. 220 """ + target_value = target_value + + # Wait for all objects parent_obj = squish.waitForObjectExists(obj) + # change range as per your screen count + left_arrow = findObjectById(parent_obj, "_leftArrow") right_arrow =findObjectById(parent_obj, "_rightArrow") - try: - current_value = round(float(findObject(obj).value),1) - except LookupError: - current_value = float(findObject(obj).property("value")) - + # Read current value (supports invisible text too) + + 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): """ - Method selects the option based on index from the dropdown + 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: @@ -208,3 +212,64 @@ except LookupError: test.fail("ERROR : " + error_message) return None + +def verify_create_treatment_parameters(): + test.startSection("Pre treatment parameters") + 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,config.ACID_CONCENTRATE,2) + set_value_based_on_target(names.o_PreTreatmentCreate_dialysateTemperatureControl_ValueAdjuster,37.0) + 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,config.VITALS,1) + select_different_dropdown(names.o_PreTreatmentCreate_bicarbonateConcentrateComboBox_BaseComboBox,config.BICARBONATE,0) + Validatebutton = setObjectText(obj = names.o_preTreatmentStack_Text, text =config.VALIDATE) + squish.mouseClick(squish.waitForObject(Validatebutton)) + td.td_Treatment_Parameters_Validation( vAccepted = 1, + vBloodFlowRateRejectReason = 0, + vDialysateFlowRateRejectReason = 0, + vTreatmentDurationRejectReason = 0, + vSalineBolusVolumeRejectReason = 0, + vHeparinStopTimeRejectReason = 0, + vHeparinTypeRejectReason = 0, + vAcidConcentrateRejectReason = 0, + vBicarbonateConcentrateRejectReason = 0, + vDialyzerTypeRejectReason = 0, + vBloodPressureMeasureIntervalRejectReason = 0, + vRinsebackFlowRateRejectReason = 0, + vRinsebackVolumeRejectReason = 0, + vArterialPressureLimitWindowRejectReason = 0, + vVenousPressureLimitWindowRejectReason = 0, + vVenousPressureLimitAsymtrcRejectReason = 0, + vTransmembranePressureLimitWindowRejectReason = 0, + vDialysateTempRejectReason = 0, + vHeparinDispensingRateRejectReason = 0, + vHeparinBolusVolumeRejectReason = 0 + ) + confirmButton = setObjectText(obj = names.o_preTreatmentStack_Text,text = config.CONFIRM ) + squish.mouseClick(squish.waitForObject(confirmButton)) + 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