Commit Graph

1467 Commits

Author SHA1 Message Date
Magnus Müller aad4b932bf time_execution_async import 2025-08-29 22:32:05 -07:00
Magnus Müller 25823ce670 make highlights sync 2025-08-29 22:25:32 -07:00
Magnus Müller ce0876adb7 highlight in parallel 2025-08-29 22:17:50 -07:00
Magnus Müller e570acfefc Enhance DOM service initialization in DOMWatchdog
- Updated the instantiation of `DomService` to include `cross_origin_iframes` parameter from the browser session profile, improving its configuration for handling cross-origin iframes.
2025-08-29 21:54:16 -07:00
Magnus Müller d8b23062b9 Formatter 2025-08-29 21:46:45 -07:00
Magnus Müller 4a62fe11f9 More logging 2025-08-29 21:42:14 -07:00
Magnus Müller 7b0e216ff0 Update font size and padding adjustments in bounding box drawing for enhanced visibility
- Increased font size in `draw_enhanced_bounding_box_with_text` from 30 to 36 for improved readability.
- Adjusted padding from 8 to 6 to accommodate the larger font while maintaining visual clarity.
- Enhanced text positioning logic to prevent clipping and ensure proper alignment within the bounding box.
2025-08-29 21:36:25 -07:00
Magnus Müller a31ae9dffb Refactor bounding box drawing and enhance LLM text representation
- Removed the `_raise_if_stopped_or_paused` method from the `Agent` class to streamline functionality.
- Updated `draw_enhanced_bounding_box_with_text` to improve font size and padding for better visibility of index boxes.
- Introduced `get_meaningful_text_for_llm` method in `EnhancedDOMTreeNode` to provide more relevant text for LLM processing.
- Enhanced `llm_representation` method with observability features for better debugging.
2025-08-29 21:30:11 -07:00
Magnus Müller e8bd85865d Add filter for highlight IDs in screenshot generation and update element colors
- Introduced `filter_highlight_ids` option in `BrowserProfile`, `BrowserSession`, and `create_highlighted_screenshot` to control the visibility of element IDs based on text length.
- Updated `draw_enhanced_bounding_box_with_text` to utilize the new filtering logic for enhanced visual clarity.
- Changed the color of text areas from yellow to orange for improved visibility in the UI.
2025-08-29 20:56:03 -07:00
Magnus Müller 66822d6090 Update font size and padding in bounding box drawing functions for improved visibility
- Increased font size in `draw_enhanced_bounding_box_with_text` from 35 to 40 for better readability.
- Adjusted padding in `draw_bounding_box_with_text` from 3 to 5 to enhance spacing around text elements.
2025-08-29 20:45:54 -07:00
Magnus Müller 8511c2d398 Remove display highlights on screen feature and adjust bounding box drawing parameters
- Eliminated the `display_highlights_on_screen` option from `BrowserProfile` and `BrowserSession` to streamline the highlighting functionality.
- Updated the `draw_enhanced_bounding_box_with_text` function to increase font size for better visibility and reduced padding for a more compact layout.
- Removed associated screenshot overlay logic in `DOMWatchdog` to reflect the removal of the display highlights feature.
2025-08-29 20:38:57 -07:00
Magnus Müller 3b6c5d11ba Enhance bounding box drawing with dashed borders and larger index containers
- Updated `draw_enhanced_bounding_box_with_text` function to draw dashed bounding boxes for better visibility.
- Increased the size of index text and padding for improved prominence.
- Adjusted text positioning logic to ensure proper placement within or outside the bounding box based on available space.
- Enhanced background rectangle drawing for better contrast and visibility.
2025-08-29 20:24:13 -07:00
Magnus Müller 634dd20e37 Add display highlights on screen feature and enhance bounding box drawing
- Introduced `display_highlights_on_screen` option in `BrowserProfile` and `BrowserSession` to control the visibility of highlights directly on the browser screen.
- Implemented `draw_enhanced_bounding_box_with_text` function to improve the visual representation of highlighted elements with larger indices and solid borders.
- Updated screenshot overlay logic in `DOMWatchdog` to utilize the new highlighting feature, ensuring better visibility of interactive elements during browser sessions.
2025-08-29 20:19:26 -07:00
Magnus Müller 3e568d4280 Merge remote-tracking branch 'origin/main' into cursor/generate-python-highlights-for-browser-screenshot-ef29 2025-08-29 19:56:47 -07:00
Magnus Müller 7ad12bbfde fix-windowsVirtualKeyCode 2025-08-29 19:49:34 -07:00
Magnus Müller f4a34bc1d7 fix-clear-text 2025-08-29 19:24:47 -07:00
jason a8b4b034c1 Merge branch 'main' into fix/cdp-viewport-initialization 2025-08-29 22:22:13 -04:00
Magnus Müller 46c0dc4fe2 Refactor key code mapping and text field clearing logic in DefaultActionWatchdog
- Updated key code mappings for special characters to reflect correct usage with modifiers.
- Enhanced text field clearing method to use platform-specific modifiers (Cmd for macOS, Ctrl for others) for a more human-like interaction.
- Removed unnecessary `windowsVirtualKeyCode` assignments for printable characters to prevent incorrect virtual key code usage.

These changes improve the accuracy of character input handling and enhance the robustness of text field interactions.
2025-08-29 18:45:20 -07:00
Magnus Müller 42e6cc80e0 Remove CDPSession in default watchdog 2025-08-29 18:34:03 -07:00
Magnus Müller 4e80786015 Refactor DefaultActionWatchdog for improved focus handling
- Added type hint for CDPSession in the _focus_element_simple method.
- Enhanced logging for focus attempts, including exception details.
- Reduced sleep duration in scrollIntoViewIfNeeded for better performance.
- Updated text clearing logic to ensure it only occurs after successful focus.

These changes enhance the robustness of element interaction and improve debugging capabilities.
2025-08-29 18:22:43 -07:00
Magnus Müller 662a39742e Use existing method to get coordinates 2025-08-29 18:08:37 -07:00
Magnus Müller d80549038b Enhance element interaction handling
- Added logging for new elements detected during actions in the Agent class.
- Implemented a human-like text field clearing method in DefaultActionWatchdog, utilizing Ctrl+A and Backspace.
- Improved focus handling for label elements, ensuring they are only interactive if they do not have a 'for' attribute.
- Updated clickable element detection logic to account for labels pointing to inputs.

These changes improve the robustness of user interactions and enhance debugging capabilities.
2025-08-29 18:01:34 -07:00
Magnus Müller bb3055e7bb Emulate real human typing 2025-08-29 16:51:04 -07:00
Magnus Müller 7eb30f6842 Update browser_use/browser/watchdogs/downloads_watchdog.py
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2025-08-29 15:05:10 -07:00
Magnus Müller 8be1a17774 Fix dont reasign event in on_CloseTabEvent 2025-08-29 14:57:58 -07:00
Magnus Müller 1a31aefd38 Merge remote-tracking branch 'origin/main' into fix-tab-switching 2025-08-29 14:48:46 -07:00
Magnus Müller 9246ca1621 Remove init scrpt because it was not used 2025-08-29 14:39:12 -07:00
Magnus Müller babe510c30 When closing tabs, first check if we need to open a new one 2025-08-29 13:41:25 -07:00
jason 75759b49c0 Merge branch 'main' into fix/storage-watchdog-stop-monitoring 2025-08-29 15:56:57 -04:00
jason 8e48f6375c Merge branch 'main' into fix/cdp-viewport-initialization 2025-08-29 15:55:07 -04:00
Saurav Panda a2e40c7980 Merge branch 'main' into fix-disable-security-bug 2025-08-29 12:44:44 -07:00
Saurav Panda 34a69a0acb fix: add highlighting condition check for disable_security browser profile setting 2025-08-29 11:58:51 -07:00
Magnus Müller 4c10628ff2 Dont open new tab, if we are already inside a new tab 2025-08-29 11:35:02 -07:00
Magnus Müller 9dd5b27c1f Logs 2025-08-29 11:25:25 -07:00
Magnus Müller 9915ea41a9 Remove 📍 from logs 2025-08-29 11:02:50 -07:00
jason 98095d3d0d Update browser_use/browser/session.py
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2025-08-28 20:33:15 -04:00
Saurav Panda 601105fa4a ix: prevent disable_security from breaking browser extensions 2025-08-28 16:17:16 -07:00
jtanningbed f38555e418 fix: apply viewport settings via TabCreatedEvent handler
- Add on_TabCreatedEvent handler to BrowserSession to apply viewport settings
- Update _cdp_set_viewport to accept optional target_id parameter
- All tabs (initial and new) now get viewport through unified event handler

This ensures consistent viewport configuration across all tabs when
viewport is explicitly set in the browser profile, while respecting
the natural window sizing when viewport is not configured.
2025-08-28 18:20:17 -04:00
jtanningbed 5d71fc060b feat: add CDP implementation for capturing localStorage/sessionStorage
Implements _cdp_get_origins() method to capture localStorage and sessionStorage
using cdp-use's typed DOMStorage client. This enables proper session
persistence for applications that store authentication tokens in browser storage
rather than cookies.

- Adds _cdp_get_origins() to enumerate all frames and extract unique origins
- Uses cdp-use's DOMStorage.getDOMStorageItems to retrieve localStorage/sessionStorage
- Updates _cdp_get_storage_state() to include origins in storage state
- Handles errors gracefully with debug logging for individual storage failures
- Uses try-finally to ensure DOMStorage is properly disabled even on errors
- Encapsulates storage extraction logic in helper functions for clarity
2025-08-28 16:43:10 -04:00
Andrei Gheorghe c16726433c Allow override of timeouts from env variables 2025-08-27 22:39:58 -07:00
jtanningbed 0d61c52c11 fix: improve StorageStateWatchdog lifecycle management
- Add BrowserStopEvent handler to properly stop monitoring when browser closes
- Await LoadStorageStateEvent dispatch to ensure storage is loaded before navigation
- Clean up monitoring task on browser stop to prevent CDP connection errors

This ensures storage state is properly loaded before the browser starts navigating
and prevents error logs from monitoring attempts after the browser has closed.
2025-08-28 01:31:56 -04:00
Magnus Müller c969b956d6 Logger statement 2025-08-27 17:24:59 -07:00
Magnus Müller efb2f8bfae Autopdf download to false 2025-08-27 17:21:35 -07:00
Magnus Müller 21febf82ad Check for highlight_elements flag 2025-08-27 16:41:13 -07:00
Magnus Müller 0dd27ca976 Remove js in downloadwatchdog 2025-08-27 16:37:17 -07:00
Magnus Müller 78049eee07 Remove 0.5 s waiting in navigation 2025-08-27 12:26:59 -07:00
Magnus Müller e07c229104 Skip switch tab 2025-08-27 12:13:08 -07:00
EnzoFanAccount d354c0eb9f linting 2025-08-27 15:13:33 -03:00
EnzoFanAccount 8136d029d6 formatting 2025-08-27 15:02:40 -03:00
Magnus Müller 11a50db4fb hot-fix-local-true-if-no-cdp-url 2025-08-27 11:01:20 -07:00