Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
fix discovery of elements that have both shadow and non shadow child nodes
Nick Sweeting73369f910c38
diff --git a/browser_use/browser/views.py b/browser_use/browser/views.pyindex 3434d86e2..1c46d0c5c 100644--- a/browser_use/browser/views.py+++ b/browser_use/browser/views.py@@ -14,6 +14,7 @@ class TabInfo(BaseModel):page_id: inturl: strtitle: str+ parent_page_id: Optional[int] = None # parent page that contains this popup or cross-origin iframe@dataclassdiff --git a/browser_use/dom/buildDomTree.js b/browser_use/dom/buildDomTree.jsindex 9286c097d..e86a5bd87 100644--- a/browser_use/dom/buildDomTree.js+++ b/browser_use/dom/buildDomTree.js@@ -955,16 +955,16 @@if (domElement) nodeData.children.push(domElement);}}- // Handle shadow DOM- else if (node.shadowRoot) {- nodeData.shadowRoot = true;- for (const child of node.shadowRoot.childNodes) {- const domElement = buildDomTree(child, parentIframe);- if (domElement) nodeData.children.push(domElement);- }- }// Handle regular elementselse {+ // Handle shadow DOM+ if (node.shadowRoot) {+ nodeData.shadowRoot = true;+ for (const child of node.shadowRoot.childNodes) {+ const domElement = buildDomTree(child, parentIframe);+ if (domElement) nodeData.children.push(domElement);+ }+ }for (const child of node.childNodes) {const domElement = buildDomTree(child, parentIframe);if (domElement) nodeData.children.push(domElement);