(root)
| 34 | ) |
| 35 | |
| 36 | def iterative_dfs(root): |
| 37 | if not root: |
| 38 | return |
| 39 | stack = [root] |
| 40 | visited = set() |
| 41 | while stack: |
| 42 | node = stack.pop() |
| 43 | if id(node) in visited: |
| 44 | continue |
| 45 | visited.add(id(node)) |
| 46 | if is_interactive(node): |
| 47 | bounds = { |
| 48 | 'left': getattr(getattr(node, 'bounds_in_screen', None), 'left', 0), |
| 49 | 'top': getattr(getattr(node, 'bounds_in_screen', None), 'top', 0), |
| 50 | 'right': getattr(getattr(node, 'bounds_in_screen', None), 'right', 0), |
| 51 | 'bottom': getattr(getattr(node, 'bounds_in_screen', None), 'bottom', 0) |
| 52 | } |
| 53 | interactives.append({ |
| 54 | 'unique_id': getattr(node, 'unique_id', None), |
| 55 | 'class_name': node.class_name, |
| 56 | 'content_description': node.content_description, |
| 57 | 'text': node.text, |
| 58 | 'resource_id': getattr(node, 'view_id_resource_name', 'N/A'), |
| 59 | 'bounds': bounds |
| 60 | }) |
| 61 | for child_id in reversed(node.child_ids): |
| 62 | child_node = id_to_node.get(child_id) |
| 63 | if child_node: |
| 64 | stack.append(child_node) |
| 65 | |
| 66 | all_child_ids = {cid for node in nodes for cid in node.child_ids} |
| 67 | root_nodes = [node for node in nodes if getattr(node, 'unique_id', None) not in all_child_ids] |
no test coverage detected