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
address cubic comments of special characters and newlines
Alezander9112d85c73b36
diff --git a/browser_use/browser/watchdogs/default_action_watchdog.py b/browser_use/browser/watchdogs/default_action_watchdog.pyindex eb2550701..6a6818315 100644--- a/browser_use/browser/watchdogs/default_action_watchdog.py+++ b/browser_use/browser/watchdogs/default_action_watchdog.py@@ -1650,6 +1650,18 @@ class DefaultActionWatchdog(BaseWatchdog):'Alt','Meta','Shift',+ 'F1',+ 'F2',+ 'F3',+ 'F4',+ 'F5',+ 'F6',+ 'F7',+ 'F8',+ 'F9',+ 'F10',+ 'F11',+ 'F12',}# If it's a special key, use original logic@@ -1660,6 +1672,12 @@ class DefaultActionWatchdog(BaseWatchdog):# It's text (single character or string) - send each character as text input# This is crucial for text to appear in focused input fieldsfor char in normalized_keys:+ # Special-case newline characters to dispatch as Enter+ if char in ('\n', '\r'):+ await self._dispatch_key_event(cdp_session, 'keyDown', 'Enter')+ await self._dispatch_key_event(cdp_session, 'keyUp', 'Enter')+ continue+# Get proper modifiers and key info for the charactermodifiers, vk_code, base_key = self._get_char_modifiers_and_vk(char)key_code = self._get_key_code_for_char(base_key)diff --git a/examples/getting_started/01_basic_search.py b/examples/getting_started/01_basic_search.pyindex 695611879..031674281 100644--- a/examples/getting_started/01_basic_search.py+++ b/examples/getting_started/01_basic_search.py@@ -20,7 +20,7 @@ from browser_use import Agent, ChatBrowserUseasync def main():llm = ChatBrowserUse()- task = "Search Google for 'what is browser automation' and tell me the top 3 results"+ task = "We are testing the send_keys function. Go to https://inputtypes.com/ and focus the input box and type 'hello world'. DO NOT use the input_text action. Only use the send_keys action. Mark the task as done right after using the send_keys action."agent = Agent(task=task, llm=llm)await agent.run()