Skip to content

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

Update isInteractiveElement handling: - Remove unused window.getComputedStyle call. - Add a much faster check for interactive element using cursor pointer which cut short the function for 90% of the cases.

Rahul Sharmacdae535f13ad
diff --git a/browser_use/dom/buildDomTree.js b/browser_use/dom/buildDomTree.js
index 539c76225..f738b935f 100644
--- a/browser_use/dom/buildDomTree.js
+++ b/browser_use/dom/buildDomTree.js
@@ -462,6 +462,23 @@
return false;
}
+ function doesElementHaveInteractivePointer(element) {
+ if (element.tagName.toLowerCase() === "html") return false;
+ const style = window.getComputedStyle(element);
+
+ let interactiveCursors = ["pointer", "move", "text", "grab", "cell"];
+
+ if (interactiveCursors.includes(style.cursor)) return true;
+
+ return false;
+ }
+
+ let isInteractiveCursor = doesElementHaveInteractivePointer(element);
+
+ if (isInteractiveCursor) {
+ return true;
+ }
+
// Special handling for cookie banner elements
const isCookieBannerElement =
(typeof element.closest === 'function') && (
@@ -572,9 +589,6 @@
return true;
}
- // Get computed style
- const style = window.getComputedStyle(element);
-
// Check for event listeners
const hasClickHandler =
element.onclick !== null ||