@@ -77,9 +77,13 @@ export function buildHierarchicalTree(nodes: AccessibilityNode[]): TreeResult {
77
77
nodes . forEach ( ( node ) => {
78
78
const hasChildren = node . childIds && node . childIds . length > 0 ;
79
79
const hasValidName = node . name && node . name . trim ( ) !== "" ;
80
+ const isInteractive =
81
+ node . role !== "none" &&
82
+ node . role !== "generic" &&
83
+ node . role !== "InlineTextBox" ; //add other interactive roles here
80
84
81
- // Skip nodes that have no semantic value (no name and no children)
82
- if ( ! hasValidName && ! hasChildren ) {
85
+ // Include nodes that are either named, have children, or are interactive
86
+ if ( ! hasValidName && ! hasChildren && ! isInteractive ) {
83
87
return ;
84
88
}
85
89
@@ -177,7 +181,7 @@ export async function getAccessibilityTree(
177
181
178
182
// This function is wrapped into a string and sent as a CDP command
179
183
// It is not meant to be actually executed here
180
- function getNodePath ( el : Element ) {
184
+ const functionString = ` function getNodePath(el) {
181
185
if (!el || el.nodeType !== Node.ELEMENT_NODE) return "";
182
186
const pathSegments = [];
183
187
let current = el;
@@ -196,17 +200,15 @@ function getNodePath(el: Element) {
196
200
}
197
201
const segment = index > 1 ? tagName + "[" + index + "]" : tagName;
198
202
pathSegments.unshift(segment);
199
- current = current . parentNode as Element ;
203
+ current = current.parentNode;
200
204
if (!current || !current.parentNode) break;
201
205
if (current.nodeName.toLowerCase() === "html") {
202
206
pathSegments.unshift("html");
203
207
break;
204
208
}
205
209
}
206
210
return "/" + pathSegments.join("/");
207
- }
208
-
209
- const functionString = getNodePath . toString ( ) ;
211
+ }` ;
210
212
211
213
export async function getXPathByResolvedObjectId (
212
214
cdpClient : CDPSession ,
0 commit comments