Skip to content

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

record when JS has run in a given target

Nick Sweeting2232da65ac43
diff --git a/browser_use/dom/buildDomTree.js b/browser_use/dom/buildDomTree.js
index 9286c097d..3a2c24964 100644
--- a/browser_use/dom/buildDomTree.js
+++ b/browser_use/dom/buildDomTree.js
@@ -800,6 +800,10 @@
return null;
}
+ // FOR DEBUGGING: mark the node as having been processed by buildDomTree.js
+ // so that playwright can tell if it's been processed or not
+ // node.setAttribute('data-browser-use-built-dom-tree', 'true');
+
// Special handling for root node (body)
if (node === document.body) {
const nodeData = {
@@ -936,6 +940,9 @@
const domElement = buildDomTree(child, node);
if (domElement) nodeData.children.push(domElement);
}
+ // mark the iframe as having been processed by buildDomTree.js
+ // so that playwright can tell if got processed already or if it needs special handling
+ node.contentWindow._loadedBrowserUseBuildDomTree = true;
}
} catch (e) {
console.warn("Unable to access iframe:", e);