Skip to content

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

Enhance static attributes list in EnhancedDOMTreeNode for improved DOM serialization

Magnus Müller40ce0d382dd0
diff --git a/browser_use/dom/views.py b/browser_use/dom/views.py
index 49fbb8edf..703102b0f 100644
--- a/browser_use/dom/views.py
+++ b/browser_use/dom/views.py
@@ -693,8 +693,41 @@ class EnhancedDOMTreeNode:
'placeholder',
'aria-label',
'title',
- 'value',
'aria-expanded',
+ 'role',
+ 'data-testid',
+ 'data-test',
+ 'data-cy',
+ 'data-selenium',
+ 'for',
+ 'required',
+ 'disabled',
+ 'readonly',
+ 'checked',
+ 'selected',
+ 'multiple',
+ 'href',
+ 'target',
+ 'rel',
+ 'aria-describedby',
+ 'aria-labelledby',
+ 'aria-controls',
+ 'aria-owns',
+ 'aria-live',
+ 'aria-atomic',
+ 'aria-busy',
+ 'aria-disabled',
+ 'aria-hidden',
+ 'aria-pressed',
+ 'aria-checked',
+ 'aria-selected',
+ 'tabindex',
+ 'alt',
+ 'src',
+ 'lang',
+ 'itemscope',
+ 'itemtype',
+ 'itemprop',
]
)
attributes_string = ''.join(f'{key}={value}' for key, value in self.attributes.items() if key in static_attributes)