scroll_x = x if x > 0 else viewport_width / 2 (and the y equivalent) treats
an explicitly-passed x=0/y=0 the same as "not provided", since 0 > 0 is
False. page.mouse is a public actor API (browser_use/actor/page.py's
`mouse` property), so any caller explicitly requesting a scroll anchored at
the left edge (x=0) or top edge (y=0) instead gets silently redirected to
the horizontal/vertical center of the viewport -- no error, no warning, just
a wrong anchor point for the dispatched mouseWheel/synthesizeScrollGesture
CDP event. The only in-repo call site (actor/playground/playground.py:123,
`mouse.scroll(x=0, y=100, delta_y=500)`) was itself silently hitting this
bug.
Fix: change the x/y parameters to `int | None = None` and only fall back to
the viewport center when the coordinate is genuinely unset (None), extracted
into a small pure `_resolve_scroll_anchor()` helper so the anchor-resolution
logic is unit-testable without a real browser session. Also moved the
viewport-metrics fetch and anchor resolution above both CDP methods (mouse
wheel event, then synthesizeScrollGesture fallback) so both consistently
anchor at the same resolved point -- previously the synthesizeScrollGesture
fallback used the raw, un-centered x/y args instead.
Added tests/ci/test_actor_mouse_scroll_anchor.py covering: explicit x=0,
explicit y=0, both-unset (center fallback), and normal positive coordinates
passed straight through.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ord() raises TypeError when called on a multi-character string. Several
Unicode characters expand on case conversion ('ß'.upper() == 'SS',
'ffi'.upper() == 'FFI', 'ʼn'.upper() == 'ʼN'). Typing any of these caused
'Failed to input text via CDP: TypeError: ord() expected a character,
but string of length 2 found' and aborted the action.
Fall back to the original character's code point when upper()/lower()
returns more than one code point. The Windows VK code is only an
approximation anyway; the 'text' field passed to dispatchKeyEvent
carries the actual character.
Prevent passwords and other sensitive form data from appearing in debug
logs by showing "[REDACTED N chars]" instead of the actual value.
Fixes issue #4721 (security advisory)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Updated DOM tree retrieval methods to lazily fetch frame hierarchy only when necessary, improving performance for pages without cross-origin iframes.
- Adjusted method signatures to reflect optional frame fetching, enhancing flexibility in DOM service operations.
- Streamlined timing metrics by setting placeholders for timing logs, preparing for future performance enhancements.
- Updated DOM tree retrieval methods to include pre-fetched frame hierarchy, reducing redundant CDP calls and improving performance.
- Adjusted timing logs to provide detailed breakdowns of DOM tree construction, including total time and individual component timings.
- Removed commented-out code related to Python-based highlighting, streamlining the DOMWatchdog class.
- Reduced wait time in DOMWatchdog for page stability, enhancing responsiveness during DOM builds.
removed invalid filter param in attachToTarget()
added more keys and better parsing for lowercase keys using get_key_info() to make sure that key presses are properly processed