Commit Graph

36 Commits

Author SHA1 Message Date
Magnus Müller 312bcf947d Merge branch 'main' into fix/mouse-scroll-zero-coordinate-redirect 2026-08-02 19:17:17 -07:00
Magnus Müller e00ec0aa35 Merge branch 'main' into fix/element-click-variable-shadowing 2026-08-02 14:17:57 -07:00
MagMueller 5a4b02c4bd Keep selector indices unique across CDP sessions 2026-07-23 15:44:03 -07:00
Andrew Chen db8a1d4af0 Fix Mouse.scroll() silently redirecting an explicit x=0/y=0 to viewport center
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>
2026-07-15 13:40:49 +08:00
Gaurav Rawat af39d3479d Fix variable shadowing in Element.click() error handling 2026-06-27 08:04:05 +00:00
Larsen Cundric 02dd650a19 fix: handle multi-character upper/lower in CDP typing
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.
2026-05-11 08:03:49 +00:00
Will-hxw 99e9a455e7 fix(element): redact sensitive values in fill() debug logging
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>
2026-04-23 23:19:31 +08:00
constx1337 6b77410683 refactor: Replace print with logger.debug in actor/page.py 2025-12-25 14:39:05 +08:00
kalil0321 0988199776 Merge branch 'main' into kalil0321/demo-mode 2025-11-13 15:34:49 +01:00
reformedot 0282675ade refactor: implement lazy fetching for DOM tree construction
- 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.
2025-11-10 21:28:10 -08:00
reformedot 97420238c1 refactor: enhance DOM tree construction and timing metrics
- 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.
2025-11-10 20:53:23 -08:00
kalil0321 3f64178894 Implement demo mode for in-browser logging 2025-11-08 21:39:57 +01:00
mertunsall 67d2f12665 default to PNG everywhere 2025-11-06 14:51:52 -08:00
Magnus Müller 9caa248316 Merge code7 branch changes 2025-10-21 18:55:54 -07:00
Saurav Panda ee355bf43c Merge branch 'main' into focus-causes-llm-to-not-input-text-properly 2025-10-16 16:59:08 -07:00
Saurav Panda eb6eee149a fix: Wrapped select() in try-catch to handle input types that don't support text selection 2025-10-16 16:42:18 -07:00
Saurav Panda 48e0cbb784 fixed clear issue when focus fails. 2025-10-16 16:10:48 -07:00
Reagan Hsu eaad2c7e63 Merge branch 'main' into fix/keyboard-events-complete 2025-10-15 14:18:34 -07:00
Reagan Hsu 659c0ddf42 make new utils file and add get_key_info 2025-10-15 13:48:08 -07:00
Magnus Müller 7f2e9fc4c3 Linter 2025-10-13 21:12:00 -07:00
Magnus Müller 20f8ef81e1 Unify extract in actor and tools 2025-10-13 21:11:26 -07:00
Reagan Hsu bc0ce8c226 Merge branch 'main' into fix/keyboard-events-complete 2025-10-13 19:29:16 -07:00
Reagan Hsu 81933bb20c update Page.press() to include event code and windowsVirtualKeyCode
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
2025-10-13 18:34:30 -07:00
Magnus Müller 6568a4061f Remove activateTarget 2025-10-11 18:28:24 -07:00
Magnus Müller 6d941a5dcc Rename Clear existing to clear 2025-10-05 19:32:39 -07:00
Magnus Müller 36bbf1ee23 Update outdated function names 2025-10-05 19:30:10 -07:00
Gregor Žunič e1c418179d BrowserSession -> Browser 2025-09-19 11:28:42 -07:00
Gregor Žunič 504f8cad09 migrated Target to Page 2025-09-19 10:27:00 -07:00
Gregor Žunič 804812500f migrated from lib functions 2025-09-17 08:09:24 -07:00
Gregor Žunič 101d4d1c36 more switches to snake_case 2025-09-16 20:15:27 -07:00
Gregor Žunič 2f6ca0f2d2 extract_content 2025-09-16 19:53:45 -07:00
Gregor Žunič 942a00c109 CamelCase to snake_case 2025-09-16 19:42:26 -07:00
Gregor Žunič 18b6145ba2 ai element by prompt 2025-09-16 17:08:18 -07:00
Gregor Žunič 5e05224ffb switched to browsersession input 2025-09-15 21:25:32 -07:00
Gregor Žunič e0f65ca892 v2 2025-09-15 21:11:46 -07:00
Gregor Žunič 11d37dd68d v1 actor 2025-09-15 17:12:31 -07:00