Playwright AI Insights - VS Code Extension
AI-powered test failure analysis and self-healing locator suggestions directly in your VS Code editor.
Features
✨ Smart Analysis
- 🤖 Instant AI analysis of test failures
- 💡 AI-suggested locator improvements
- 📊 Visual insights panel with statistics
- ⚡ One-click failure analysis from explorer
🔧 Easy Integration
- Works with any Playwright project
- No code changes needed
- Configure once, works everywhere
- Minimal setup (just API key)
📈 Actionable Insights
- Root cause analysis
- Specific fix suggestions
- Confidence scores
- Import history tracking
Installation
- Install from VS Code Marketplace:
Playwright AI Insights
- Set your OpenAI API key in settings or environment variable
- Run tests and analyze failures
Getting Started
Open VS Code Settings and search for playwright-ai:
Cmd + , (Mac) or Ctrl + , (Windows/Linux)
Search for playwright-ai.apiKey and enter your OpenAI API key.
Alternatively, set OPENAI_API_KEY environment variable.
Step 2: Analyze Test Failures
Run your Playwright tests:
npx playwright test
Open Command Palette (Cmd + Shift + P / Ctrl + Shift + P)
Search for Playwright AI: Analyze Test Failures
View results in the AI Insights panel
Step 3: Apply Suggestions
- Review suggested locators in the panel
- Click "Apply Suggestion" to use AI recommendations
- Improve your test selectors instantly
Commands
| Command |
Description |
Playwright AI: Analyze Test Failures |
Analyze failures from current workspace |
Playwright AI: Open AI Insights Panel |
Show the insights panel |
Playwright AI: Configure OpenAI API Key |
Set up your API key |
Settings
{
"playwright-ai.apiKey": "sk-...", // Your OpenAI API key
"playwright-ai.model": "gpt-4o-mini", // AI model (gpt-4o, gpt-4o-mini, gpt-4-turbo)
"playwright-ai.autoAnalyze": false, // Auto-analyze after test runs
"playwright-ai.debug": false // Enable debug logging
}
Usage Examples
Automatic Analysis After Test Run
Enable autoAnalyze in settings for automatic analysis when tests complete.
Analyze Specific Test Result Directory
Right-click on test result folder in explorer and select "Analyze Test Failures"
View Historical Analysis
All analysis reports are saved in your workspace for review.
Pricing
Uses OpenAI's gpt-4o-mini model by default:
- ~$0.015 per 1M input tokens
- ~$0.06 per 1M output tokens
Typical cost per test failure: $0.001 - $0.003
Troubleshooting
Extension not activating?
- Check that API key is configured
- Restart VS Code
- Check output channel for errors
No failures found?
- Ensure test results exist in
playwright-report or test-results directories
- Run tests first:
npx playwright test
Slow analysis?
- Check OpenAI API status at status.openai.com
- Verify network connectivity
- Try smaller batch sizes
Privacy & Security
- API key stored securely in VS Code
- Analysis done via OpenAI API
- No data stored long-term
- Only failure info + DOM sent to API (capped at 6000 chars)
Learn More
Support
License
MIT
Happy Testing! 🎭