Skip to content

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

Dont cap urls

magmuelleradd855e5ee68
diff --git a/browser_use/dom/service.py b/browser_use/dom/service.py
index feaeac044..71f93a442 100644
--- a/browser_use/dom/service.py
+++ b/browser_use/dom/service.py
@@ -395,6 +395,13 @@ class DomService:
'autocomplete', # Form field behavior
]
+ # These attributes should never be capped
+ no_cap_attributes = {
+ 'href', # URLs should never be capped
+ 'src', # Source URLs should never be capped
+ 'action', # Form submission URLs should never be capped
+ }
+
# Collect essential attributes that have values
attrs = []
for attr in essential_attributes:
@@ -405,7 +412,10 @@ class DomService:
elif isinstance(element_attr, (list, tuple)):
element_attr = ' '.join(str(v) for v in element_attr)
- attrs.append(f'{attr}="{self._cap_text_length(element_attr, 25)}"')
+ if attr not in no_cap_attributes:
+ element_attr = self._cap_text_length(element_attr, 25)
+
+ attrs.append(f'{attr}="{element_attr}"')
state_attributes_prefixes = (
'aria-',