Skip to content

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

removed false positives: if element has 0 height and width, it can't be clicakble

Gregor Žunič0830f06de6fe
diff --git a/browser_use/dom/serializer/clickable_elements.py b/browser_use/dom/serializer/clickable_elements.py
index 89f0d80c6..a242e3a18 100644
--- a/browser_use/dom/serializer/clickable_elements.py
+++ b/browser_use/dom/serializer/clickable_elements.py
@@ -18,9 +18,15 @@ class ClickableElementDetector:
if node.tag_name in {'html', 'body'}:
return False
- # Primary check: Chrome's own clickable detection (most reliable for DIV buttons, etc.)
- # if node.snapshot_node and node.snapshot_node.is_clickable:
- # return True
+ # Super quick check: if the node is a div with no width or height, it's not clickable (basically invisible element on page)
+ if (
+ node.snapshot_node
+ and node.snapshot_node.bounds
+ and node.snapshot_node.bounds.width == 0
+ and node.snapshot_node.bounds.height == 0
+ ):
+ return False
+
# Enhanced accessibility property checks - direct clear indicators only
if node.ax_node and node.ax_node.properties:
for prop in node.ax_node.properties:
diff --git a/browser_use/dom/serializer/serializer.py b/browser_use/dom/serializer/serializer.py
index cf9859bcf..57ce91bed 100644
--- a/browser_use/dom/serializer/serializer.py
+++ b/browser_use/dom/serializer/serializer.py
@@ -80,7 +80,7 @@ class DOMTreeSerializer:
"""Step 1: Create a simplified tree with enhanced element detection."""
if node.node_type == NodeType.DOCUMENT_NODE:
- # for all children including shadow roots
+ # for all cldren including shadow roots
for child in node.children_and_shadow_roots:
simplified_child = self._create_simplified_tree(child)
if simplified_child: