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
test(browser): validate literal plus CDP key events
IENVYshanks2b56dc8f5990
diff --git a/browser_use/browser/watchdogs/default_action_watchdog.py b/browser_use/browser/watchdogs/default_action_watchdog.pyindex 805b5b43a..5c9c92e63 100644--- a/browser_use/browser/watchdogs/default_action_watchdog.py+++ b/browser_use/browser/watchdogs/default_action_watchdog.py@@ -2530,7 +2530,6 @@ class DefaultActionWatchdog(BaseWatchdog):main_key = key_aliases.get(suffix.strip().lower(), suffix)if is_combination and main_key is not None:-# Calculate modifier bitmaskmodifier_value = 0for mod in modifiers:diff --git a/tests/ci/browser/test_send_keys_literal_plus.py b/tests/ci/browser/test_send_keys_literal_plus.pyindex 49c161cff..62707050c 100644--- a/tests/ci/browser/test_send_keys_literal_plus.py+++ b/tests/ci/browser/test_send_keys_literal_plus.py@@ -1,11 +1,12 @@import asynciofrom types import SimpleNamespace+from typing import castfrom browser_use.browser.events import SendKeysEventfrom browser_use.browser.watchdogs.default_action_watchdog import DefaultActionWatchdog-def make_watchdog(recorded_params, dispatched_keys):+def make_watchdog(recorded_params, dispatched_keys) -> DefaultActionWatchdog:class Input:async def dispatchKeyEvent(self, params=None, session_id=None):recorded_params.append(params or {})@@ -29,7 +30,7 @@ def make_watchdog(recorded_params, dispatched_keys):)watchdog._get_char_modifiers_and_vk = DefaultActionWatchdog._get_char_modifiers_and_vk.__get__(watchdog)watchdog._get_key_code_for_char = DefaultActionWatchdog._get_key_code_for_char.__get__(watchdog)- return watchdog+ return cast(DefaultActionWatchdog, watchdog)def test_send_keys_literal_plus_dispatches_char_event():@@ -39,8 +40,9 @@ def test_send_keys_literal_plus_dispatches_char_event():asyncio.run(DefaultActionWatchdog.on_SendKeysEvent(watchdog, SendKeysEvent(keys='+')))- assert any(params.get('type') == 'char' and params.get('text') == '+' for params in recorded_params)- assert all(key for _, key, _ in dispatched_keys)+ char_events = [params for params in recorded_params if params.get('type') == 'char']+ assert [(params.get('text'), params.get('key')) for params in char_events] == [('+', '+')]+ assert all(params.get('key') for params in recorded_params)def test_send_keys_text_with_plus_dispatches_all_characters():