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
Include '' if attr none
Magnus Müllerff9c300b4968
diff --git a/browser_use/dom/serializer/serializer.py b/browser_use/dom/serializer/serializer.pyindex b9d04bc12..c41747aee 100644--- a/browser_use/dom/serializer/serializer.py+++ b/browser_use/dom/serializer/serializer.py@@ -1118,6 +1118,15 @@ class DOMTreeSerializer:del attributes_to_include[attr]if attributes_to_include:- return ' '.join(f'{key}={cap_text_length(value, 100)}' for key, value in attributes_to_include.items())+ # Format attributes, wrapping empty values in quotes for clarity+ formatted_attrs = []+ for key, value in attributes_to_include.items():+ capped_value = cap_text_length(value, 100)+ # Show empty values as key='' instead of key=+ if not capped_value:+ formatted_attrs.append(f"{key}=''")+ else:+ formatted_attrs.append(f'{key}={capped_value}')+ return ' '.join(formatted_attrs)return ''