Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

added check for empty child for a tag

paperboardofficial10c50254dad1
diff --git a/browser_use/dom/buildDomTree.js b/browser_use/dom/buildDomTree.js
index 003eed567..6a3af206e 100644
--- a/browser_use/dom/buildDomTree.js
+++ b/browser_use/dom/buildDomTree.js
@@ -688,6 +688,10 @@
nodeData.children.push(domElement);
}
}
+ // If it's an <a> element and has no visible content, return null
+ if (nodeData.tagName === 'a' && nodeData.children.length === 0) {
+ return null;
+ }
}
// NOTE: We register the node to the hash map.