Skip to content

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

fix clear_existing param to input_text

Nick Sweetinga476a1ec2873
diff --git a/browser_use/browser/default_action_watchdog.py b/browser_use/browser/default_action_watchdog.py
index 05964c2e0..da925c132 100644
--- a/browser_use/browser/default_action_watchdog.py
+++ b/browser_use/browser/default_action_watchdog.py
@@ -115,7 +115,9 @@ class DefaultActionWatchdog(BaseWatchdog):
else:
try:
# Try to type to the specific element
- await self._input_text_element_node_impl(element_node, event.text, event.clear_existing)
+ await self._input_text_element_node_impl(
+ element_node, event.text, clear_existing=event.clear_existing or (not event.text)
+ )
self.logger.info(f'⌨️ Typed "{event.text}" into element with index {index_for_logging}')
self.logger.debug(f'Element xpath: {element_node.xpath}')
except Exception as e: