mirror of
https://github.com/browser-use/browser-use
synced 2026-05-06 17:52:15 +02:00
* Add http_credentials to browser context. * Detect index change caused by page change in `multi_act` * Fix: Add sameSite cookie validation and auto-correction * added drag drop action * added drag drop action * pre-commit run -a (again) * added active_tab state management * add anthropic RateLimitError to list of defined rate limit errors * Add Retry handling to bedrock example * fix pydantic issue causing config to be overwritten * fix config setup * Add botocore, organize imports * ignore langchain beta warnings * silence pydantic deprecation warnings * Update bedrock_claude for ruff * ruff checks * Update pyproject.toml and bedrock_claude.py * ignore signal registration errors in edge case environments * ruff fixes * add example of getting 2FA code from 1password * add rebrowser and creepjs to stealth tests * Fix typos discovered by codespell * uv add --dev codespell * Update browser_use/browser/context.py * lint * Add explanations override_system_message and extend_system_message * Update custom-functions.mdx .get_current_page() is an async function which have to be awaited. * Fix: Remove unnecessary await from _verified_api_keys * Fix: Correct indentation for cookie loading log message in BrowserContext * Fix: resolve undefined response variable in Deepseek model raw tool calling mode * fix: increment consecutive_failure on every step error * Fix azure example not working due to agent memory changes * dont expose debug port on all addresses and keep security enabled by default * custom browser addition --------- Co-authored-by: Bartlomiej Wietrak <bartekwietrak@gmail.com> Co-authored-by: Alin Jiang <alineveryday@outlook.com> Co-authored-by: dipfocus <dipfocus@gmail.com> Co-authored-by: PaperBoardOfficial <hiremohitforsoftwarerole@gmail.com> Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: Alezander9 <alexander.j.yue@gmail.com> Co-authored-by: dheerajoruganty <db2winfb@gmail.com> Co-authored-by: Nick Sweeting <git@sweeting.me> Co-authored-by: Dheeraj Oruganty <53569374+dheerajoruganty@users.noreply.github.com> Co-authored-by: Bart <46058081+b0rgcube@users.noreply.github.com> Co-authored-by: Nick Sweeting <github@sweeting.me> Co-authored-by: pppp606 <ppppp303@gmail.com> Co-authored-by: Oswy <74738120+oswy-cpu@users.noreply.github.com> Co-authored-by: BurnyCoder <happymancz@email.cz> Co-authored-by: zhushijie <mr.zhushijie@gmail.com> Co-authored-by: john-rtr <jonathan.ratier@gmail.com> Co-authored-by: mathisarends-viadee <mathis.arends@viadee.de> Co-authored-by: lorenss-m <saeclmusic@gmail.com> Co-authored-by: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
126 lines
3.3 KiB
Python
126 lines
3.3 KiB
Python
from typing import Optional
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
|
|
|
|
|
# Action Input Models
|
|
class SearchGoogleAction(BaseModel):
|
|
query: str
|
|
|
|
|
|
class GoToUrlAction(BaseModel):
|
|
url: str
|
|
|
|
|
|
class WaitForElementAction(BaseModel):
|
|
selector: str
|
|
timeout: Optional[int] = 10000 # Timeout in milliseconds
|
|
|
|
|
|
class ClickElementAction(BaseModel):
|
|
index: int
|
|
xpath: Optional[str] = None
|
|
|
|
|
|
class ClickElementByXpathAction(BaseModel):
|
|
xpath: str
|
|
|
|
|
|
class ClickElementBySelectorAction(BaseModel):
|
|
css_selector: str
|
|
|
|
|
|
class ClickElementByTextAction(BaseModel):
|
|
text: str
|
|
element_type: Optional[str]
|
|
nth: int = 0
|
|
|
|
|
|
class InputTextAction(BaseModel):
|
|
index: int
|
|
text: str
|
|
xpath: Optional[str] = None
|
|
|
|
|
|
class DoneAction(BaseModel):
|
|
text: str
|
|
success: bool
|
|
|
|
|
|
class SwitchTabAction(BaseModel):
|
|
page_id: int
|
|
|
|
|
|
class OpenTabAction(BaseModel):
|
|
url: str
|
|
|
|
|
|
class CloseTabAction(BaseModel):
|
|
page_id: int
|
|
|
|
|
|
class ScrollAction(BaseModel):
|
|
amount: Optional[int] = None # The number of pixels to scroll. If None, scroll down/up one page
|
|
|
|
|
|
class SendKeysAction(BaseModel):
|
|
keys: str
|
|
|
|
|
|
class GroupTabsAction(BaseModel):
|
|
tab_ids: list[int] = Field(..., description='List of tab IDs to group')
|
|
title: str = Field(..., description='Name for the tab group')
|
|
color: Optional[str] = Field(
|
|
'blue',
|
|
description='Color for the group (grey/blue/red/yellow/green/pink/purple/cyan)',
|
|
)
|
|
|
|
|
|
class UngroupTabsAction(BaseModel):
|
|
tab_ids: list[int] = Field(..., description='List of tab IDs to ungroup')
|
|
|
|
|
|
class ExtractPageContentAction(BaseModel):
|
|
value: str
|
|
|
|
|
|
class NoParamsAction(BaseModel):
|
|
"""
|
|
Accepts absolutely anything in the incoming data
|
|
and discards it, so the final parsed model is empty.
|
|
"""
|
|
|
|
model_config = ConfigDict(extra='allow')
|
|
|
|
@model_validator(mode='before')
|
|
def ignore_all_inputs(cls, values):
|
|
# No matter what the user sends, discard it and return empty.
|
|
return {}
|
|
|
|
|
|
class Position(BaseModel):
|
|
x: int
|
|
y: int
|
|
|
|
|
|
class DragDropAction(BaseModel):
|
|
# Element-based approach
|
|
element_source: Optional[str] = Field(None, description='CSS selector or XPath of the element to drag from')
|
|
element_target: Optional[str] = Field(None, description='CSS selector or XPath of the element to drop onto')
|
|
element_source_offset: Optional[Position] = Field(
|
|
None, description='Precise position within the source element to start drag (in pixels from top-left corner)'
|
|
)
|
|
element_target_offset: Optional[Position] = Field(
|
|
None, description='Precise position within the target element to drop (in pixels from top-left corner)'
|
|
)
|
|
|
|
# Coordinate-based approach (used if selectors not provided)
|
|
coord_source_x: Optional[int] = Field(None, description='Absolute X coordinate on page to start drag from (in pixels)')
|
|
coord_source_y: Optional[int] = Field(None, description='Absolute Y coordinate on page to start drag from (in pixels)')
|
|
coord_target_x: Optional[int] = Field(None, description='Absolute X coordinate on page to drop at (in pixels)')
|
|
coord_target_y: Optional[int] = Field(None, description='Absolute Y coordinate on page to drop at (in pixels)')
|
|
|
|
# Common options
|
|
steps: Optional[int] = Field(10, description='Number of intermediate points for smoother movement (5-20 recommended)')
|
|
delay_ms: Optional[int] = Field(5, description='Delay in milliseconds between steps (0 for fastest, 10-20 for more natural)')
|