Browser Testing MCP Server - Cursor AI Instructions
Setup Instructions
Install Python dependencies:
Save the Python file as
browser_testing_mcp.pyMake it executable:
Configure MCP in Cursor: Add to your MCP configuration file:
Instructions for Cursor AI
You have access to a Browser Testing MCP server that allows you to control a real browser to test web applications. This is particularly useful for verifying that web apps you create are functioning correctly.
Available Tools
You can use these tools to interact with a browser:
Browser Management
launch_browser- Start a browser instance (set headless=false to see it)close_browser- Close the browser when donenavigate_to- Go to any URL
Interaction
click_element- Click any element by CSS selectortype_text- Type into input fieldsfill_form- Fill multiple form fields at onceevaluate_javascript- Execute custom JavaScript
Monitoring & Debugging
get_console_logs- See JavaScript errors and console outputget_network_requests- Monitor API calls and responsesget_page_metrics- Check performance metricstake_screenshot- Capture visual state
Verification
wait_for_selector- Wait for elements to appearcheck_element_state- Verify element states (visible, enabled, etc.)get_local_storage- Check stored dataget_cookies- Verify authentication cookiesget_page_content- Get HTML content
Testing Workflow Example
When testing a web application you've created, follow this pattern:
Common Testing Scenarios
Test Form Validation
Test API Error Handling
Test Authentication Flow
Test Responsive Design
Debugging Tips
Always check console logs after interactions to catch JavaScript errors
Monitor network requests to ensure APIs are called correctly
Use screenshots to visually verify UI state
Check localStorage/cookies to verify data persistence
Use wait_for_selector before interacting with dynamically loaded content
Run with headless=False to see what's happening during debugging
Error Handling
If you encounter errors:
"Browser not launched" - Call
launch_browserfirst"Element not found" - Check selector is correct, use
wait_for_selectorfirst"Timeout" - Increase timeout value or check if element actually appears
Network issues - Check if the app is running on the expected port
Best Practices
Always close the browser when done testing
Use descriptive selectors (IDs or data-testid attributes)
Wait for elements before interacting with them
Check both success and error cases
Verify API calls match expected patterns
Take screenshots at key points for visual verification
Check performance metrics to ensure app loads efficiently
This tool allows you to thoroughly test any web application you create, ensuring all features work correctly before considering the task complete.