Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -re2c906a7b5fde31d48d168f097fe6a5a2ab0afea -rcc11c8f30b8a4fe476e22ae98b21d17aab1ad4ad --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision e2c906a7b5fde31d48d168f097fe6a5a2ab0afea) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision cc11c8f30b8a4fe476e22ae98b21d17aab1ad4ad) @@ -1,5 +1,10 @@ import squish import test +import object +import names +from squish import * +from leahi_dialin.ui import utils +from builtins import int as pyInt def get_object_from_names(names_dict, error_message = "Missing object", timeout_ms = 200): """ @@ -12,3 +17,70 @@ except LookupError: test.fail("ERROR : " + error_message) return None + +def set_Object_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}") \ No newline at end of file Index: suite_leahi/suite.conf =================================================================== diff -u -re2c906a7b5fde31d48d168f097fe6a5a2ab0afea -rcc11c8f30b8a4fe476e22ae98b21d17aab1ad4ad --- suite_leahi/suite.conf (.../suite.conf) (revision e2c906a7b5fde31d48d168f097fe6a5a2ab0afea) +++ suite_leahi/suite.conf (.../suite.conf) (revision cc11c8f30b8a4fe476e22ae98b21d17aab1ad4ad) @@ -1,6 +1,6 @@ AUT=leahi LANGUAGE=Python OBJECTMAPSTYLE=script -TEST_CASES=tst_solution_infusion tst_main_treatment tst_service_export_logs +TEST_CASES=tst_solution_infusion tst_main_treatment tst_service_export_logs tst_ultrafiltration VERSION=3 WRAPPERS=Qt Index: suite_leahi/tst_ultrafiltration/test.py =================================================================== diff -u -rdf56ff7f6c9478cf2af7f132732016a0c78ba899 -rcc11c8f30b8a4fe476e22ae98b21d17aab1ad4ad --- suite_leahi/tst_ultrafiltration/test.py (.../test.py) (revision df56ff7f6c9478cf2af7f132732016a0c78ba899) +++ suite_leahi/tst_ultrafiltration/test.py (.../test.py) (revision cc11c8f30b8a4fe476e22ae98b21d17aab1ad4ad) @@ -17,6 +17,7 @@ import names from configuration import utility +from configuration import config from leahi_dialin.ui import utils from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.common.td_defs import TDOpModes,TDTreatmentStates @@ -48,70 +49,6 @@ MAX_NEW_UF_VOLUME = 8.0 MAX_NEW_UF_RATE = 2.0 - -def get_title_text_obj(text): - names.o_title_Text["text"] = text - return names.o_title_Text - -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 continue_edit_changes(accept,rejectionReason): payload = conversions.integer_to_bytearray(accept) payload += conversions.integer_to_bytearray(rejectionReason) @@ -156,7 +93,7 @@ def main(): utils.tstStart(__file__) - startApplication(names.AUT_NAME) + startApplication(config.AUT_NAME) td.td_operation_mode(TDOpModes.MODE_STAN.value) @@ -202,7 +139,7 @@ test.startSection("Check the values in the Ultrafiltration Volume Popup") mouseClick(waitForObject(names.o_editButton_ultrafiltration_IconButton)) #check the tittle in edit popup - title = waitForObjectExists(get_title_text_obj(ULTRAFILTRATION_VOLUME)) + title = waitForObjectExists(utility.set_Object_Text(obj=names.o_title_Text,text = ULTRAFILTRATION_VOLUME)) test.compare(title.text, ULTRAFILTRATION_VOLUME, "Title text should be -> "+ str(ULTRAFILTRATION_VOLUME)) #check the value in the edit popup uf_volume_removed_text = waitForObjectExists(names.o_ufVolumeRemovedItem_ValueItem).label @@ -221,13 +158,13 @@ mouseClick(waitForObject(names.o_backButton_BackButton)) test.verify(waitForObjectExists(names.o_editButton_TouchRect).visible,"Edit button is visible") mouseClick(waitForObject(names.o_editButton_TouchRect)) - set_value_based_on_target(names.o_volumeGoalAdjuster_ValueAdjuster, 1.50) + utility.set_value_based_on_target(names.o_volumeGoalAdjuster_ValueAdjuster, 1.50) mouseClick(waitForObject(names.o_continueButton_TouchRect)) continue_edit_changes(accept = 1, rejectionReason = 0) #check the values in the confirm ultrafiltration volume - confirm_ultrafiltrationtitle = waitForObjectExists(get_title_text_obj("Confirm Ultrafiltration Volume (L)")) + confirm_ultrafiltrationtitle = waitForObjectExists(utility.set_Object_Text(text="Confirm Ultrafiltration Volume (L)",obj = names.o_title_Text)) test.compare(confirm_ultrafiltrationtitle.text, "Confirm Ultrafiltration Volume (L)", "Title text should be -> "+ str("Confirm Ultrafiltration Volume (L)")) new_uf_volume_text = waitForObjectExists(names.o_newVolumeContainer_ValueContainer).text