Skip to content

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

use bounding box to determine a tag eligibility, fixes 1789

Nick Sweetingf5546c633ddb
diff --git a/browser_use/dom/buildDomTree.js b/browser_use/dom/buildDomTree.js
index 1abf4ac4e..57c147421 100644
--- a/browser_use/dom/buildDomTree.js
+++ b/browser_use/dom/buildDomTree.js
@@ -1391,10 +1391,16 @@
}
}
- // Skip empty anchor tags
+ // Skip empty anchor tags only if they have no dimensions and no children
if (nodeData.tagName === 'a' && nodeData.children.length === 0 && !nodeData.attributes.href) {
- if (debugMode) PERF_METRICS.nodeMetrics.skippedNodes++;
- return null;
+ // Check if the anchor has actual dimensions
+ const rect = getCachedBoundingRect(node);
+ const hasSize = (rect && rect.width > 0 && rect.height > 0) || (node.offsetWidth > 0 || node.offsetHeight > 0);
+
+ if (!hasSize) {
+ if (debugMode) PERF_METRICS.nodeMetrics.skippedNodes++;
+ return null;
+ }
}
const id = `${ID.current++}`;