Skip to content

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

Fix: update shadow root attribute in HTMLSerializer to use 'shadowroot' instead of 'shadowrootmode', enhancing compatibility with declarative shadow DOM syntax.

Magnus Müllercb4cfb113090
diff --git a/browser_use/dom/serializer/html_serializer.py b/browser_use/dom/serializer/html_serializer.py
index 5050cfa17..8aaf31df7 100644
--- a/browser_use/dom/serializer/html_serializer.py
+++ b/browser_use/dom/serializer/html_serializer.py
@@ -45,12 +45,11 @@ class HTMLSerializer:
elif node.node_type == NodeType.DOCUMENT_FRAGMENT_NODE:
# Shadow DOM root - wrap in template with shadowrootmode attribute
- # This is the declarative shadow DOM syntax that html2text can process
parts = []
# Add shadow root opening
shadow_type = node.shadow_root_type or 'open'
- parts.append(f'<template shadowrootmode="{shadow_type.lower()}">')
+ parts.append(f'<template shadowroot="{shadow_type.lower()}">')
# Serialize shadow children
for child in node.children: