working nav and screenshots and highlighting

This commit is contained in:
Nick Sweeting
2025-08-06 21:04:09 -07:00
parent fe113d7094
commit dc80ea32f0
3 changed files with 15 additions and 12 deletions

View File

@@ -24,7 +24,7 @@ from browser_use.browser.watchdog_base import BaseWatchdog
if TYPE_CHECKING:
pass
# Rebuild event models that have forward references to EnhancedDOMTreeNode
# Import EnhancedDOMTreeNode and rebuild event models that have forward references to it
# This must be done after all imports are complete
ClickElementEvent.model_rebuild()
TypeTextEvent.model_rebuild()
@@ -146,7 +146,9 @@ class DefaultActionWatchdog(BaseWatchdog):
# Try to scroll the element's container
success = await self._scroll_element_container(element_node, pixels)
if success:
self.logger.info(f'📜 Scrolled element {index_for_logging} container {event.direction} by {event.amount} pixels')
self.logger.info(
f'📜 Scrolled element {index_for_logging} container {event.direction} by {event.amount} pixels'
)
return
# Perform target-level scroll

View File

@@ -86,45 +86,45 @@ class BrowserStateRequestEvent(BaseEvent):
class GoBackEvent(BaseEvent):
"""Navigate back in browser history."""
pass
class GoForwardEvent(BaseEvent):
"""Navigate forward in browser history."""
pass
class RefreshEvent(BaseEvent):
"""Refresh/reload the current page."""
pass
class WaitEvent(BaseEvent):
"""Wait for a specified number of seconds."""
seconds: float = 3.0
max_seconds: float = 10.0 # Safety cap
class SendKeysEvent(BaseEvent):
"""Send keyboard keys/shortcuts."""
keys: str # e.g., "ctrl+a", "cmd+c", "Enter"
class UploadFileEvent(BaseEvent):
"""Upload a file to an element."""
node: 'EnhancedDOMTreeNode'
file_path: str
class ScrollToTextEvent(BaseEvent):
"""Scroll to specific text on the page."""
text: str
direction: Literal['up', 'down'] = 'down'
@@ -324,8 +324,9 @@ class AboutBlankDVDScreensaverShownEvent(BaseEvent):
error: str | None = None
# Note: Model rebuilding for forward references is handled at the end of the module import chain
# The events with 'EnhancedDOMTreeNode' forward references will be rebuilt after all imports are complete
# Note: Model rebuilding for forward references is handled in the importing modules
# Events with 'EnhancedDOMTreeNode' forward references (ClickElementEvent, TypeTextEvent,
# ScrollEvent, UploadFileEvent) need model_rebuild() called after imports are complete
# check that event names are valid and non-overlapping (naiively n^2 so it's pretty slow but ok for now, optimize when >20 events)
event_names = {

View File

@@ -40,7 +40,7 @@ from browser_use.utils import time_execution_sync
logger = logging.getLogger(__name__)
# Rebuild event models that have forward references to EnhancedDOMTreeNode
# Import EnhancedDOMTreeNode and rebuild event models that have forward references to it
# This must be done after all imports are complete
ClickElementEvent.model_rebuild()
TypeTextEvent.model_rebuild()