Skip to content

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

properly clear input elements before typing in text

Nick Sweetingb1142a59571e
diff --git a/browser_use/browser/context.py b/browser_use/browser/context.py
index 13a2e70ce..28dde79e1 100644
--- a/browser_use/browser/context.py
+++ b/browser_use/browser/context.py
@@ -1235,7 +1235,7 @@ class BrowserContext:
disabled = await disabled_handle.json_value() if disabled_handle else False
if (await is_contenteditable.json_value() or tag_name == 'input') and not (readonly or disabled):
- await element_handle.evaluate('el => el.textContent = ""')
+ await element_handle.evaluate('el => {el.textContent = ""; el.value = "";}')
await element_handle.type(text, delay=5)
else:
await element_handle.fill(text)