sample_id stringlengths 21 196 | text stringlengths 105 936k | metadata dict | category stringclasses 6
values |
|---|---|---|---|
browser-use/browser-use:tests/ci/models/test_azure_responses_api.py | """Tests for Azure OpenAI Responses API support."""
import os
import pytest
from browser_use.llm.azure.chat import RESPONSES_API_ONLY_MODELS, ChatAzureOpenAI
from browser_use.llm.messages import (
AssistantMessage,
ContentPartImageParam,
ContentPartTextParam,
Function,
ImageURL,
SystemMessage,
ToolCall,
User... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/models/test_azure_responses_api.py",
"license": "MIT License",
"lines": 224,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_ai_step.py | """Tests for AI step private method used during rerun"""
from unittest.mock import AsyncMock
from browser_use.agent.service import Agent
from browser_use.agent.views import ActionResult
from tests.ci.conftest import create_mock_llm
async def test_execute_ai_step_basic():
"""Test that _execute_ai_step extracts cont... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_ai_step.py",
"license": "MIT License",
"lines": 92,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_ax_name_matching.py | """Tests for ax_name (accessible name) element matching in history rerun.
This tests Level 4 matching which uses the accessibility tree's name property
to match elements when hash, stable_hash, and xpath all fail.
This is particularly useful for dynamic SPAs where DOM structure changes
but accessible names remain stab... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_ax_name_matching.py",
"license": "MIT License",
"lines": 481,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_coordinate_clicking.py | """Tests for coordinate clicking feature.
This feature allows certain models (Claude Sonnet 4, Claude Opus 4, Gemini 3 Pro, browser-use/* models)
to use coordinate-based clicking, while other models only get index-based clicking.
"""
import pytest
from browser_use.tools.service import Tools
from browser_use.tools.vi... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_coordinate_clicking.py",
"license": "MIT License",
"lines": 143,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_extension_config.py | """Tests for extension configuration environment variables."""
import os
import pytest
class TestDisableExtensionsEnvVar:
"""Test BROWSER_USE_DISABLE_EXTENSIONS environment variable."""
def test_default_value_is_true(self):
"""Without env var set, enable_default_extensions should default to True."""
# Clear ... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_extension_config.py",
"license": "MIT License",
"lines": 102,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_fallback_llm.py | """
Tests for the fallback_llm feature in Agent.
Tests verify that when the primary LLM fails with rate limit (429) or server errors (503, 502, 500, 504),
the agent automatically switches to the fallback LLM and continues execution.
"""
from unittest.mock import AsyncMock
import pytest
from browser_use.agent.views ... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_fallback_llm.py",
"license": "MIT License",
"lines": 332,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_markdown_extractor.py | """Tests for markdown extractor preprocessing."""
from browser_use.dom.markdown_extractor import _preprocess_markdown_content
class TestPreprocessMarkdownContent:
"""Tests for _preprocess_markdown_content function."""
def test_preserves_short_lines(self):
"""Short lines (1-2 chars) should be preserved, not remo... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_markdown_extractor.py",
"license": "MIT License",
"lines": 80,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_sandbox_structured_output.py | """
Tests for sandbox structured output handling.
Tests that output_model_schema works correctly when using @sandbox decorator,
specifically that the _output_model_schema private attribute is preserved
through serialization/deserialization.
"""
from pydantic import BaseModel
from browser_use.agent.views import Actio... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_sandbox_structured_output.py",
"license": "MIT License",
"lines": 181,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:browser_use/actor/utils.py | """Utility functions for actor operations."""
class Utils:
"""Utility functions for actor operations."""
@staticmethod
def get_key_info(key: str) -> tuple[str, int | None]:
"""Get the code and windowsVirtualKeyCode for a key.
Args:
key: Key name (e.g., 'Enter', 'ArrowUp', 'a', 'A')
Returns:
Tuple of... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/actor/utils.py",
"license": "MIT License",
"lines": 162,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:browser_use/agent/judge.py | """Judge system for evaluating browser-use agent execution traces."""
import base64
import logging
from pathlib import Path
from typing import Literal
from browser_use.llm.messages import (
BaseMessage,
ContentPartImageParam,
ContentPartTextParam,
ImageURL,
SystemMessage,
UserMessage,
)
logger = logging.getLog... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/agent/judge.py",
"license": "MIT License",
"lines": 188,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use:browser_use/agent/variable_detector.py | """Detect variables in agent history for reuse"""
import re
from browser_use.agent.views import AgentHistoryList, DetectedVariable
from browser_use.dom.views import DOMInteractedElement
def detect_variables_in_history(history: AgentHistoryList) -> dict[str, DetectedVariable]:
"""
Analyze agent history and detect ... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/agent/variable_detector.py",
"license": "MIT License",
"lines": 215,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/cloud/views.py | from typing import Literal
from uuid import UUID
from pydantic import BaseModel, ConfigDict, Field
ProxyCountryCode = (
Literal[
'us', # United States
'uk', # United Kingdom
'fr', # France
'it', # Italy
'jp', # Japan
'au', # Australia
'de', # Germany
'fi', # Finland
'ca', # Canada
'in', ... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/cloud/views.py",
"license": "MIT License",
"lines": 68,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:browser_use/browser/session_manager.py | """Event-driven CDP session management.
Manages CDP sessions by listening to Target.attachedToTarget and Target.detachedFromTarget
events, ensuring the session pool always reflects the current browser state.
"""
import asyncio
from typing import TYPE_CHECKING
from cdp_use.cdp.target import AttachedToTargetEvent, Det... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/session_manager.py",
"license": "MIT License",
"lines": 740,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/code_use/formatting.py | """Browser state formatting helpers for code-use agent."""
import logging
from typing import Any
from browser_use.browser.session import BrowserSession
from browser_use.browser.views import BrowserStateSummary
logger = logging.getLogger(__name__)
async def format_browser_state_for_llm(
state: BrowserStateSummary,... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/code_use/formatting.py",
"license": "MIT License",
"lines": 160,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/code_use/namespace.py | """Namespace initialization for code-use mode.
This module creates a namespace with all browser tools available as functions,
similar to a Jupyter notebook environment.
"""
import asyncio
import csv
import datetime
import json
import logging
import re
from pathlib import Path
from typing import Any
import requests
... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/code_use/namespace.py",
"license": "MIT License",
"lines": 547,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/code_use/notebook_export.py | """Export code-use session to Jupyter notebook format."""
import json
import re
from pathlib import Path
from browser_use.code_use.service import CodeAgent
from .views import CellType, NotebookExport
def export_to_ipynb(agent: CodeAgent, output_path: str | Path) -> Path:
"""
Export a NotebookSession to a Jupyter... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/code_use/notebook_export.py",
"license": "MIT License",
"lines": 232,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/code_use/service.py | """Code-use agent service - Jupyter notebook-like code execution for browser automation."""
import asyncio
import datetime
import html
import json
import logging
import re
import tempfile
import traceback
from pathlib import Path
from typing import Any
from uuid_extensions import uuid7str
from browser_use.browser im... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/code_use/service.py",
"license": "MIT License",
"lines": 1232,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/code_use/views.py | """Data models for code-use mode."""
from __future__ import annotations
import json
from enum import Enum
from pathlib import Path
from typing import Any
from pydantic import BaseModel, ConfigDict, Field, PrivateAttr
from uuid_extensions import uuid7str
from browser_use.tokens.views import UsageSummary
class Cell... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/code_use/views.py",
"license": "MIT License",
"lines": 320,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/dom/markdown_extractor.py | """
Shared markdown extraction utilities for browser content processing.
This module provides a unified interface for extracting clean markdown from browser content,
used by both the tools service and page actor.
"""
import re
from dataclasses import dataclass
from enum import Enum, auto
from typing import TYPE_CHECK... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/dom/markdown_extractor.py",
"license": "MIT License",
"lines": 450,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/dom/serializer/code_use_serializer.py | # @file purpose: Ultra-compact serializer optimized for code-use agents
# Focuses on minimal token usage while preserving essential interactive context
from browser_use.dom.utils import cap_text_length
from browser_use.dom.views import (
EnhancedDOMTreeNode,
NodeType,
SimplifiedNode,
)
# Minimal but sufficient att... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/dom/serializer/code_use_serializer.py",
"license": "MIT License",
"lines": 238,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/dom/serializer/eval_serializer.py | # @file purpose: Concise evaluation serializer for DOM trees - optimized for LLM query writing
from browser_use.dom.utils import cap_text_length
from browser_use.dom.views import (
EnhancedDOMTreeNode,
NodeType,
SimplifiedNode,
)
# Critical attributes for query writing and form interaction
# NOTE: Removed 'id' an... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/dom/serializer/eval_serializer.py",
"license": "MIT License",
"lines": 407,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/dom/serializer/html_serializer.py | # @file purpose: Serializes enhanced DOM trees to HTML format including shadow roots
from browser_use.dom.views import EnhancedDOMTreeNode, NodeType
class HTMLSerializer:
"""Serializes enhanced DOM trees back to HTML format.
This serializer reconstructs HTML from the enhanced DOM tree, including:
- Shadow DOM co... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/dom/serializer/html_serializer.py",
"license": "MIT License",
"lines": 245,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/init_cmd.py | """
Standalone init command for browser-use template generation.
This module provides a minimal command-line interface for generating
browser-use templates without requiring heavy TUI dependencies.
"""
import json
import shutil
import sys
from pathlib import Path
from typing import Any
from urllib import request
from... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/init_cmd.py",
"license": "MIT License",
"lines": 370,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/llm/browser_use/chat.py | """
ChatBrowserUse - Client for browser-use cloud API
This wraps the BaseChatModel protocol and sends requests to the browser-use cloud API
for optimized browser automation LLM inference.
"""
import asyncio
import logging
import os
import random
from typing import Any, TypeVar, overload
import httpx
from pydantic im... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/browser_use/chat.py",
"license": "MIT License",
"lines": 247,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/llm/cerebras/chat.py | from __future__ import annotations
from dataclasses import dataclass
from typing import Any, TypeVar, overload
import httpx
from openai import (
APIConnectionError,
APIError,
APIStatusError,
APITimeoutError,
AsyncOpenAI,
RateLimitError,
)
from openai.types.chat import ChatCompletion
from pydantic import BaseMod... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/cerebras/chat.py",
"license": "MIT License",
"lines": 167,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/llm/cerebras/serializer.py | from __future__ import annotations
import json
from typing import Any, overload
from browser_use.llm.messages import (
AssistantMessage,
BaseMessage,
ContentPartImageParam,
ContentPartTextParam,
SystemMessage,
ToolCall,
UserMessage,
)
MessageDict = dict[str, Any]
class CerebrasMessageSerializer:
"""Seriali... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/cerebras/serializer.py",
"license": "MIT License",
"lines": 95,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/llm/oci_raw/chat.py | """
OCI Raw API chat model integration for browser-use.
This module provides direct integration with Oracle Cloud Infrastructure's
Generative AI service using raw API calls without Langchain dependencies.
"""
import asyncio
import json
from dataclasses import dataclass
from typing import Any, TypeVar, overload
impor... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/oci_raw/chat.py",
"license": "MIT License",
"lines": 387,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/llm/oci_raw/serializer.py | """
Message serializer for OCI Raw API integration.
This module handles the conversion between browser-use message formats
and the OCI Raw API message format using proper OCI SDK models.
"""
from oci.generative_ai_inference.models import ImageContent, ImageUrl, Message, TextContent
from browser_use.llm.messages impo... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/oci_raw/serializer.py",
"license": "MIT License",
"lines": 196,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/llm/vercel/chat.py | import json
from collections.abc import Mapping
from dataclasses import dataclass, field
from typing import Any, Literal, TypeAlias, TypeVar, overload
import httpx
from openai import APIConnectionError, APIStatusError, AsyncOpenAI, RateLimitError
from openai.types.chat.chat_completion import ChatCompletion
from openai... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/vercel/chat.py",
"license": "MIT License",
"lines": 468,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/llm/vercel/serializer.py | from openai.types.chat import ChatCompletionMessageParam
from browser_use.llm.messages import BaseMessage
from browser_use.llm.openai.serializer import OpenAIMessageSerializer
class VercelMessageSerializer:
"""
Serializer for converting between custom message types and Vercel AI Gateway message formats.
Vercel A... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/llm/vercel/serializer.py",
"license": "MIT License",
"lines": 19,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use:browser_use/sandbox/sandbox.py | import ast
import asyncio
import base64
import dataclasses
import enum
import inspect
import json
import os
import sys
import textwrap
from collections.abc import Callable, Coroutine
from functools import wraps
from typing import TYPE_CHECKING, Any, Concatenate, ParamSpec, TypeVar, Union, cast, get_args, get_origin
im... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/sandbox/sandbox.py",
"license": "MIT License",
"lines": 555,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/sandbox/views.py | """Type-safe event models for sandbox execution SSE streaming"""
import json
from enum import Enum
from typing import Any
from pydantic import BaseModel
class SandboxError(Exception):
pass
class SSEEventType(str, Enum):
"""Event types for Server-Sent Events"""
BROWSER_CREATED = 'browser_created'
INSTANCE_CRE... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/sandbox/views.py",
"license": "MIT License",
"lines": 94,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/tokens/custom_pricing.py | """
Custom model pricing for models not available in LiteLLM's pricing data.
Prices are per token (not per 1M tokens).
"""
from typing import Any
# Custom model pricing data
# Format matches LiteLLM's model_prices_and_context_window.json structure
CUSTOM_MODEL_PRICING: dict[str, dict[str, Any]] = {
'bu-1-0': {
'i... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/tokens/custom_pricing.py",
"license": "MIT License",
"lines": 29,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:browser_use/tools/utils.py | """Utility functions for browser tools."""
from browser_use.dom.service import EnhancedDOMTreeNode
def get_click_description(node: EnhancedDOMTreeNode) -> str:
"""Get a brief description of the clicked element for memory."""
parts = []
# Tag name
parts.append(node.tag_name)
# Add type for inputs
if node.tag_... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/tools/utils.py",
"license": "MIT License",
"lines": 69,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/browser/save_cookies.py | """
Export cookies and storage state from your real Chrome browser
This allows you to save your authenticated sessions for later use
without needing to connect to the Chrome profile every time
"""
import asyncio
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__fi... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/browser/save_cookies.py",
"license": "MIT License",
"lines": 34,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/code_agent/extract_products.py | """
Example: Using code-use mode to extract products from multiple pages.
This example demonstrates the new code-use mode, which works like a Jupyter notebook
where the LLM writes Python code that gets executed in a persistent namespace.
The agent can:
- Navigate to pages
- Extract data using JavaScript
- Combine res... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/code_agent/extract_products.py",
"license": "MIT License",
"lines": 34,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use:examples/code_agent/filter_webvoyager_dataset.py | import asyncio
from browser_use.code_use import CodeAgent
async def main():
task = """
Find the WebVoyager dataset, download it and create a new version where you remove all tasks which have older dates than today.
"""
# Create code-use agent
agent = CodeAgent(
task=task,
max_steps=25,
)
try:
# Run the ... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/code_agent/filter_webvoyager_dataset.py",
"license": "MIT License",
"lines": 19,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/demo_mode_example.py | import asyncio
from browser_use import Agent, ChatBrowserUse
async def main() -> None:
agent = Agent(
task='Please find the latest commit on browser-use/browser-use repo and tell me the commit message. Please summarize what it is about.',
llm=ChatBrowserUse(model='bu-2-0'),
demo_mode=True,
)
await agent.run... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/demo_mode_example.py",
"license": "MIT License",
"lines": 11,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/features/judge_trace.py | """
Setup:
1. Get your API key from https://cloud.browser-use.com/new-api-key
2. Set environment variable: export BROWSER_USE_API_KEY="your-key"
"""
import asyncio
import os
import sys
# Add the parent directory to the path so we can import browser_use
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(o... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/features/judge_trace.py",
"license": "MIT License",
"lines": 36,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/features/large_blocklist.py | """
Example: Using large blocklists (400k+ domains) with automatic optimization
This example demonstrates:
1. Loading a real-world blocklist (HaGeZi's Pro++ with 439k+ domains)
2. Automatic conversion to set for O(1) lookup performance
3. Testing that blocked domains are actually blocked
Performance: ~0.02ms per doma... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/features/large_blocklist.py",
"license": "MIT License",
"lines": 85,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/features/stop_externally.py | import asyncio
import os
import random
import sys
from browser_use.llm.google.chat import ChatGoogle
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from dotenv import load_dotenv
load_dotenv()
from browser_use import Agent
llm = ChatGoogle(model='gemini-flash-latest', temperature=1.0... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/features/stop_externally.py",
"license": "MIT License",
"lines": 27,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/models/browser_use_llm.py | """
Example of the fastest + smartest LLM for browser automation.
Setup:
1. Get your API key from https://cloud.browser-use.com/new-api-key
2. Set environment variable: export BROWSER_USE_API_KEY="your-key"
"""
import asyncio
import os
from dotenv import load_dotenv
from browser_use import Agent, ChatBrowserUse
lo... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/browser_use_llm.py",
"license": "MIT License",
"lines": 22,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/models/cerebras_example.py | """
Example of using Cerebras with browser-use.
To use this example:
1. Set your CEREBRAS_API_KEY environment variable
2. Run this script
Cerebras integration is working great for:
- Direct text generation
- Simple tasks without complex structured output
- Fast inference for web automation
Available Cerebras models ... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/cerebras_example.py",
"license": "MIT License",
"lines": 61,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/models/gemini-3.py | import asyncio
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from dotenv import load_dotenv
from browser_use import Agent, ChatGoogle
load_dotenv()
api_key = os.getenv('GOOGLE_API_KEY')
if not api_key:
raise ValueError('GOOGLE_API_KEY is not set... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/gemini-3.py",
"license": "MIT License",
"lines": 20,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/models/moonshot.py | import asyncio
import os
from dotenv import load_dotenv
from browser_use import Agent, ChatOpenAI
load_dotenv()
# Get API key from environment variable
api_key = os.getenv('MOONSHOT_API_KEY')
if api_key is None:
print('Make sure you have MOONSHOT_API_KEY set in your .env file')
print('Get your API key from https:... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/moonshot.py",
"license": "MIT License",
"lines": 29,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/models/oci_models.py | """
Oracle Cloud Infrastructure (OCI) Raw API Example
This example demonstrates how to use OCI's Generative AI service with browser-use
using the raw API integration (ChatOCIRaw) without Langchain dependencies.
@dev You need to:
1. Set up OCI configuration file at ~/.oci/config
2. Have access to OCI Generative AI mod... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/oci_models.py",
"license": "MIT License",
"lines": 201,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/models/vercel_ai_gateway.py | """
Example using Vercel AI Gateway with browser-use.
Vercel AI Gateway provides an OpenAI-compatible API endpoint that can proxy
requests to various AI providers. This allows you to use Vercel's infrastructure
for rate limiting, caching, and monitoring.
Prerequisites:
1. Set VERCEL_API_KEY in your environment variab... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/vercel_ai_gateway.py",
"license": "MIT License",
"lines": 46,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/sandbox/example.py | """Example of using sandbox execution with Browser-Use Agent
This example demonstrates how to use the @sandbox decorator to run
browser automation tasks with the Agent in a sandbox environment.
To run this example:
1. Set your BROWSER_USE_API_KEY environment variable
2. Set your LLM API key (OPENAI_API_KEY, ANTHROPIC... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/sandbox/example.py",
"license": "MIT License",
"lines": 47,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/use-cases/apply_to_job.py | import argparse
import asyncio
import json
import os
from dotenv import load_dotenv
from browser_use import Agent, Browser, ChatOpenAI, Tools
from browser_use.tools.views import UploadFileAction
load_dotenv()
async def apply_to_rochester_regional_health(info: dict, resume_path: str):
"""
json format:
{
"fi... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/use-cases/apply_to_job.py",
"license": "MIT License",
"lines": 110,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use:examples/use-cases/buy_groceries.py | import asyncio
from pydantic import BaseModel, Field
from browser_use import Agent, Browser, ChatBrowserUse
class GroceryItem(BaseModel):
"""A single grocery item"""
name: str = Field(..., description='Item name')
price: float = Field(..., description='Price as number')
brand: str | None = Field(None, descript... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/use-cases/buy_groceries.py",
"license": "MIT License",
"lines": 61,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/use-cases/onepassword.py | import os
from onepassword.client import Client
from browser_use import ActionResult, Agent, Browser, ChatOpenAI, Tools
from browser_use.browser.session import BrowserSession
"""
Use Case: Securely log into a website using credentials stored in 1Password vault.
- Use fill_field action to fill in username and passwor... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/use-cases/onepassword.py",
"license": "MIT License",
"lines": 153,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use:examples/use-cases/pcpartpicker.py | import asyncio
from browser_use import Agent, Browser, ChatBrowserUse, Tools
async def main():
browser = Browser(cdp_url='http://localhost:9222')
llm = ChatBrowserUse(model='bu-2-0')
tools = Tools()
task = """
Design me a mid-range water-cooled ITX computer
Keep the total budget under $2000
Go to... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/use-cases/pcpartpicker.py",
"license": "MIT License",
"lines": 25,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/use-cases/phone_comparison.py | import asyncio
from pydantic import BaseModel, Field
from browser_use import Agent, Browser, ChatBrowserUse
class ProductListing(BaseModel):
"""A single product listing"""
title: str = Field(..., description='Product title')
url: str = Field(..., description='Full URL to listing')
price: float = Field(..., des... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/use-cases/phone_comparison.py",
"license": "MIT License",
"lines": 67,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:tests/ci/browser/test_cross_origin_click.py | """Test clicking elements inside cross-origin iframes."""
import asyncio
import pytest
from browser_use.browser.profile import BrowserProfile, ViewportSize
from browser_use.browser.session import BrowserSession
from browser_use.tools.service import Tools
@pytest.fixture
async def browser_session():
"""Create brow... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/browser/test_cross_origin_click.py",
"license": "MIT License",
"lines": 109,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/browser/test_dom_serializer.py | """
Test DOM serializer with complex scenarios: shadow DOM, same-origin and cross-origin iframes.
This test verifies that the DOM serializer correctly:
1. Extracts interactive elements from shadow DOM
2. Processes same-origin iframes
3. Handles cross-origin iframes (should be blocked)
4. Generates correct selector_map... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/browser/test_dom_serializer.py",
"license": "MIT License",
"lines": 480,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/browser/test_navigation.py | """
Test navigation edge cases: broken pages, slow loading, non-existing pages.
Tests verify that:
1. Agent can handle navigation to broken/malformed HTML pages
2. Agent can handle slow-loading pages without hanging
3. Agent can handle non-existing pages (404, connection refused, etc.)
4. Agent can recover and continu... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/browser/test_navigation.py",
"license": "MIT License",
"lines": 347,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/browser/test_screenshot.py | import pytest
from pytest_httpserver import HTTPServer
from browser_use.agent.service import Agent
from browser_use.browser.events import NavigateToUrlEvent
from browser_use.browser.profile import BrowserProfile
from browser_use.browser.session import BrowserSession
from tests.ci.conftest import create_mock_llm
@pyt... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/browser/test_screenshot.py",
"license": "MIT License",
"lines": 134,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/browser/test_tabs.py | """
Test multi-tab operations: creation, switching, closing, and background tabs.
Tests verify that:
1. Agent can create multiple tabs (3) and switch between them
2. Agent can close tabs with vision=True
3. Agent can handle buttons that open new tabs in background
4. Agent can continue and call done() after each tab o... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/browser/test_tabs.py",
"license": "MIT License",
"lines": 609,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/browser/test_true_cross_origin_click.py | """Test clicking elements inside TRUE cross-origin iframes (external domains)."""
import asyncio
import pytest
from browser_use.browser.profile import BrowserProfile, ViewportSize
from browser_use.browser.session import BrowserSession
from browser_use.tools.service import Tools
@pytest.fixture
async def browser_se... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/browser/test_true_cross_origin_click.py",
"license": "MIT License",
"lines": 105,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/infrastructure/test_registry_validation.py | """
Comprehensive tests for the action registry system - Validation and patterns.
Tests cover:
1. Type 1 and Type 2 patterns
2. Validation rules
3. Decorated function behavior
4. Parameter model generation
5. Parameter ordering
"""
import asyncio
import logging
import pytest
from pydantic import Field
from browser_... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/infrastructure/test_registry_validation.py",
"license": "MIT License",
"lines": 420,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/models/model_test_helper.py | """Shared test helper for LLM model tests."""
import os
import pytest
from browser_use.agent.service import Agent
from browser_use.browser.profile import BrowserProfile
from browser_use.browser.session import BrowserSession
async def run_model_button_click_test(
model_class,
model_name: str,
api_key_env: str | ... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/models/model_test_helper.py",
"license": "MIT License",
"lines": 91,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/models/test_llm_anthropic.py | """Test Anthropic model button click."""
from browser_use.llm.anthropic.chat import ChatAnthropic
from tests.ci.models.model_test_helper import run_model_button_click_test
async def test_anthropic_claude_sonnet_4_0(httpserver):
"""Test Anthropic claude-sonnet-4-0 can click a button."""
await run_model_button_click... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/models/test_llm_anthropic.py",
"license": "MIT License",
"lines": 12,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/models/test_llm_azure.py | """Test Azure OpenAI model button click."""
from browser_use.llm.azure.chat import ChatAzureOpenAI
from tests.ci.models.model_test_helper import run_model_button_click_test
async def test_azure_gpt_4_1_mini(httpserver):
"""Test Azure OpenAI gpt-4.1-mini can click a button."""
await run_model_button_click_test(
m... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/models/test_llm_azure.py",
"license": "MIT License",
"lines": 12,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/models/test_llm_browseruse.py | """Test Browser Use model button click."""
from browser_use.llm.browser_use.chat import ChatBrowserUse
from tests.ci.models.model_test_helper import run_model_button_click_test
async def test_browseruse_bu_latest(httpserver):
"""Test Browser Use bu-latest can click a button."""
await run_model_button_click_test(
... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/models/test_llm_browseruse.py",
"license": "MIT License",
"lines": 12,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/models/test_llm_google.py | """Test Google model button click."""
from browser_use.llm.google.chat import ChatGoogle
from tests.ci.models.model_test_helper import run_model_button_click_test
async def test_google_gemini_flash_latest(httpserver):
"""Test Google gemini-flash-latest can click a button."""
await run_model_button_click_test(
mo... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/models/test_llm_google.py",
"license": "MIT License",
"lines": 12,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/models/test_llm_openai.py | """Test OpenAI model button click."""
from browser_use.llm.openai.chat import ChatOpenAI
from tests.ci.models.model_test_helper import run_model_button_click_test
async def test_openai_gpt_4_1_mini(httpserver):
"""Test OpenAI gpt-4.1-mini can click a button."""
await run_model_button_click_test(
model_class=Chat... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/models/test_llm_openai.py",
"license": "MIT License",
"lines": 12,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/security/test_ip_blocking.py | """
Comprehensive tests for IP address blocking in SecurityWatchdog.
Tests cover IPv4, IPv6, localhost, private networks, edge cases, and interactions
with allowed_domains and prohibited_domains configurations.
"""
from bubus import EventBus
from browser_use.browser import BrowserProfile, BrowserSession
from browser... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/security/test_ip_blocking.py",
"license": "MIT License",
"lines": 391,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_file_system_docx.py | """Tests for DOCX file support in the FileSystem."""
from pathlib import Path
import pytest
from browser_use.filesystem.file_system import (
DocxFile,
FileSystem,
)
class TestDocxFile:
"""Test DOCX file operations."""
@pytest.mark.asyncio
async def test_create_docx_file(self, tmp_path: Path):
"""Test creat... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_file_system_docx.py",
"license": "MIT License",
"lines": 148,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_file_system_images.py | """Tests for image file support in the FileSystem."""
import base64
import io
from pathlib import Path
import pytest
from PIL import Image
from browser_use.filesystem.file_system import FileSystem
class TestImageFiles:
"""Test image file operations - only external reading supported."""
def create_test_image(sel... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_file_system_images.py",
"license": "MIT License",
"lines": 195,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_file_system_llm_integration.py | """Integration tests for DOCX and image file support in LLM messages."""
import base64
import io
from pathlib import Path
import pytest
from PIL import Image
from browser_use.agent.message_manager.service import MessageManager
from browser_use.agent.prompts import AgentMessagePrompt
from browser_use.agent.views impo... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_file_system_llm_integration.py",
"license": "MIT License",
"lines": 310,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_history_wait_time.py | from browser_use.agent.views import StepMetadata
def test_step_metadata_has_step_interval_field():
"""Test that StepMetadata includes step_interval field"""
metadata = StepMetadata(step_number=1, step_start_time=10.0, step_end_time=12.5, step_interval=2.5)
assert hasattr(metadata, 'step_interval')
assert metadat... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_history_wait_time.py",
"license": "MIT License",
"lines": 86,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_rerun_ai_summary.py | """Tests for AI summary generation during rerun"""
from unittest.mock import AsyncMock
from browser_use.agent.service import Agent
from browser_use.agent.views import ActionResult, AgentHistory, AgentHistoryList, RerunSummaryAction, StepMetadata
from browser_use.browser.views import BrowserStateHistory
from browser_u... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_rerun_ai_summary.py",
"license": "MIT License",
"lines": 1097,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_screenshot_exclusion.py | """Test that screenshot action is excluded when use_vision != 'auto'."""
import pytest
from browser_use.agent.service import Agent
from browser_use.browser.profile import BrowserProfile
from browser_use.browser.session import BrowserSession
from browser_use.tools.service import Tools
from tests.ci.conftest import cre... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_screenshot_exclusion.py",
"license": "MIT License",
"lines": 130,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_variable_detection.py | """Unit tests for variable detection in agent history"""
from browser_use.agent.variable_detector import (
_detect_from_attributes,
_detect_from_value_pattern,
_detect_variable_type,
_ensure_unique_name,
detect_variables_in_history,
)
from browser_use.agent.views import DetectedVariable
from browser_use.dom.views... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_variable_detection.py",
"license": "MIT License",
"lines": 299,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:tests/ci/test_variable_substitution.py | """Unit tests for variable substitution in agent history"""
from types import SimpleNamespace
from browser_use.agent.service import Agent
from browser_use.dom.views import DOMInteractedElement, NodeType
def create_test_element(attributes: dict[str, str] | None = None) -> DOMInteractedElement:
"""Helper to create a... | {
"repo_id": "browser-use/browser-use",
"file_path": "tests/ci/test_variable_substitution.py",
"license": "MIT License",
"lines": 214,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
browser-use/browser-use:examples/features/blocked_domains.py | import asyncio
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from dotenv import load_dotenv
load_dotenv()
from browser_use import Agent, ChatOpenAI
from browser_use.browser import BrowserProfile, BrowserSession
llm = ChatOpenAI(model='gpt-4o-mini... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/features/blocked_domains.py",
"license": "MIT License",
"lines": 48,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/models/modelscope_example.py | """
Simple try of the agent.
@dev You need to add MODELSCOPE_API_KEY to your environment variables.
"""
import asyncio
import os
from dotenv import load_dotenv
from browser_use import Agent, ChatOpenAI
# dotenv
load_dotenv()
api_key = os.getenv('MODELSCOPE_API_KEY', '')
if not api_key:
raise ValueError('MODELSCO... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/models/modelscope_example.py",
"license": "MIT License",
"lines": 23,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:browser_use/actor/element.py | """Element class for element operations."""
import asyncio
from typing import TYPE_CHECKING, Literal, Union
from cdp_use.client import logger
from typing_extensions import TypedDict
if TYPE_CHECKING:
from cdp_use.cdp.dom.commands import (
DescribeNodeParameters,
FocusParameters,
GetAttributesParameters,
Get... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/actor/element.py",
"license": "MIT License",
"lines": 1011,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/actor/mouse.py | """Mouse class for mouse operations."""
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from cdp_use.cdp.input.commands import DispatchMouseEventParameters, SynthesizeScrollGestureParameters
from cdp_use.cdp.input.types import MouseButton
from browser_use.browser.session import BrowserSession
class Mouse:
"... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/actor/mouse.py",
"license": "MIT License",
"lines": 115,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/actor/page.py | """Page class for page-level operations."""
from typing import TYPE_CHECKING, TypeVar
from pydantic import BaseModel
from browser_use import logger
from browser_use.actor.utils import get_key_info
from browser_use.dom.serializer.serializer import DOMTreeSerializer
from browser_use.dom.service import DomService
from ... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/actor/page.py",
"license": "MIT License",
"lines": 437,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/actor/playground/flights.py | import asyncio
from browser_use import Agent, Browser, ChatOpenAI
llm = ChatOpenAI('gpt-4.1-mini')
async def main():
"""
Main function demonstrating mixed automation with Browser-Use and Playwright.
"""
print('🚀 Mixed Automation with Browser-Use and Actor API')
browser = Browser(keep_alive=True)
await brows... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/actor/playground/flights.py",
"license": "MIT License",
"lines": 25,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:browser_use/actor/playground/mixed_automation.py | import asyncio
from pydantic import BaseModel
from browser_use import Browser, ChatOpenAI
TASK = """
On the current wikipedia page, find the latest huge edit and tell me what is was about.
"""
class LatestEditFinder(BaseModel):
"""Find the latest huge edit on the current wikipedia page."""
latest_edit: str
edi... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/actor/playground/mixed_automation.py",
"license": "MIT License",
"lines": 34,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:browser_use/actor/playground/playground.py | #!/usr/bin/env python3
"""
Playground script to test the browser-use actor API.
This script demonstrates:
- Starting a browser session
- Using the actor API to navigate and interact
- Finding elements, clicking, scrolling, JavaScript evaluation
- Testing most of the available methods
"""
import asyncio
import json
im... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/actor/playground/playground.py",
"license": "MIT License",
"lines": 186,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/apps/ad-use/ad_generator.py | import argparse
import asyncio
import logging
import os
import subprocess
import sys
from datetime import datetime
from pathlib import Path
from browser_use.utils import create_task_with_error_handling
def setup_environment(debug: bool):
if not debug:
os.environ['BROWSER_USE_SETUP_LOGGING'] = 'false'
os.environ... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/apps/ad-use/ad_generator.py",
"license": "MIT License",
"lines": 328,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/apps/msg-use/login.py | import asyncio
import os
from pathlib import Path
from browser_use import Agent, BrowserSession
from browser_use.llm.google import ChatGoogle
GOOGLE_API_KEY = os.getenv('GOOGLE_API_KEY')
# Browser profile directory for persistence (same as main script)
USER_DATA_DIR = Path.home() / '.config' / 'whatsapp_scheduler' /... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/apps/msg-use/login.py",
"license": "MIT License",
"lines": 52,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/apps/msg-use/scheduler.py | #!/usr/bin/env python3
"""
WhatsApp Message Scheduler - Send scheduled messages via WhatsApp Web
"""
import argparse
import asyncio
import json
import logging
import os
import random
import re
from datetime import datetime, timedelta
from pathlib import Path
def setup_environment(debug: bool):
if not debug:
os.en... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/apps/msg-use/scheduler.py",
"license": "MIT License",
"lines": 223,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/apps/news-use/news_monitor.py | #!/usr/bin/env python3
"""
News monitoring agent with browser-use + Gemini Flash.
Automatically extracts and analyzes the latest articles from any news website.
"""
import argparse
import asyncio
import hashlib
import json
import logging
import os
import time
from datetime import datetime
from typing import Literal
f... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/apps/news-use/news_monitor.py",
"license": "MIT License",
"lines": 243,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/browser/cloud_browser.py | """
Examples of using Browser-Use cloud browser service.
Prerequisites:
1. Set BROWSER_USE_API_KEY environment variable
2. Active subscription at https://cloud.browser-use.com
"""
import asyncio
from dotenv import load_dotenv
from browser_use import Agent, Browser, ChatBrowserUse
load_dotenv()
async def basic():... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/browser/cloud_browser.py",
"license": "MIT License",
"lines": 42,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/custom-functions/actor_use.py | import asyncio
import os
import sys
from browser_use.browser.session import BrowserSession
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from dotenv import load_dotenv
load_dotenv()
from browser_use import ActionResult, Agent, ChatOpenAI, Tools
tools = Tools()
llm ... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/custom-functions/actor_use.py",
"license": "MIT License",
"lines": 22,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:examples/features/rerun_history.py | """
Example: Rerunning saved agent history with variable detection and substitution
This example shows how to:
1. Run an agent and save its history (including initial URL navigation)
2. Detect variables in the saved history (emails, names, dates, etc.)
3. Rerun the history with substituted values (different data)
4. G... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/features/rerun_history.py",
"license": "MIT License",
"lines": 119,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/dom/serializer/paint_order.py | from collections import defaultdict
from dataclasses import dataclass
from browser_use.dom.views import SimplifiedNode
"""
Helper class for maintaining a union of rectangles (used for order of elements calculation)
"""
@dataclass(frozen=True, slots=True)
class Rect:
"""Closed axis-aligned rectangle with (x1,y1) bo... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/dom/serializer/paint_order.py",
"license": "MIT License",
"lines": 156,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:examples/features/follow_up_task.py | from dotenv import load_dotenv
from browser_use import Agent, Browser
load_dotenv()
import asyncio
async def main():
browser = Browser(keep_alive=True)
await browser.start()
agent = Agent(task='search for browser-use.', browser_session=browser)
await agent.run(max_steps=2)
agent.add_new_task('return the tit... | {
"repo_id": "browser-use/browser-use",
"file_path": "examples/features/follow_up_task.py",
"license": "MIT License",
"lines": 14,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
browser-use/browser-use:browser_use/agent/cloud_events.py | import base64
import os
from datetime import datetime, timezone
from pathlib import Path
import anyio
from bubus import BaseEvent
from pydantic import Field, field_validator
from uuid_extensions import uuid7str
MAX_STRING_LENGTH = 500000 # 100K chars ~ 25k tokens should be enough
MAX_URL_LENGTH = 100000
MAX_TASK_LEN... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/agent/cloud_events.py",
"license": "MIT License",
"lines": 251,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/events.py | """Event definitions for browser communication."""
import inspect
import os
from typing import Any, Literal
from bubus import BaseEvent
from bubus.models import T_EventResultType
from cdp_use.cdp.target import TargetID
from pydantic import BaseModel, Field, field_validator
from browser_use.browser.views import Brows... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/events.py",
"license": "MIT License",
"lines": 432,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/python_highlights.py | """Python-based highlighting system for drawing bounding boxes on screenshots.
This module replaces JavaScript-based highlighting with fast Python image processing
to draw bounding boxes around interactive elements directly on screenshots.
"""
import asyncio
import base64
import io
import logging
import os
from PIL ... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/python_highlights.py",
"license": "MIT License",
"lines": 449,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/session.py | """Event-driven browser session with backwards compatibility."""
import asyncio
import logging
import time
from functools import cached_property
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal, Self, Union, cast, overload
from urllib.parse import urlparse, urlunparse
from uuid import UUID
impo... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/session.py",
"license": "MIT License",
"lines": 3262,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/video_recorder.py | """Video Recording Service for Browser Use Sessions."""
import base64
import io
import logging
import math
from pathlib import Path
from typing import Optional
from browser_use.browser.profile import ViewportSize
try:
import imageio.v2 as iio # type: ignore[import-not-found]
import numpy as np # type: ignore[imp... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/video_recorder.py",
"license": "MIT License",
"lines": 116,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/watchdog_base.py | """Base watchdog class for browser monitoring components."""
import asyncio
import inspect
import time
from collections.abc import Iterable
from typing import Any, ClassVar
from bubus import BaseEvent, EventBus
from pydantic import BaseModel, ConfigDict, Field
from browser_use.browser.session import BrowserSession
... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/watchdog_base.py",
"license": "MIT License",
"lines": 272,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
browser-use/browser-use:browser_use/browser/watchdogs/aboutblank_watchdog.py | """About:blank watchdog for managing about:blank tabs with DVD screensaver."""
from typing import TYPE_CHECKING, ClassVar
from bubus import BaseEvent
from cdp_use.cdp.target import TargetID
from pydantic import PrivateAttr
from browser_use.browser.events import (
AboutBlankDVDScreensaverShownEvent,
BrowserStopEven... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/watchdogs/aboutblank_watchdog.py",
"license": "MIT License",
"lines": 217,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
browser-use/browser-use:browser_use/browser/watchdogs/crash_watchdog.py | """Browser watchdog for monitoring crashes and network timeouts using CDP."""
import asyncio
import time
from typing import TYPE_CHECKING, ClassVar
import psutil
from bubus import BaseEvent
from cdp_use.cdp.target import SessionID, TargetID
from cdp_use.cdp.target.events import TargetCrashedEvent
from pydantic import... | {
"repo_id": "browser-use/browser-use",
"file_path": "browser_use/browser/watchdogs/crash_watchdog.py",
"license": "MIT License",
"lines": 281,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.