Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -r605b0d914ce80d7252b16dcadfd88c214d2fe236 -rbddd2fe08aac52e286b53a811f0ab41919c7fea2 --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 605b0d914ce80d7252b16dcadfd88c214d2fe236) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision bddd2fe08aac52e286b53a811f0ab41919c7fea2) @@ -16,16 +16,37 @@ 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 setObjectText(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. @@ -63,16 +84,10 @@ 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: @@ -94,3 +109,65 @@ 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 + """ + 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(setObjectText(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,1000) + test.log(f"Opening slider for {parameter}...") + squish.mousePress(value_field, squish.Qt.LeftButton) + 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): + """ + Method to perform the left arrow untill the value + becomes off + """ + 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 +