Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -r4554e32860b9a12d2bc94bd15f1dab4e8a436a9a -rdb068fb5765c4b6da4cf59373bf7768977a7b7b9 --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision 4554e32860b9a12d2bc94bd15f1dab4e8a436a9a) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision db068fb5765c4b6da4cf59373bf7768977a7b7b9) @@ -2,6 +2,9 @@ import test import object import names +from squish import * +from leahi_dialin.ui import utils +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 @@ -129,23 +132,7 @@ return None -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 - def set_value_based_on_target(obj, target_value): """ obj: dictionary containing object paths @@ -183,8 +170,9 @@ test.log(f"Updated value: {current_value}") - test.log(f"✅ Target value reached: {current_value}") + test.log(f"✅ Target value reached: {current_value}") + def select_different_dropdown(object,type,whichTypeIndex): """ Selects a value from a dropdown using a doc string. @@ -200,24 +188,6 @@ return True return False # default return if not successful - -def findAllChildrenById(parent, target_id): - """ - Finds all child objects (excluding parent) by their id property. - Returns a list of all matching child objects found. - """ - results = [] - - # Recurse through all children to collect matching instances - for child in object.children(parent): - # Check child's id - if str(child.id) == target_id: - results.append(child) - - # Continue searching in grand children - results.extend(findAllChildrenById(child, target_id)) - - return results def set_value_with_slider(value_field_obj, slider_obj,parameter): """ @@ -226,7 +196,7 @@ """ try: - value_field = waitForObject(value_field_obj,1000) + value_field = squish.waitForObject(value_field_obj,1000) test.log(f"Opening slider for {parameter}...") squish.mousePress(value_field, squish.Qt.LeftButton) value = value_field.value @@ -239,19 +209,21 @@ if not object.exists(slider_obj): test.fail(f"{parameter}: Slider did not appear.") - slider = waitForObject(slider_obj) + slider = squish.waitForObject(slider_obj) test.log(f"{parameter}: Slider appeared successfully.") squish.mousePress(slider,squish.Qt.LeftButton) - final_value = waitForObject(value_field_obj).value + final_value = squish.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 get_current_date_and_time(date_format='%Y/%b/%d - %H:%M'): + date = datetime.now() + return str(date.strftime(date_format)) def click_left_until_off(object_name): """