Skip to content

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

Turn result to str

Magnus Müller49ad909f2b7a
diff --git a/browser_use/tools/service.py b/browser_use/tools/service.py
index 11550e3ea..adcdc8a02 100644
--- a/browser_use/tools/service.py
+++ b/browser_use/tools/service.py
@@ -926,7 +926,7 @@ JSON.stringify(Array.from(document.querySelectorAll('a')).map(el => el.textConte
params={'expression': code, 'returnByValue': True}, session_id=cdp_session.session_id
)
result_text = result.get('result', {}).get('value', '')
-
+ result_text = str(result_text)
if len(result_text) > 20000:
result_text = result_text[:20000] + ' Truncated after 20000 characters ...'
# Return the result (could be empty string, which is valid)