Skip to content

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

fix: detect interactive elements with click event listener : adding 'click' mouse event and fixing element mouse event check

mingzhong.li91b1bb85e24f
diff --git a/browser_use/dom/buildDomTree.js b/browser_use/dom/buildDomTree.js
index 7bd184941..564a8c90a 100644
--- a/browser_use/dom/buildDomTree.js
+++ b/browser_use/dom/buildDomTree.js
@@ -830,8 +830,10 @@
const listeners = getEventListeners(element);
const mouseEvents = ['click', 'mousedown', 'mouseup', 'dblclick'];
for (const eventType of mouseEvents) {
- if (listeners[eventType] && listeners[eventType].length > 0) {
- return true; // Found a mouse interaction listener
+ for (const listener of listeners) {
+ if (listener.type === eventType) {
+ return true; // Found a mouse interaction listener
+ }
}
}
} else {
@@ -1117,10 +1119,12 @@
const getEventListeners = window.getEventListenersForNode;
if (typeof getEventListeners === 'function') {
const listeners = getEventListeners(element);
- const interactionEvents = ['mousedown', 'mouseup', 'keydown', 'keyup', 'submit', 'change', 'input', 'focus', 'blur'];
+ const interactionEvents = ['click', 'mousedown', 'mouseup', 'keydown', 'keyup', 'submit', 'change', 'input', 'focus', 'blur'];
for (const eventType of interactionEvents) {
- if (listeners[eventType] && listeners[eventType].length > 0) {
- return true; // Found a common interaction listener
+ for (const listener of listeners) {
+ if (listener.type === eventType) {
+ return true; // Found a common interaction listener
+ }
}
}
} else {