Index: suite_leahi/shared/scripts/configuration/utility.py =================================================================== diff -u -rc697407b30310eda41d59fe98cd42aa461038516 -rbf4e1edb998d1ab22c639f571c5ad3b264dbac4b --- suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision c697407b30310eda41d59fe98cd42aa461038516) +++ suite_leahi/shared/scripts/configuration/utility.py (.../utility.py) (revision bf4e1edb998d1ab22c639f571c5ad3b264dbac4b) @@ -223,22 +223,23 @@ ) squish.mouseClick(names.o_preTreatmentStack_confirmButton_ConfirmButton) test.endSection() - -def findAllObjectsById(parent, target_id): + +def findAllChildrenById(parent, target_id): """ - Recursively finds all child objects by their id property. - Returns a list of all matching objects found. + Finds all child objects (excluding parent) by their id property. + Returns a list of all matching child 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 + # Recurse through all children to collect matching instances for child in object.children(parent): - results.extend(findAllObjectsById(child, target_id)) - + # 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): @@ -302,6 +303,7 @@ test.fail("ERROR : " + error_message) return None + def get_object_source_path(names_dict, error_message = "Missing object source path", timeout_ms = 2000): """ To get an object source path with try..except catching to prevent script errors when the object is not found on the GUI