Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -rc7d96b722594bb29a7bbc3689715b90af6e3d616 -r6f50d4bea7fb93aa7c03d1aa0e98cc7e5e9cd859 --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision c7d96b722594bb29a7bbc3689715b90af6e3d616) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 6f50d4bea7fb93aa7c03d1aa0e98cc7e5e9cd859) @@ -2,13 +2,21 @@ import test import object import names +<<<<<<< HEAD +from squish import * +from leahi_dialin.ui import utils +from builtins import int as pyInt +from datetime import datetime + +======= 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() from leahi_dialin.ui import utils from builtins import int as pyInt +>>>>>>> origin/staging def get_object_from_names(names_dict, error_message = "Missing object", timeout_ms = 200): """ @@ -22,6 +30,8 @@ test.fail("ERROR : " + error_message) return None +<<<<<<< HEAD +======= def get_bullet_object(screen_obj, num): """ To obtain a bullet object based on occurrence provided. @@ -43,6 +53,7 @@ names.o_text_object["text"] = txt return names.o_text_object +>>>>>>> origin/staging def setObjectText(text,obj): """ Method to set object property based on text @@ -63,8 +74,13 @@ found = findObjectById(child, id) if found: return found +<<<<<<< HEAD + return None +======= + return None + def findChildByText(parent_object, target_text): """Recursively finds a child object by its text property.""" for child in object.children(parent_object): @@ -74,6 +90,7 @@ if found: return found +>>>>>>> origin/staging def set_value_based_on_target(obj, target_value): """ obj: dictionary containing object paths @@ -96,28 +113,48 @@ right_arrow =findObjectById(parent_obj, "_rightArrow") # Read current value (supports invisible text too) +<<<<<<< HEAD + 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) +>>>>>>> origin/staging # 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)) +<<<<<<< HEAD + # 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) +>>>>>>> origin/staging test.log(f"Updated value: {current_value}") test.log(f"✅ Target value reached: {current_value}") def select_different_dropdown(object,type,whichTypeIndex): +<<<<<<< HEAD +======= """ Selects a value from a dropdown using a doc string. """ +>>>>>>> origin/staging 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)) @@ -128,6 +165,8 @@ return True return False # default return if not successful +<<<<<<< HEAD +======= def verify_create_treatment_parameters(): test.startSection("Pre treatment parameters") navigation.navigation_pageIndicator_step(config.CREATERX) @@ -194,23 +233,36 @@ +>>>>>>> origin/staging 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: +<<<<<<< HEAD + 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_field = waitForObject(value_field_obj,1000) test.log(f"Opening slider for {parameter}...") squish.mousePress(value_field, squish.Qt.LeftButton) +>>>>>>> origin/staging 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) +<<<<<<< HEAD +======= +>>>>>>> origin/staging if not object.exists(slider_obj): test.fail(f"{parameter}: Slider did not appear.") @@ -220,6 +272,17 @@ 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) +<<<<<<< HEAD + 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 get_current_date_and_time(date_format='%Y/%b/%d - %H:%M'): + date = datetime.now() + return str(date.strftime(date_format)) +======= if object.exists(slider_obj): test.log(f"Waiting for {parameter} slider to close...") @@ -277,4 +340,5 @@ return squish.waitForObject(names_dict, timeout_ms).text except LookupError: test.fail("ERROR : " + error_message) - return None \ No newline at end of file + return None +>>>>>>> origin/staging