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
extraction, sage entire tree
Gregor Žunič65f94f7eee91
diff --git a/browser_use/dom/playground/extraction.py b/browser_use/dom/playground/extraction.pyindex d81483682..70a6ef0ca 100644--- a/browser_use/dom/playground/extraction.py+++ b/browser_use/dom/playground/extraction.py@@ -108,7 +108,7 @@ async def test_focus_vs_all_elements():# save pure clickable elements to a fileif all_elements_state.dom_state._root:async with await anyio.open_file('./tmp/element_tree.json', 'w', encoding='utf-8') as f:- await f.write(json.dumps(all_elements_state.dom_state._root.original_node.__json__(), indent=0))+ await f.write(json.dumps(all_elements_state.dom_state._root.__json__(), indent=0))# copy the user message to the clipboard# pyperclip.copy(text_to_save)diff --git a/browser_use/dom/serializer/clickable_elements.py b/browser_use/dom/serializer/clickable_elements.pyindex 2ccb2ccc1..47e4b6c7b 100644--- a/browser_use/dom/serializer/clickable_elements.py+++ b/browser_use/dom/serializer/clickable_elements.py@@ -1,4 +1,4 @@-from dom.views import EnhancedDOMTreeNode+from browser_use.dom.views import EnhancedDOMTreeNodeclass ClickableElementDetector:diff --git a/browser_use/dom/serializer/serializer.py b/browser_use/dom/serializer/serializer.pyindex 6dd4d0728..54dcd8ff3 100644--- a/browser_use/dom/serializer/serializer.py+++ b/browser_use/dom/serializer/serializer.py@@ -1,8 +1,7 @@# @file purpose: Serializes enhanced DOM trees to string format for LLM consumption-from dom.serializer.clickable_elements import ClickableElementDetector-+from browser_use.dom.serializer.clickable_elements import ClickableElementDetectorfrom browser_use.dom.utils import cap_text_lengthfrom browser_use.dom.views import DOMSelectorMap, EnhancedDOMTreeNode, NodeType, SerializedDOMState, SimplifiedNodediff --git a/browser_use/dom/views.py b/browser_use/dom/views.pyindex 463132352..f6cd801c8 100644--- a/browser_use/dom/views.py+++ b/browser_use/dom/views.py@@ -37,6 +37,14 @@ class SimplifiedNode:is_new: bool = False+ def __json__(self) -> dict:+ return {+ 'should_display': self.should_display,+ 'interactive_index': self.interactive_index,+ 'original_node': self.original_node.__json__(),+ 'children': [c.__json__() for c in self.children],+ }+class NodeType(int, Enum):"""DOM node types based on the DOM specification."""