code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def test_simple_domain_specific_sensitive_data(registry, caplog):
"""Test the basic functionality of domain-specific sensitive data replacement"""
# Set log level to capture warnings
import logging
caplog.set_level(logging.WARNING)
# Create a simple Pydantic model with sensitive data placeholders
params = Sensi... | Test the basic functionality of domain-specific sensitive data replacement | test_simple_domain_specific_sensitive_data | python | browser-use/browser-use | tests/ci/test_agent_sensitive_data.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_agent_sensitive_data.py | MIT |
def test_match_url_with_domain_pattern():
"""Test that the domain pattern matching utility works correctly"""
# Test exact domain matches
assert match_url_with_domain_pattern('https://example.com', 'example.com') is True
assert match_url_with_domain_pattern('http://example.com', 'example.com') is False # Default ... | Test that the domain pattern matching utility works correctly | test_match_url_with_domain_pattern | python | browser-use/browser-use | tests/ci/test_agent_sensitive_data.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_agent_sensitive_data.py | MIT |
def test_unsafe_domain_patterns():
"""Test that unsafe domain patterns are rejected"""
# These are unsafe patterns that could match too many domains
assert match_url_with_domain_pattern('https://evil.com', '*google.com') is False
assert match_url_with_domain_pattern('https://google.com.evil.com', '*.*.com') is Fal... | Test that unsafe domain patterns are rejected | test_unsafe_domain_patterns | python | browser-use/browser-use | tests/ci/test_agent_sensitive_data.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_agent_sensitive_data.py | MIT |
def test_malformed_urls_and_patterns():
"""Test handling of malformed URLs or patterns"""
# Malformed URLs
assert match_url_with_domain_pattern('not-a-url', 'example.com') is False
assert match_url_with_domain_pattern('http://', 'example.com') is False
assert match_url_with_domain_pattern('https://', 'example.com... | Test handling of malformed URLs or patterns | test_malformed_urls_and_patterns | python | browser-use/browser-use | tests/ci/test_agent_sensitive_data.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_agent_sensitive_data.py | MIT |
def test_url_components():
"""Test handling of URL components like credentials, ports, fragments, etc."""
# URLs with credentials (username:password@)
assert match_url_with_domain_pattern('https://user:pass@example.com', 'example.com') is True
assert match_url_with_domain_pattern('https://user:pass@example.com', '... | Test handling of URL components like credentials, ports, fragments, etc. | test_url_components | python | browser-use/browser-use | tests/ci/test_agent_sensitive_data.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_agent_sensitive_data.py | MIT |
def test_filter_sensitive_data(message_manager):
"""Test that _filter_sensitive_data handles all sensitive data scenarios correctly"""
# Set up a message with sensitive information
message = HumanMessage(content='My username is admin and password is secret123')
# Case 1: No sensitive data provided
message_manager... | Test that _filter_sensitive_data handles all sensitive data scenarios correctly | test_filter_sensitive_data | python | browser-use/browser-use | tests/ci/test_agent_sensitive_data.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_agent_sensitive_data.py | MIT |
def test_authentication_bypass_prevention(self):
"""Test that the URL allowlist cannot be bypassed using authentication credentials."""
# Create a context config with a sample allowed domain
browser_profile = BrowserProfile(allowed_domains=['example.com'], headless=True, user_data_dir=None)
browser_session = Br... | Test that the URL allowlist cannot be bypassed using authentication credentials. | test_authentication_bypass_prevention | python | browser-use/browser-use | tests/ci/test_browser_session_allowed_domains.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_allowed_domains.py | MIT |
def test_glob_pattern_matching(self):
"""Test that glob patterns in allowed_domains work correctly."""
# Test *.example.com pattern (should match subdomains and main domain)
browser_profile = BrowserProfile(allowed_domains=['*.example.com'], headless=True, user_data_dir=None)
browser_session = BrowserSession(br... | Test that glob patterns in allowed_domains work correctly. | test_glob_pattern_matching | python | browser-use/browser-use | tests/ci/test_browser_session_allowed_domains.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_allowed_domains.py | MIT |
def test_glob_pattern_edge_cases(self):
"""Test edge cases for glob pattern matching to ensure proper behavior."""
# Test with domains containing glob pattern in the middle
browser_profile = BrowserProfile(allowed_domains=['*.google.com', 'https://wiki.org'], headless=True, user_data_dir=None)
browser_session =... | Test edge cases for glob pattern matching to ensure proper behavior. | test_glob_pattern_edge_cases | python | browser-use/browser-use | tests/ci/test_browser_session_allowed_domains.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_allowed_domains.py | MIT |
async def temp_cookies_file(self):
"""Create a temporary cookies file with test cookies."""
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
test_cookies = [
{
'name': 'test_cookie',
'value': 'test_value',
'domain': 'localhost',
'path': '/',
'expires': -... | Create a temporary cookies file with test cookies. | temp_cookies_file | python | browser-use/browser-use | tests/ci/test_browser_session_cookies.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_cookies.py | MIT |
async def browser_session_with_cookies(self, browser_profile_with_cookies):
"""Create a BrowserSession with cookie file configured."""
session = BrowserSession(browser_profile=browser_profile_with_cookies)
yield session
# Cleanup
try:
await session.stop()
except Exception:
pass | Create a BrowserSession with cookie file configured. | browser_session_with_cookies | python | browser-use/browser-use | tests/ci/test_browser_session_cookies.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_cookies.py | MIT |
def http_server(self, httpserver: HTTPServer):
"""Set up HTTP server with test endpoints."""
# Endpoint that shows cookies
httpserver.expect_request('/cookies').respond_with_data(
"""
<html>
<body>
<h1>Cookie Test Page</h1>
<script>
document.write('<p>Cookies: ' + document.cookie + '</p>');
... | Set up HTTP server with test endpoints. | http_server | python | browser-use/browser-use | tests/ci/test_browser_session_cookies.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_cookies.py | MIT |
async def test_cookies_loaded_on_start(self, browser_session_with_cookies, http_server):
"""Test that cookies are loaded from cookies_file when browser starts."""
# Start the browser session
await browser_session_with_cookies.start()
# Verify cookies were loaded
cookies = await browser_session_with_cookies.g... | Test that cookies are loaded from cookies_file when browser starts. | test_cookies_loaded_on_start | python | browser-use/browser-use | tests/ci/test_browser_session_cookies.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_cookies.py | MIT |
async def test_cookies_available_in_page(self, browser_session_with_cookies, http_server):
"""Test that loaded cookies are available to web pages."""
# Start the browser session
await browser_session_with_cookies.start()
# Navigate to test page
page = await browser_session_with_cookies.get_current_page()
a... | Test that loaded cookies are available to web pages. | test_cookies_available_in_page | python | browser-use/browser-use | tests/ci/test_browser_session_cookies.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_cookies.py | MIT |
async def test_nonexistent_cookies_file(self):
"""Test that browser starts normally when cookies_file doesn't exist."""
# Use a non-existent file path
profile = BrowserProfile(headless=True, user_data_dir=None, cookies_file='/tmp/nonexistent_cookies.json')
session = BrowserSession(browser_profile=profile)
# ... | Test that browser starts normally when cookies_file doesn't exist. | test_nonexistent_cookies_file | python | browser-use/browser-use | tests/ci/test_browser_session_cookies.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_cookies.py | MIT |
async def test_invalid_cookies_file(self, tmp_path):
"""Test that browser handles invalid cookie file gracefully."""
# Create a file with invalid JSON
invalid_file = tmp_path / 'invalid_cookies.json'
invalid_file.write_text('not valid json')
profile = BrowserProfile(headless=True, user_data_dir=None, cookies... | Test that browser handles invalid cookie file gracefully. | test_invalid_cookies_file | python | browser-use/browser-use | tests/ci/test_browser_session_cookies.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_cookies.py | MIT |
async def test_relative_cookies_file_path(self, browser_profile_with_cookies):
"""Test that relative cookies_file paths work correctly."""
# Create profile with relative path
profile = BrowserProfile(
headless=True,
user_data_dir=None,
cookies_file='./test_cookies.json', # Relative path
downloads_pat... | Test that relative cookies_file paths work correctly. | test_relative_cookies_file_path | python | browser-use/browser-use | tests/ci/test_browser_session_cookies.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_cookies.py | MIT |
async def test_server(httpserver):
"""Setup test HTTP server with a simple page."""
html_content = """
<!DOCTYPE html>
<html>
<head>
<title>Test Page</title>
</head>
<body>
<h1>Test Page</h1>
<button id="test-button" onclick="document.getElementById('result').innerText = 'Clicked!'">
Click Me
</button... | Setup test HTTP server with a simple page. | test_server | python | browser-use/browser-use | tests/ci/test_browser_session_downloads.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_downloads.py | MIT |
async def test_download_detection_timing(test_server, tmp_path):
"""Test that download detection adds 5 second delay to clicks when downloads_dir is set."""
# Test 1: With downloads_dir set (default behavior)
browser_with_downloads = BrowserSession(
headless=True,
downloads_dir=str(tmp_path / 'downloads'),
us... | Test that download detection adds 5 second delay to clicks when downloads_dir is set. | test_download_detection_timing | python | browser-use/browser-use | tests/ci/test_browser_session_downloads.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_downloads.py | MIT |
async def test_actual_download_detection(test_server, tmp_path):
"""Test that actual downloads are detected correctly."""
downloads_path = tmp_path / 'downloads'
downloads_path.mkdir()
browser_session = BrowserSession(
headless=True,
downloads_path=str(downloads_path),
user_data_dir=None,
)
await browser... | Test that actual downloads are detected correctly. | test_actual_download_detection | python | browser-use/browser-use | tests/ci/test_browser_session_downloads.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_downloads.py | MIT |
async def test_assumption_1_dom_processing_works(browser_session, httpserver):
"""Test assumption 1: DOM processing works and finds elements."""
# Go to a simple page
page = await browser_session.get_current_page()
await page.goto(httpserver.url_for('/'))
await page.wait_for_load_state()
# Trigger DOM processing... | Test assumption 1: DOM processing works and finds elements. | test_assumption_1_dom_processing_works | python | browser-use/browser-use | tests/ci/test_browser_session_element_cache.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_element_cache.py | MIT |
async def test_assumption_2_cached_selector_map_persists(browser_session, httpserver):
"""Test assumption 2: Cached selector map persists after get_state_summary."""
# Go to a simple page
page = await browser_session.get_current_page()
await page.goto(httpserver.url_for('/'))
await page.wait_for_load_state()
# T... | Test assumption 2: Cached selector map persists after get_state_summary. | test_assumption_2_cached_selector_map_persists | python | browser-use/browser-use | tests/ci/test_browser_session_element_cache.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_element_cache.py | MIT |
async def test_assumption_3_action_gets_same_selector_map(browser_session, controller, httpserver):
"""Test assumption 3: Action gets the same selector map as cached."""
# Go to a simple page
page = await browser_session.get_current_page()
await page.goto(httpserver.url_for('/'))
await page.wait_for_load_state()
... | Test assumption 3: Action gets the same selector map as cached. | test_assumption_3_action_gets_same_selector_map | python | browser-use/browser-use | tests/ci/test_browser_session_element_cache.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_element_cache.py | MIT |
async def test_assumption_4_click_action_specific_issue(browser_session, controller, httpserver):
"""Test assumption 4: Specific issue with click_element_by_index action."""
# Go to a simple page
page = await browser_session.get_current_page()
await page.goto(httpserver.url_for('/'))
await page.wait_for_load_state... | Test assumption 4: Specific issue with click_element_by_index action. | test_assumption_4_click_action_specific_issue | python | browser-use/browser-use | tests/ci/test_browser_session_element_cache.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_element_cache.py | MIT |
async def test_assumption_5_multiple_get_selector_map_calls(browser_session, httpserver):
"""Test assumption 5: Multiple calls to get_selector_map return consistent results."""
# Go to a simple page
page = await browser_session.get_current_page()
await page.goto(httpserver.url_for('/'))
await page.wait_for_load_st... | Test assumption 5: Multiple calls to get_selector_map return consistent results. | test_assumption_5_multiple_get_selector_map_calls | python | browser-use/browser-use | tests/ci/test_browser_session_element_cache.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_element_cache.py | MIT |
async def test_assumption_6_page_changes_affect_selector_map(browser_session, httpserver):
"""Test assumption 6: Check if page navigation affects cached selector map."""
# Go to first page
page = await browser_session.get_current_page()
await page.goto(httpserver.url_for('/'))
await page.wait_for_load_state()
# ... | Test assumption 6: Check if page navigation affects cached selector map. | test_assumption_6_page_changes_affect_selector_map | python | browser-use/browser-use | tests/ci/test_browser_session_element_cache.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_element_cache.py | MIT |
async def test_assumption_7_cache_gets_cleared(browser_session, controller, httpserver):
"""Test assumption 7: Check if _cached_browser_state_summary gets cleared."""
# Go to a simple page
page = await browser_session.get_current_page()
await page.goto(httpserver.url_for('/'))
await page.wait_for_load_state()
pr... | Test assumption 7: Check if _cached_browser_state_summary gets cleared. | test_assumption_7_cache_gets_cleared | python | browser-use/browser-use | tests/ci/test_browser_session_element_cache.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_element_cache.py | MIT |
async def test_final_real_click_with_debug(browser_session, controller, httpserver):
"""Final test: Try actual click with maximum debugging."""
# Go to a simple page
page = await browser_session.get_current_page()
await page.goto(httpserver.url_for('/'))
await page.wait_for_load_state()
print('=== FINAL CLICK TE... | Final test: Try actual click with maximum debugging. | test_final_real_click_with_debug | python | browser-use/browser-use | tests/ci/test_browser_session_element_cache.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_element_cache.py | MIT |
async def browser_profile(self):
"""Create and provide a BrowserProfile with headless mode."""
profile = BrowserProfile(headless=True, user_data_dir=None, keep_alive=False)
yield profile | Create and provide a BrowserProfile with headless mode. | browser_profile | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def browser_session(self, browser_profile):
"""Create a BrowserSession instance without starting it."""
session = BrowserSession(browser_profile=browser_profile)
yield session
await session.kill() | Create a BrowserSession instance without starting it. | browser_session | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_start_already_started_session(self, browser_session):
"""Test calling .start() on a session that's already started."""
# logger.info('Testing start on already started session')
# Start the session for the first time
result1 = await browser_session.start()
assert browser_session.initialized is ... | Test calling .start() on a session that's already started. | test_start_already_started_session | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_concurrent_start_calls(self, browser_session):
"""Test simultaneously calling .start() from two parallel coroutines."""
# logger.info('Testing concurrent start calls')
# Track how many times the lock is actually acquired for initialization
original_start_lock = browser_session._start_lock
lock... | Test simultaneously calling .start() from two parallel coroutines. | test_concurrent_start_calls | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_start_with_closed_browser_connection(self, browser_session):
"""Test calling .start() on a session that's started but has a closed browser connection."""
# logger.info('Testing start with closed browser connection')
# Start the session normally
await browser_session.start()
assert browser_sess... | Test calling .start() on a session that's started but has a closed browser connection. | test_start_with_closed_browser_connection | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_start_with_missing_browser_context(self, browser_session):
"""Test calling .start() when browser_context is None but initialized is True."""
# logger.info('Testing start with missing browser context')
# Manually set initialized to True but leave browser_context as None
browser_session.initialize... | Test calling .start() when browser_context is None but initialized is True. | test_start_with_missing_browser_context | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_start_initialization_failure(self, browser_session):
"""Test that initialization failure properly resets the initialized flag."""
# logger.info('Testing start initialization failure')
# Mock setup_playwright to raise an exception
original_setup_playwright = browser_session.setup_playwright
as... | Test that initialization failure properly resets the initialized flag. | test_start_initialization_failure | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_close_unstarted_session(self, browser_session):
"""Test calling .close() on a session that hasn't been started yet."""
# logger.info('Testing close on unstarted session')
# Ensure session is not started
assert browser_session.initialized is False
assert browser_session.browser_context is None
... | Test calling .close() on a session that hasn't been started yet. | test_close_unstarted_session | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_close_alias_method(self, browser_session):
"""Test the deprecated .close() alias method."""
# logger.info('Testing deprecated close alias method')
# Start the session
await browser_session.start()
assert browser_session.initialized is True
# Use the deprecated close method
await browser_s... | Test the deprecated .close() alias method. | test_close_alias_method | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_context_manager_usage(self, browser_session):
"""Test using BrowserSession as an async context manager."""
# logger.info('Testing context manager usage')
# Use as context manager
async with browser_session as session:
assert session is browser_session
assert session.initialized is True
... | Test using BrowserSession as an async context manager. | test_context_manager_usage | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_multiple_concurrent_operations_after_start(self, browser_session):
"""Test that multiple operations can run concurrently after start() completes."""
# logger.info('Testing multiple concurrent operations after start')
# Start the session
await browser_session.start()
# Run multiple operations ... | Test that multiple operations can run concurrently after start() completes. | test_multiple_concurrent_operations_after_start | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_require_initialization_decorator_already_started(self, browser_session):
"""Test @require_initialization decorator when session is already started."""
# logger.info('Testing @require_initialization decorator with already started session')
# Start the session first
await browser_session.start()
... | Test @require_initialization decorator when session is already started. | test_require_initialization_decorator_already_started | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_require_initialization_decorator_not_started(self, browser_session):
"""Test @require_initialization decorator when session is not started."""
# logger.info('Testing @require_initialization decorator with unstarted session')
# Ensure session is not started
assert browser_session.initialized is F... | Test @require_initialization decorator when session is not started. | test_require_initialization_decorator_not_started | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_require_initialization_decorator_with_closed_page(self, browser_session):
"""Test @require_initialization decorator handles closed pages correctly."""
# logger.info('Testing @require_initialization decorator with closed page')
# Start the session and get a page
await browser_session.start()
cu... | Test @require_initialization decorator handles closed pages correctly. | test_require_initialization_decorator_with_closed_page | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_concurrent_stop_calls(self, browser_profile):
"""Test simultaneous calls to stop() from multiple coroutines."""
# logger.info('Testing concurrent stop calls')
# Create a single session for this test
browser_session = BrowserSession(browser_profile=browser_profile)
await browser_session.start()... | Test simultaneous calls to stop() from multiple coroutines. | test_concurrent_stop_calls | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_stop_with_closed_browser_context(self, browser_session):
"""Test calling stop() when browser context is already closed."""
# logger.info('Testing stop with closed browser context')
# Start the session
await browser_session.start()
assert browser_session.initialized is True
browser_ctx = brow... | Test calling stop() when browser context is already closed. | test_stop_with_closed_browser_context | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_access_after_stop(self, browser_profile):
"""Test accessing browser context after stop() to ensure proper cleanup."""
# logger.info('Testing access after stop')
# Create a session without fixture to avoid double cleanup
browser_session = BrowserSession(browser_profile=browser_profile)
# Start... | Test accessing browser context after stop() to ensure proper cleanup. | test_access_after_stop | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_race_condition_between_stop_and_operation(self, browser_session):
"""Test race condition between stop() and other operations."""
# logger.info('Testing race condition between stop and operations')
await browser_session.start()
# Create a barrier to synchronize the operations
barrier = asyncio... | Test race condition between stop() and other operations. | test_race_condition_between_stop_and_operation | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_multiple_start_stop_cycles(self, browser_session):
"""Test multiple start/stop cycles to ensure no resource leaks."""
# logger.info('Testing multiple start/stop cycles')
# Perform multiple start/stop cycles
for i in range(3):
# Start
await browser_session.start()
assert browser_session.... | Test multiple start/stop cycles to ensure no resource leaks. | test_multiple_start_stop_cycles | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_context_manager_with_exception(self, browser_session):
"""Test context manager properly closes even when exception occurs."""
# logger.info('Testing context manager with exception')
class TestException(Exception):
pass
# Use context manager and raise exception inside
with pytest.raises(Tes... | Test context manager properly closes even when exception occurs. | test_context_manager_with_exception | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_session_without_fixture(self):
"""Test creating a session without using fixture."""
# Create a new profile and session for this test
profile = BrowserProfile(headless=True, user_data_dir=None, keep_alive=False)
session = BrowserSession(browser_profile=profile)
try:
await session.start()
... | Test creating a session without using fixture. | test_session_without_fixture | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_start_with_keep_alive_profile(self):
"""Test start/stop behavior with keep_alive=True profile."""
# Create a completely fresh profile and session to avoid module-scoped fixture issues
profile = BrowserProfile(headless=True, user_data_dir=None, keep_alive=False)
session = BrowserSession(browser_pr... | Test start/stop behavior with keep_alive=True profile. | test_start_with_keep_alive_profile | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_user_data_dir_not_allowed_to_corrupt_default_profile(self, caplog):
"""Test user_data_dir handling for different browser channels and version mismatches."""
# Test 1: Chromium with default user_data_dir and default channel should work fine
session = BrowserSession(
headless=True,
user_data_d... | Test user_data_dir handling for different browser channels and version mismatches. | test_user_data_dir_not_allowed_to_corrupt_default_profile | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_sequential_agents_same_profile_different_browser(self, mock_llm):
"""Test Sequential Agents, Same Profile, Different Browser pattern"""
from browser_use import Agent
from browser_use.browser.profile import BrowserProfile
# Create a reusable profile
reused_profile = BrowserProfile(
user_data... | Test Sequential Agents, Same Profile, Different Browser pattern | test_sequential_agents_same_profile_different_browser | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_sequential_agents_same_profile_same_browser(self, mock_llm):
"""Test Sequential Agents, Same Profile, Same Browser pattern"""
from browser_use import Agent, BrowserSession
# Create a reusable session with keep_alive
reused_session = BrowserSession(
user_data_dir=None, # Use temp dir for test... | Test Sequential Agents, Same Profile, Same Browser pattern | test_sequential_agents_same_profile_same_browser | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_parallel_agents_same_browser_multiple_tabs(self, httpserver):
"""Test Parallel Agents, Same Browser, Multiple Tabs pattern"""
import tempfile
from browser_use import Agent, BrowserSession
# Create a shared browser session
with tempfile.NamedTemporaryFile(suffix='.json', delete=False, mode='w'... | Test Parallel Agents, Same Browser, Multiple Tabs pattern | test_parallel_agents_same_browser_multiple_tabs | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_parallel_agents_same_browser_same_tab(self, mock_llm, httpserver):
"""Test Parallel Agents, Same Browser, Same Tab pattern (not recommended)"""
from browser_use import Agent, BrowserSession
# Create a browser session and start it first
shared_browser = BrowserSession(
user_data_dir=None,
h... | Test Parallel Agents, Same Browser, Same Tab pattern (not recommended) | test_parallel_agents_same_browser_same_tab | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def test_parallel_agents_same_profile_different_browsers(self, mock_llm):
"""Test Parallel Agents, Same Profile, Different Browsers pattern (recommended)"""
import tempfile
from browser_use import Agent
from browser_use.browser import BrowserProfile, BrowserSession
# Create a shared profile with stora... | Test Parallel Agents, Same Profile, Different Browsers pattern (recommended) | test_parallel_agents_same_profile_different_browsers | python | browser-use/browser-use | tests/ci/test_browser_session_start.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_start.py | MIT |
async def browser_session(base_url):
"""Create and provide a BrowserSession instance with a properly initialized tab."""
browser_session = BrowserSession(
user_data_dir=None,
headless=True,
keep_alive=True,
)
await browser_session.start()
# Create an initial tab and wait for it to load completely
await bro... | Create and provide a BrowserSession instance with a properly initialized tab. | browser_session | python | browser-use/browser-use | tests/ci/test_browser_session_tab_management.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_tab_management.py | MIT |
async def _execute_action(self, controller, browser_session: BrowserSession, action_data):
"""Generic helper to execute any action via the controller."""
# Dynamically create an appropriate ActionModel class
action_type = list(action_data.keys())[0]
action_value = action_data[action_type]
# Create the Action... | Generic helper to execute any action via the controller. | _execute_action | python | browser-use/browser-use | tests/ci/test_browser_session_tab_management.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_tab_management.py | MIT |
async def _simulate_human_tab_change(self, page, browser_session: BrowserSession):
"""Simulate a user changing tabs by properly triggering events with Playwright."""
# logger.debug(
# f'BEFORE: agent_tab={browser_session.agent_current_page.url if browser_session.agent_current_page else "None"}, '
# f'human_cur... | Simulate a user changing tabs by properly triggering events with Playwright. | _simulate_human_tab_change | python | browser-use/browser-use | tests/ci/test_browser_session_tab_management.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_tab_management.py | MIT |
async def test_initial_values(self, browser_session, base_url):
"""Test that open_tab correctly updates both tab references."""
await self._reset_tab_state(browser_session, base_url)
initial_tab = await browser_session.get_current_page()
assert initial_tab.url == 'about:blank'
assert browser_session.human_c... | Test that open_tab correctly updates both tab references. | test_initial_values | python | browser-use/browser-use | tests/ci/test_browser_session_tab_management.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_tab_management.py | MIT |
async def test_agent_changes_tab(self, browser_session, base_url):
"""Test that agent_current_page changes and human_current_page remains the same when a new tab is opened."""
initial_tab = await self._reset_tab_state(browser_session, base_url)
await initial_tab.goto(f'{base_url}/page1')
await self._simulate_h... | Test that agent_current_page changes and human_current_page remains the same when a new tab is opened. | test_agent_changes_tab | python | browser-use/browser-use | tests/ci/test_browser_session_tab_management.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_tab_management.py | MIT |
async def test_human_changes_tab(self, browser_session, base_url):
"""Test that human_current_page changes and agent_current_page remains the same when a new tab is opened."""
initial_tab = await self._reset_tab_state(browser_session, base_url)
assert initial_tab.url == 'about:blank'
# assert human opening ne... | Test that human_current_page changes and agent_current_page remains the same when a new tab is opened. | test_human_changes_tab | python | browser-use/browser-use | tests/ci/test_browser_session_tab_management.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_tab_management.py | MIT |
async def test_switch_tab(self, browser_session, base_url):
"""Test that switch_tab updates both tab references."""
# open a new tab for the human + agent to start on
first_tab = await self._reset_tab_state(browser_session, base_url)
await browser_session.navigate(f'{base_url}/page1')
await self._simulate_hu... | Test that switch_tab updates both tab references. | test_switch_tab | python | browser-use/browser-use | tests/ci/test_browser_session_tab_management.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_tab_management.py | MIT |
async def test_close_tab(self, browser_session, base_url):
"""Test that closing a tab updates references correctly."""
initial_tab = await self._reset_tab_state(browser_session, base_url)
await browser_session.navigate(f'{base_url}/page1')
assert initial_tab.url == f'{base_url}/page1'
# Create two tabs with... | Test that closing a tab updates references correctly. | test_close_tab | python | browser-use/browser-use | tests/ci/test_browser_session_tab_management.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_tab_management.py | MIT |
async def test_browser_context_state_after_error(self, browser_session):
"""Test browser context state remains consistent after errors"""
# logger.info('Testing browser context state after error')
await browser_session.start()
# Force an error by closing context and trying to use it
# Set browser_context to... | Test browser context state remains consistent after errors | test_browser_context_state_after_error | python | browser-use/browser-use | tests/ci/test_browser_session_tab_management.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_tab_management.py | MIT |
async def test_concurrent_context_access_during_closure(self, browser_session):
"""Test concurrent access to browser context during closure"""
# logger.info('Testing concurrent context access during closure')
await browser_session.start()
assert browser_session.is_connected() is True
# Create a barrier to s... | Test concurrent access to browser context during closure | test_concurrent_context_access_during_closure | python | browser-use/browser-use | tests/ci/test_browser_session_tab_management.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_tab_management.py | MIT |
async def test_proxy_settings_pydantic_model():
"""
Test that ProxySettings as a Pydantic model is correctly converted to a dictionary when used.
"""
# Create ProxySettings with Pydantic model
proxy_settings = dict(server='http://example.proxy:8080', bypass='localhost', username='testuser', password='testpass')
... |
Test that ProxySettings as a Pydantic model is correctly converted to a dictionary when used.
| test_proxy_settings_pydantic_model | python | browser-use/browser-use | tests/ci/test_browser_session_viewport_and_proxy.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_viewport_and_proxy.py | MIT |
async def test_window_size_with_real_browser():
"""
Integration test that verifies our window size Pydantic model is correctly
passed to Playwright and the actual browser window is configured with these settings.
This test is skipped in CI environments.
"""
# Create browser profile with headless mode and specific... |
Integration test that verifies our window size Pydantic model is correctly
passed to Playwright and the actual browser window is configured with these settings.
This test is skipped in CI environments.
| test_window_size_with_real_browser | python | browser-use/browser-use | tests/ci/test_browser_session_viewport_and_proxy.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_browser_session_viewport_and_proxy.py | MIT |
async def browser_session():
"""Create and provide a Browser instance with security disabled."""
browser_session = BrowserSession(
# browser_profile=BrowserProfile(),
headless=True,
user_data_dir=None,
)
await browser_session.start()
yield browser_session
await browser_session.stop() | Create and provide a Browser instance with security disabled. | browser_session | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_go_to_url_action(self, controller, browser_session, base_url):
"""Test that GoToUrlAction navigates to the specified URL."""
# Create action model for go_to_url
action_data = {'go_to_url': GoToUrlAction(url=f'{base_url}/page1')}
# Create the ActionModel instance
class GoToUrlActionModel(Action... | Test that GoToUrlAction navigates to the specified URL. | test_go_to_url_action | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_scroll_actions(self, controller, browser_session, base_url):
"""Test that scroll actions correctly scroll the page."""
# First navigate to a page
goto_action = {'go_to_url': GoToUrlAction(url=f'{base_url}/page1')}
class GoToUrlActionModel(ActionModel):
go_to_url: GoToUrlAction | None = None
... | Test that scroll actions correctly scroll the page. | test_scroll_actions | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_registry_actions(self, controller, browser_session):
"""Test that the registry contains the expected default actions."""
# Check that common actions are registered
common_actions = [
'go_to_url',
'search_google',
'click_element_by_index',
'input_text',
'scroll_down',
'scroll_up',
... | Test that the registry contains the expected default actions. | test_registry_actions | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_custom_action_registration(self, controller, browser_session, base_url):
"""Test registering a custom action and executing it."""
# Define a custom action
class CustomParams(BaseModel):
text: str
@controller.action('Test custom action', param_model=CustomParams)
async def custom_action(par... | Test registering a custom action and executing it. | test_custom_action_registration | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_input_text_action(self, controller, browser_session, base_url, http_server):
"""Test that InputTextAction correctly inputs text into form fields."""
# Set up search form endpoint for this test
http_server.expect_request('/searchform').respond_with_data(
"""
<html>
<head><title>Search Form<... | Test that InputTextAction correctly inputs text into form fields. | test_input_text_action | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_error_handling(self, controller, browser_session):
"""Test error handling when an action fails."""
# Create an action with an invalid index
invalid_action = {'click_element_by_index': ClickElementAction(index=999)} # doesn't exist on page
class ClickActionModel(ActionModel):
click_element_by... | Test error handling when an action fails. | test_error_handling | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_wait_action(self, controller, browser_session):
"""Test that the wait action correctly waits for the specified duration."""
# verify that it's in the default action set
wait_action = None
for action_name, action in controller.registry.registry.actions.items():
if 'wait' in action_name.lower()... | Test that the wait action correctly waits for the specified duration. | test_wait_action | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_go_back_action(self, controller, browser_session, base_url):
"""Test that go_back action navigates to the previous page."""
# Navigate to first page
goto_action1 = {'go_to_url': GoToUrlAction(url=f'{base_url}/page1')}
class GoToUrlActionModel(ActionModel):
go_to_url: GoToUrlAction | None = No... | Test that go_back action navigates to the previous page. | test_go_back_action | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_navigation_chain(self, controller, browser_session, base_url):
"""Test navigating through multiple pages and back through history."""
# Set up a chain of navigation: Home -> Page1 -> Page2
urls = [f'{base_url}/', f'{base_url}/page1', f'{base_url}/page2']
# Navigate to each page in sequence
for... | Test navigating through multiple pages and back through history. | test_navigation_chain | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_excluded_actions(self, browser_session):
"""Test that excluded actions are not registered."""
# Create controller with excluded actions
excluded_controller = Controller(exclude_actions=['search_google', 'open_tab'])
# Verify excluded actions are not in the registry
assert 'search_google' not i... | Test that excluded actions are not registered. | test_excluded_actions | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_done_action(self, controller, browser_session, base_url):
"""Test that DoneAction completes a task and reports success or failure."""
# First navigate to a page
goto_action = {'go_to_url': GoToUrlAction(url=f'{base_url}/page1')}
class GoToUrlActionModel(ActionModel):
go_to_url: GoToUrlAction ... | Test that DoneAction completes a task and reports success or failure. | test_done_action | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_send_keys_action(self, controller, browser_session, base_url, http_server):
"""Test SendKeysAction using a controlled local HTML file."""
# Set up keyboard test page for this test
http_server.expect_request('/keyboard').respond_with_data(
"""
<!DOCTYPE html>
<html>
<head>
<title>Key... | Test SendKeysAction using a controlled local HTML file. | test_send_keys_action | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_get_dropdown_options(self, controller, browser_session, base_url, http_server):
"""Test that get_dropdown_options correctly retrieves options from a dropdown."""
# Add route for dropdown test page
http_server.expect_request('/dropdown1').respond_with_data(
"""
<!DOCTYPE html>
<html>
<he... | Test that get_dropdown_options correctly retrieves options from a dropdown. | test_get_dropdown_options | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_select_dropdown_option(self, controller, browser_session, base_url, http_server):
"""Test that select_dropdown_option correctly selects an option from a dropdown."""
# Add route for dropdown test page
http_server.expect_request('/dropdown2').respond_with_data(
"""
<!DOCTYPE html>
<html>
... | Test that select_dropdown_option correctly selects an option from a dropdown. | test_select_dropdown_option | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_extract_content_action(self, controller, browser_session, base_url, http_server):
"""Test the default extract_content action with mixed parameter ordering."""
# Set up a test page with specific content
http_server.expect_request('/extract-test').respond_with_data(
"""
<!DOCTYPE html>
<html... | Test the default extract_content action with mixed parameter ordering. | test_extract_content_action | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
async def test_click_element_by_index(self, controller, browser_session, base_url, http_server):
"""Test that click_element_by_index correctly clicks an element and handles different outcomes."""
# Add route for clickable elements test page
http_server.expect_request('/clickable').respond_with_data(
"""
<!D... | Test that click_element_by_index correctly clicks an element and handles different outcomes. | test_click_element_by_index | python | browser-use/browser-use | tests/ci/test_controller.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller.py | MIT |
def test_is_url_allowed(self):
"""
Test the _is_url_allowed method to verify that it correctly checks URLs against
the allowed domains configuration.
"""
# Scenario 1: allowed_domains is None, any URL should be allowed.
config1 = BrowserProfile(allowed_domains=None, headless=True, user_data_dir=None)
cont... |
Test the _is_url_allowed method to verify that it correctly checks URLs against
the allowed domains configuration.
| test_is_url_allowed | python | browser-use/browser-use | tests/ci/test_controller_action_parameter_injection.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller_action_parameter_injection.py | MIT |
def test_convert_simple_xpath_to_css_selector(self):
"""
Test the _convert_simple_xpath_to_css_selector method of BrowserSession.
This verifies that simple XPath expressions are correctly converted to CSS selectors.
"""
# Test empty xpath returns empty string
assert BrowserSession._convert_simple_xpath_to_c... |
Test the _convert_simple_xpath_to_css_selector method of BrowserSession.
This verifies that simple XPath expressions are correctly converted to CSS selectors.
| test_convert_simple_xpath_to_css_selector | python | browser-use/browser-use | tests/ci/test_controller_action_parameter_injection.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller_action_parameter_injection.py | MIT |
def test_enhanced_css_selector_for_element(self):
"""
Test the _enhanced_css_selector_for_element method to verify that
it returns the correct CSS selector string for a DOMElementNode.
"""
# Create a DOMElementNode instance with a complex set of attributes
dummy_element = DOMElementNode(
tag_name='div',
... |
Test the _enhanced_css_selector_for_element method to verify that
it returns the correct CSS selector string for a DOMElementNode.
| test_enhanced_css_selector_for_element | python | browser-use/browser-use | tests/ci/test_controller_action_parameter_injection.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller_action_parameter_injection.py | MIT |
async def test_navigate_and_get_current_page(self, browser_session, base_url):
"""Test that navigate method changes the URL and get_current_page returns the proper page."""
# Navigate to the test page
await browser_session.navigate(f'{base_url}/')
# Get the current page
page = await browser_session.get_curre... | Test that navigate method changes the URL and get_current_page returns the proper page. | test_navigate_and_get_current_page | python | browser-use/browser-use | tests/ci/test_controller_action_parameter_injection.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller_action_parameter_injection.py | MIT |
async def test_refresh_page(self, browser_session, base_url):
"""Test that refresh_page correctly reloads the current page."""
# Navigate to the test page
await browser_session.navigate(f'{base_url}/')
# Get the current page before refresh
page_before = await browser_session.get_current_page()
# Refresh t... | Test that refresh_page correctly reloads the current page. | test_refresh_page | python | browser-use/browser-use | tests/ci/test_controller_action_parameter_injection.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller_action_parameter_injection.py | MIT |
async def test_execute_javascript(self, browser_session, base_url):
"""Test that execute_javascript correctly executes JavaScript in the current page."""
# Navigate to a test page
await browser_session.navigate(f'{base_url}/')
# Execute a simple JavaScript snippet that returns a value
result = await browser_... | Test that execute_javascript correctly executes JavaScript in the current page. | test_execute_javascript | python | browser-use/browser-use | tests/ci/test_controller_action_parameter_injection.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller_action_parameter_injection.py | MIT |
async def test_get_scroll_info(self, browser_session, base_url):
"""Test that get_scroll_info returns the correct scroll position information."""
# Navigate to the scroll test page
await browser_session.navigate(f'{base_url}/scroll_test')
page = await browser_session.get_current_page()
# Get initial scroll i... | Test that get_scroll_info returns the correct scroll position information. | test_get_scroll_info | python | browser-use/browser-use | tests/ci/test_controller_action_parameter_injection.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller_action_parameter_injection.py | MIT |
async def test_take_screenshot(self, browser_session, base_url):
"""Test that take_screenshot returns a valid base64 encoded image."""
# Navigate to the test page
await browser_session.navigate(f'{base_url}/')
# Take a screenshot
screenshot_base64 = await browser_session.take_screenshot()
# Verify the scr... | Test that take_screenshot returns a valid base64 encoded image. | test_take_screenshot | python | browser-use/browser-use | tests/ci/test_controller_action_parameter_injection.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller_action_parameter_injection.py | MIT |
async def test_switch_tab_operations(self, browser_session, base_url):
"""Test tab creation, switching, and closing operations."""
# Navigate to home page in first tab
await browser_session.navigate(f'{base_url}/')
# Create a new tab
await browser_session.create_new_tab(f'{base_url}/scroll_test')
# Verify... | Test tab creation, switching, and closing operations. | test_switch_tab_operations | python | browser-use/browser-use | tests/ci/test_controller_action_parameter_injection.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller_action_parameter_injection.py | MIT |
async def test_remove_highlights(self, browser_session, base_url):
"""Test that remove_highlights successfully removes highlight elements."""
# Navigate to a test page
await browser_session.navigate(f'{base_url}/')
# Add a highlight via JavaScript
await browser_session.execute_javascript("""
cons... | Test that remove_highlights successfully removes highlight elements. | test_remove_highlights | python | browser-use/browser-use | tests/ci/test_controller_action_parameter_injection.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_controller_action_parameter_injection.py | MIT |
async def test_individual_parameters_no_browser(self, registry):
"""Test action with individual parameters, no special injection"""
@registry.action('Simple action with individual params')
async def simple_action(text: str, number: int = 10):
return ActionResult(extracted_content=f'Text: {text}, Number: {numb... | Test action with individual parameters, no special injection | test_individual_parameters_no_browser | python | browser-use/browser-use | tests/ci/test_registry.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_registry.py | MIT |
async def test_individual_parameters_with_browser(self, registry, browser_session, base_url):
"""Test action with individual parameters plus browser_session injection"""
@registry.action('Action with individual params and browser')
async def action_with_browser(text: str, browser_session: BrowserSession):
pag... | Test action with individual parameters plus browser_session injection | test_individual_parameters_with_browser | python | browser-use/browser-use | tests/ci/test_registry.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_registry.py | MIT |
async def test_page_parameter_injection(self, registry, browser_session, base_url):
"""Test action with direct Page parameter injection"""
@registry.action('Action with page parameter')
async def action_with_page(text: str, page: Page):
title = await page.title()
return ActionResult(extracted_content=f'Tex... | Test action with direct Page parameter injection | test_page_parameter_injection | python | browser-use/browser-use | tests/ci/test_registry.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_registry.py | MIT |
async def test_pydantic_model_with_page_parameter(self, registry, browser_session, base_url):
"""Test pydantic model action with page parameter injection"""
@registry.action('Pydantic action with page', param_model=ComplexParams)
async def pydantic_action_with_page(params: ComplexParams, page: Page):
title = ... | Test pydantic model action with page parameter injection | test_pydantic_model_with_page_parameter | python | browser-use/browser-use | tests/ci/test_registry.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_registry.py | MIT |
async def test_pydantic_model_parameters(self, registry, browser_session, base_url):
"""Test action that takes a pydantic model as first parameter"""
@registry.action('Action with pydantic model', param_model=ComplexParams)
async def pydantic_action(params: ComplexParams, browser_session: BrowserSession):
pag... | Test action that takes a pydantic model as first parameter | test_pydantic_model_parameters | python | browser-use/browser-use | tests/ci/test_registry.py | https://github.com/browser-use/browser-use/blob/master/tests/ci/test_registry.py | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.