browser-use-agentcore
Browser Use AgentCore Skill
Overview
This skill uses AWS Bedrock AgentCore Browser to perform automated web testing in the cloud. No local browser or display required - tests run on AWS infrastructure.
Features
- Test any URL with a real browser
- Capture full-page screenshots
- Check for JavaScript console errors
- Verify API health endpoints
- View live browser session in AWS Console
Prerequisites
- AWS credentials configured
- IAM permissions for AgentCore Browser
- Python 3.10+
Required IAM Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"bedrock-agentcore:StartBrowserSession",
"bedrock-agentcore:StopBrowserSession",
"bedrock-agentcore:GetBrowserSession"
],
"Resource": "*"
}
]
}
Quick Start
Install Dependencies
pip install bedrock-agentcore playwright boto3 nest-asyncio
Basic Usage
# Test a URL
python scripts/browser_test.py https://example.com
# Test with screenshot
python scripts/browser_test.py https://example.com --screenshot screenshot.png
# Test with API health check
python scripts/browser_test.py https://example.com --check-api
# Full test with JSON output
python scripts/browser_test.py https://example.com -s screenshot.png -a --json
Python API
Simple Test
from browser_test import test_url
# test_url is a synchronous function
results = test_url(
url="https://example.com",
screenshot_path="screenshot.png",
check_api=True
)
print(f"Status: {results['status']}")
print(f"Title: {results['title']}")
print(f"Errors: {results['errors']}")
Advanced Usage with Playwright
from bedrock_agentcore.tools.browser_client import BrowserClient
from playwright.async_api import async_playwright
async def custom_test():
client = BrowserClient(region="us-west-2")
session = await client.start_browser_session(
session_name="my-test",
timeout=300,
viewport={"width": 1920, "height": 1080}
)
ws_url, headers = await client.generate_ws_headers()
async with async_playwright() as p:
browser = await p.chromium.connect_over_cdp(ws_url, headers=headers)
page = browser.contexts[0].pages[0]
# Your custom test logic
await page.goto("https://example.com")
await page.click("button#submit")
await page.wait_for_selector(".result")
content = await page.content()
await browser.close()
await client.stop_browser_session()
return content
Command Line Options
| Option | Short | Description |
|---|---|---|
url |
- | URL to test (required) |
--screenshot |
-s |
Path to save screenshot |
--check-api |
-a |
Check /api/health endpoint |
--region |
-r |
AWS region (default: us-west-2) |
--json |
-j |
Output results as JSON |
Output Format
Console Output
🚀 Starting browser session in us-west-2...
✅ Browser session started: sess-abc123
🔗 Connecting to remote browser...
🌐 Navigating to https://example.com...
📄 Page title: Example Domain
📊 HTTP status: 200
📸 Screenshot saved: screenshot.png
==================================================
📋 Test Results
==================================================
URL: https://example.com
Status: 200
Title: Example Domain
Errors: 0
✅ All checks passed!
JSON Output
{
"url": "https://example.com",
"status": 200,
"title": "Example Domain",
"errors": [],
"api_check": {
"url": "https://example.com/api/health",
"status": 200,
"body": "{\"status\":\"healthy\"}"
},
"screenshot": "screenshot.png"
}
Live View
While tests are running, you can watch the browser in real-time:
- Open AWS Console - AgentCore Browser
- Navigate to Built-in tools
- Find your active session
- Click View live session
Troubleshooting
Session Timeout
If tests timeout, increase the session timeout:
session = await client.start_browser_session(
session_name="long-test",
timeout=600 # 10 minutes
)
Permission Denied
Ensure your IAM role/user has the required permissions for AgentCore Browser.
Network Errors
Check that the target URL is accessible from AWS infrastructure. Internal/private URLs may not be reachable.
Regional Availability
AgentCore Browser is available in:
- us-east-1 (N. Virginia)
- us-west-2 (Oregon)
Pricing
AgentCore Browser uses consumption-based pricing with no upfront costs. See AWS Pricing for details.
More from tsaol/awesome-claude
xlsx
Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas
16pptx
Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks
15docx
Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks
14pdf
Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.
14frontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
13excel
Excel 表格创建、编辑和数据分析。支持公式、格式化、数据分析和可视化。当需要处理表格文件时使用:(1) 创建带公式的表格,(2) 读取和分析数据,(3) 修改现有表格,(4) 数据分析和可视化
3