Skip to content

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

Refine clickable element detection logic

Magnus Müllerb012d21de3b4
diff --git a/browser_use/dom/serializer/clickable_elements.py b/browser_use/dom/serializer/clickable_elements.py
index 4e33dafbb..d16c07e07 100644
--- a/browser_use/dom/serializer/clickable_elements.py
+++ b/browser_use/dom/serializer/clickable_elements.py
@@ -94,7 +94,8 @@ class ClickableElementDetector:
# Skip properties we can't process
continue
- # ENHANCED TAG CHECK: Include truly interactive elements
+ # ENHANCED TAG CHECK: Include truly interactive elements
+ # Note: 'label' removed - labels are handled by other attribute checks below - other wise labels with "for" attribute can destry the real clickable element on appartments.com
interactive_tags = {
'button',
'input',
@@ -109,16 +110,6 @@ class ClickableElementDetector:
if node.tag_name in interactive_tags:
return True
- # Special handling for labels: only interactive if they DON'T have a 'for' attribute
- # Labels with 'for' attribute should not be interactive - their associated input should be
- if node.tag_name == 'label':
- if node.attributes and node.attributes.get('for'):
- # This label points to an input - it should NOT be interactive
- return False
- else:
- # This label doesn't point to an input - it might be clickable itself
- return True
-
# SVG elements need special handling - only interactive if they have explicit handlers
# svg_tags = {'svg', 'path', 'circle', 'rect', 'polygon', 'ellipse', 'line', 'polyline', 'g'}
# if node.tag_name in svg_tags: