Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -r7f3eb286e193636d9c48f59683063c268112f06f -r17a6f169534356e32110542fb0221cf58d6a09f7 --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 7f3eb286e193636d9c48f59683063c268112f06f) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 17a6f169534356e32110542fb0221cf58d6a09f7) @@ -1,6 +1,12 @@ import squish import test +import object +import names +from squish import * +from leahi_dialin.ui import utils +from builtins import int as pyInt from datetime import datetime + def get_object_from_names(names_dict, error_message = "Missing object", timeout_ms = 200): """ @@ -12,9 +18,154 @@ return squish.waitForObject(names_dict, timeout_ms) except LookupError: test.fail("ERROR : " + error_message) - return None + return None + +def get_bullet_object(screen_obj, num): + """ + To obtain a bullet object based on occurrence provided. + @param screen_obj: provides the container on which the bullet must be present + @param num: provides the occurrence value + @returns a real name object + """ + names.o_bullet_object["container"] = screen_obj + names.o_bullet_object["occurrence"] = num + 1 + return names.o_bullet_object +def get_text_object(screen_obj, txt): + """ + To obtain a text object based on text provided + @param screen_obj: provides the container on which the txt must be present + @returns a real name object + """ + names.o_text_object["container"] = screen_obj + names.o_text_object["text"] = txt + return names.o_text_object + +def set_property_text(text,obj): + """ + Method to set object property based on text + @param text : (string) treatment parameter text + """ + obj["text"] = text + return obj + +def findObjectById(parent, id): + """ + Recursively searches for a child object by its id. + Returns the found object or None if not found. + """ + if str(parent.id) == id: + return parent + + for child in object.children(parent): + found = findObjectById(child, id) + if found: + return found + + return None + +def set_value_based_on_target(obj, target_value): + """ + obj: dictionary containing object paths + Example: + { + "value_obj": ":mainTreatmentScreen.PressureText", + "left_arrow": ":mainTreatmentScreen.LeftArrow", + "right_arrow": ":mainTreatmentScreen.RightArrow" + } + + 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") + + # 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")) + + # 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")) + + test.log(f"Updated value: {current_value}") + + test.log(f"✅ Target value reached: {current_value}") + +def select_different_dropdown(object,type,whichTypeIndex): + 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)) + + type_option = get_object_from_names(set_property_text(obj = names.o_option_combo_box,text = type[whichTypeIndex]),error_message=f"Option {type[whichTypeIndex]} object is missing",timeout_ms=5000) + if type_option is not None: + squish.mouseClick(type_option) + return True + return False # default return if not successful + +def set_value_with_slider(value_field_obj, slider_obj,parameter): + """ + Opens the slider and moves it gradually to the target value (step of 10). + Uses controlled arrow key input for fine adjustment. + """ + + try: + value_field = waitForObject(value_field_obj) + test.log(f"Opening slider for {parameter}...") + + # Try right-click first + squish.mousePress(value_field, squish.Qt.LeftButton) + # utils.waitForGUI(0.2) + value = value_field.value + + # If not visible, try left long-press + if not object.exists(slider_obj): + test.log(f"{parameter}: Slider not opened by left-click, trying long left-press...") + squish.mousePress(value_field, squish.Qt.LeftButton) + if not object.exists(slider_obj): + test.fail(f"{parameter}: Slider did not appear.") + + slider = waitForObject(slider_obj) + test.log(f"{parameter}: Slider appeared successfully.") + squish.mousePress(slider,squish.Qt.LeftButton) + final_value = waitForObject(value_field_obj).value + test.verify(final_value!= value, f"{parameter} slider adjusted correctly to {final_value}") + squish.mouseRelease(slider, squish.Qt.LeftButton) + if object.exists(slider_obj): + test.log(f"Waiting for {parameter} slider to close...") + waitFor(lambda: not object.exists(slider_obj), 1000) + except LookupError as e: + test.fail(f"{parameter}: LookupError - {e}") + +def click_left_until_off(object_name): + parent_obj = waitForObject(object_name) + left_arrow = findObjectById(parent_obj, "_leftArrow") + + # Loop until the value becomes "off" + while findObject(object_name).value != 0.0: + squish.mouseClick(waitForObject(left_arrow)) + utils.waitForGUI(0.2) # Small delay to allow UI to update + +def get_title_text_obj(text): + names.o_title_Text["text"] = text + return names.o_title_Text + def get_current_date_and_time(date_format='%Y/%b/%d - %H:%M'): date = datetime.now() - return str(date.strftime(date_format)) - + return str(date.strftime(date_format)) \ No newline at end of file Index: suite_leahi/shared/scripts/names.py =================================================================== diff -u -r7f3eb286e193636d9c48f59683063c268112f06f -r17a6f169534356e32110542fb0221cf58d6a09f7 --- suite_leahi/shared/scripts/names.py (.../names.py) (revision 7f3eb286e193636d9c48f59683063c268112f06f) +++ suite_leahi/shared/scripts/names.py (.../names.py) (revision 17a6f169534356e32110542fb0221cf58d6a09f7) @@ -2,8 +2,6 @@ from objectmaphelper import * -AUT_NAME = "leahi -k -K -S -q" - # Top Parents o_Gui_MainView = { "type": "Gui::MainView", "unnamed": 1 } o_QQuickView = { "type": "QQuickView" } @@ -60,6 +58,8 @@ #patient vitals o_option_combo_box = {"container": o_Overlay, "type": "Text", "unnamed": 1 } +o_treatmentVitals = {"container": mainTreatmentScreen, "objectName": "treatmentVitals", "type": "TreatmentVitals" } +o_treatmentHome_editButton_IconButton = {"container": o_treatmentVitals, "id": "_editButton", "type": "IconButton", "unnamed": 1 } o_PreTreatmentCreateStack_PreTreatmentCreateStack = {"container": o_Gui_MainView, "objectName": "_PreTreatmentCreateStack","type": "PreTreatmentCreateStack", } o_PreTreatmentCreateStack_PreTreatmentCreate_PreTreatmentCreate = {"container": o_PreTreatmentCreateStack_PreTreatmentCreateStack, "objectName": "_PreTreatmentCreate", "type": "PreTreatmentCreate", } o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster = {"container": o_PreTreatmentCreateStack_PreTreatmentCreate_PreTreatmentCreate, "id": "_bloodFlowRateControl", "type": "ValueAdjuster", "unnamed": 1 } @@ -83,7 +83,6 @@ o_heartRate_TextEntry = {"container": o_Overlay, "id": "_heartRate", "type": "TextEntry", "unnamed": 1 } o_confirm_button = {"container": o_Overlay, "id": "_confirmButton", "type": "ConfirmButton", "unnamed": 1 } o_treatmentHome_bloodPressure_LabelValue = {"container": mainTreatmentScreen, "id": "_bloodPressure", "type": "LabelValue", "unnamed": 1 } -o_treatmentHome_editButton_IconButton = {"container": mainTreatmentScreen, "id": "_editButton", "type": "IconButton", "unnamed": 1,"visible": True } o_vitals_Interval_TitleText = {"container": o_Overlay, "type": "TitleText", "unnamed": 1 } o_vitals_Interval_BaseComboBox = {"container": o_Overlay, "id": "_bpMeasurementIntervalControl", "type": "BaseComboBox", "unnamed": 1 } o_treatmentHome_heartBeat_LabelValue = {"container": mainTreatmentScreen, "id": "_heartBeat", "type": "LabelValue", "unnamed": 1 } Index: suite_leahi/tst_patient_vitals/test.py =================================================================== diff -u -r7f3eb286e193636d9c48f59683063c268112f06f -r17a6f169534356e32110542fb0221cf58d6a09f7 --- suite_leahi/tst_patient_vitals/test.py (.../test.py) (revision 7f3eb286e193636d9c48f59683063c268112f06f) +++ suite_leahi/tst_patient_vitals/test.py (.../test.py) (revision 17a6f169534356e32110542fb0221cf58d6a09f7) @@ -17,6 +17,7 @@ import builtins from leahi_dialin.ui import utils from configuration import utility +from configuration import config from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.common.td_defs import TDOpModes,TDTreatmentStates from datetime import datetime @@ -48,102 +49,22 @@ VISIBLE = True - -def findObjectById(parent, id): - """ - Recursively searches for a child object by its id. - Returns the found object or None if not found. - """ - if str(parent.id) == id: - return parent - - for child in object.children(parent): - found = findObjectById(child, id) - if found: - return found - - return None - -def set_value_based_on_target(obj, target_value): - """ - obj: dictionary containing object paths - Example: - { - "value_obj": ":mainTreatmentScreen.PressureText", - "left_arrow": ":mainTreatmentScreen.LeftArrow", - "right_arrow": ":mainTreatmentScreen.RightArrow" - } - - target_value: integer or string number, e.g. 220 - """ - target_value = target_value - - # Wait for all objects - parent_obj = waitForObjectExists(obj) - - # change range as per your screen count - left_arrow = findObjectById(parent_obj, "_leftArrow") - 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")) - - # Determine direction - while current_value != float(target_value): - if current_value < float(target_value): - mouseClick(waitForObject(right_arrow)) - - elif current_value > float(target_value): - mouseClick(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")) - - test.log(f"Updated value: {current_value}") - test.log(f"✅Target value reached: {current_value}") - -def custom_object_for_combo_box(text): - """ - Method to set custom object property for export option - @param text : (string) parameter text - """ - names.o_option_combo_box["text"] = text - return names.o_option_combo_box - -def select_different_dropdown(object,type,whichTypeIndex): - type_combo_box = utility.get_object_from_names(object, error_message="Combo box object is missing") - if type_combo_box is not None: - mouseClick(waitForObjectExists(object)) - - type_option = utility.get_object_from_names(custom_object_for_combo_box(type[whichTypeIndex]), - error_message=f"Option {type[whichTypeIndex]} object is missing",timeout_ms=5000) - if type_option is not None: - mouseClick(waitForObject(type_option)) - return True - return False # default return if not successful - def verify_create_treatment_parameters(): test.startSection("Pre treatment parameters") mouseClick(waitForObject(names.o_PatientIDEntry_TextEntry)) waitForObject(names.o_PatientIDEntry_TextEntry).text ="abcd" - set_value_based_on_target(names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster, 90) - set_value_based_on_target(names.o_PreTreatmentCreate_dialysateFlowRateControl_ValueAdjuster, 100) - set_value_based_on_target(names.o_PreTreatmentCreate_durationControl_ValueAdjuster, 105) - 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, 105) - select_different_dropdown(names.o_PreTreatmentCreate_acidConcentrateComboBox_BaseComboBox,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) - set_value_based_on_target(names.o_PreTreatmentCreate_salineBolusVolumeControl_ValueAdjuster, 100) - select_different_dropdown(names.o_PreTreatment_vitalsCombobox_BaseCombobox,VITALS,2) - select_different_dropdown(names.o_PreTreatmentCreate_bicarbonateConcentrateComboBox_BaseComboBox,BICARBONATE,0) + utility.set_value_based_on_target(names.o_PreTreatmentCreate_bloodFlowRateControl_ValueAdjuster, 90) + utility.set_value_based_on_target(names.o_PreTreatmentCreate_dialysateFlowRateControl_ValueAdjuster, 100) + utility.set_value_based_on_target(names.o_PreTreatmentCreate_durationControl_ValueAdjuster, 105) + utility.set_value_based_on_target(names.o_PreTreatmentCreate_heparinBolusVolumeControl_ValueAdjuster, 0.4) + utility.set_value_based_on_target(names.o_PreTreatmentCreate_heparinDispensingRateControl_ValueAdjuster, 0.5) + utility.set_value_based_on_target(names.o_PreTreatmentCreate_heparinStopTimeControl_ValueAdjuster, 105) + utility.select_different_dropdown(names.o_PreTreatmentCreate_acidConcentrateComboBox_BaseComboBox,ACID_CONCENTRATE,2) + utility.set_value_based_on_target(names.o_PreTreatmentCreate_dialysateTemperatureControl_ValueAdjuster,37.0) + utility.select_different_dropdown(names.o_PreTreatmentCreate_dialyzerTypeComboBox_BaseComboBox,DIALYZER_TYPE,2) + utility.set_value_based_on_target(names.o_PreTreatmentCreate_salineBolusVolumeControl_ValueAdjuster, 100) + utility.select_different_dropdown(names.o_PreTreatment_vitalsCombobox_BaseCombobox,VITALS,2) + utility.select_different_dropdown(names.o_PreTreatmentCreate_bicarbonateConcentrateComboBox_BaseComboBox,BICARBONATE,0) mouseClick(waitForObject(names.o_PreTreatmentButtom)) td.td_Treatment_Parameters_Validation( vAccepted = 1, vBloodFlowRateRejectReason = 0, @@ -172,10 +93,6 @@ td.td_operation_mode(TDOpModes.MODE_PRET.value, 0) test.endSection() -def get_title_text_obj(text): - names.o_title_Text["text"] = text - return names.o_title_Text - def keyboard_object_map_helper(text): """ Method for setting custom object property's for keyboard keys @@ -197,26 +114,18 @@ mouseClick(input_field) #check the title - title = waitForObjectExists(get_title_text_obj(title_name)) + title = waitForObjectExists(utility.get_title_text_parameter(title_name)) test.compare(title_name, title.text, "Title text should be -> "+ str(title_name)) for text in expected_value: keyboard_value = keyboard_object_map_helper(text) - utils.waitForGUI(0.6) + utils.waitForGUI(0.2) mouseClick(waitForObjectExists(keyboard_value)) - utils.waitForGUI(0.6) + utils.waitForGUI(0.2) test.compare(actual_value, (input_field.text), "Value should be -> "+ str(actual_value)) test.log("User successfully authenticated through patient id -> " + expected_value + "using keypad.") - -def custom_object_for_combo_box(text): - """ - Method to set custom object property for export option - @param text : (string) parameter text - """ - names.o_option_combo_box["text"] = text - return names.o_option_combo_box - + def verify_vitals_pop_up_is_opened_automatically_after_an_interval(interval): """ Method to verify the vitals pop up @@ -229,7 +138,6 @@ start_time = time.time() sec_count = 0 while not(object.exists(names.o_vitals_close_btn)): - utils.waitForGUI(1) sec_count += 1 end_time = time.time() if sec_count in range(295, 301): @@ -247,7 +155,6 @@ start_time = time.time() sec_count = 0 while not(object.exists(names.o_vitals_close_btn)): - utils.waitForGUI(1) sec_count += 1 end_time = time.time() if sec_count in range(295, 301): @@ -264,7 +171,6 @@ entered_value = str(input_field.text) if len(entered_value) != 0: for value in range(len(entered_value)+1): - utils.waitForGUI(0.1) squish.mouseClick(squish.waitForObjectExists(names.o_back_space_key)) test.compare(str(input_field.text), "", "Input field should be empty") @@ -309,7 +215,6 @@ test.startSection("Verify popup is opened automatically after time interval") verify_entered_patient_vitals_in_maintreatment_screen() td.td_vitals_adjustment_response(vRejectionReason=1) - utils.waitForGUI(1) verify_vitals_pop_up_is_opened_automatically_after_an_interval(interval=10) test.endSection() @@ -360,7 +265,7 @@ def main(): utils.tstStart(__file__) - startApplication(names.AUT_NAME) + startApplication(config.AUT_NAME) td.td_operation_mode(TDOpModes.MODE_STAN.value) @@ -383,7 +288,7 @@ 0 , 0 , 0) - utils.waitForGUI(2) + utils.waitForGUI(1) validate_time_interval(names.o_vitalCountdown_Text,10) test.endSection() @@ -426,16 +331,16 @@ #check the title text in the popup vitals_titleText = waitForObjectExists(names.o_vitals_Interval_TitleText).text test.compare("Vitals Interval", vitals_titleText, "Vitals Interval popup text should be ->"+str("Vitals Interval")) - select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,0) - select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,1) + utility.select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,0) + utility.select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,1) test.compare(waitForObject(names.o_vitals_Interval_BaseComboBox).currentText, VITALS[1], "Vitals interval value should be :"+str(VITALS[1])) - select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,2) + utility.select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,2) test.compare(waitForObject(names.o_vitals_Interval_BaseComboBox).currentText, VITALS[2], "Vitals interval value should be :"+str(VITALS[2])) - select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,3) + utility.select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,3) test.compare(waitForObject(names.o_vitals_Interval_BaseComboBox).currentText, VITALS[3], "Vitals interval value should be :"+str(VITALS[3])) - select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,4) + utility.select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,4) test.compare(waitForObject(names.o_vitals_Interval_BaseComboBox).currentText, VITALS[4], "Vitals interval value should be :"+str(VITALS[4])) - select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,5) + utility.select_different_dropdown(names.o_vitals_Interval_BaseComboBox,VITALS,5) test.compare(waitForObject(names.o_vitals_Interval_BaseComboBox).currentText, VITALS[5], "Vitals interval value should be :"+str(VITALS[5])) mouseClick(waitForObject(names.o_vitals_close_btn)) test.endSection() @@ -456,6 +361,7 @@ systime = sys_time.split("-")[1].strip() test.compare(lastdatetime, systime, "Last read time is updated properly") test.endSection() + utils.tstDone() \ No newline at end of file