Skip to content

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

Dont select body as clickable

magmueller1f2bc5348eaf
diff --git a/browser_use/dom/buildDomTree.js b/browser_use/dom/buildDomTree.js
index db1ffc290..9dd4534e2 100644
--- a/browser_use/dom/buildDomTree.js
+++ b/browser_use/dom/buildDomTree.js
@@ -137,6 +137,11 @@
// Helper function to check if element is interactive
function isInteractiveElement(element) {
+ // Immediately return false for body tag
+ if (element.tagName.toLowerCase() === 'body') {
+ return false;
+ }
+
// Base interactive elements and roles
const interactiveElements = new Set([
'a', 'button', 'details', 'embed', 'input', 'label',
@@ -164,7 +169,7 @@
interactiveElements.has(tagName) ||
interactiveRoles.has(role) ||
interactiveRoles.has(ariaRole) ||
- (tabIndex !== null && tabIndex !== '-1') ||
+ (tabIndex !== null && tabIndex !== '-1' && element.parentElement?.tagName.toLowerCase() !== 'body') ||
element.getAttribute('data-action') === 'a-dropdown-select' ||
element.getAttribute('data-action') === 'a-dropdown-button';
@@ -240,13 +245,17 @@
const isDraggable = element.draggable ||
element.getAttribute('draggable') === 'true';
+ // Additional check to prevent body from being marked as interactive
+ if (element.tagName.toLowerCase() === 'body' || element.parentElement?.tagName.toLowerCase() === 'body') {
+ return false;
+ }
+
return hasAriaProps ||
// hasClickStyling ||
hasClickHandler ||
hasClickListeners ||
// isFormRelated ||
isDraggable;
-
}
// Helper function to check if element is visible