This guide explains how to use AutoSpectra MCP server for live debugging and test development with visible browsers.
The visible: true
parameter in all browser automation tools enables real-time observation and debugging:
// Use visible browser mode for debugging
use_mcp_tool({
server_name: "autospectra",
tool_name: "navigate",
arguments: {
url: "https://example.com",
visible: true
}
});
Use the MCP tools with visible mode to explore the application:
// Navigate with visible browser
use_mcp_tool({
server_name: "autospectra",
tool_name: "navigate",
arguments: {
url: "https://your-app.com",
visible: true
}
});
// Extract data to see what's available
use_mcp_tool({
server_name: "autospectra",
tool_name: "extract",
arguments: {
selector: ".some-element",
visible: true
}
});
// Generate a test based on exploration
use_mcp_tool({
server_name: "autospectra",
tool_name: "generate_tests",
arguments: {
url: "https://your-app.com",
framework: "playwright",
format: "javascript",
prompt: "Test the login functionality"
}
});
Edit the generated test file to add breakpoints, console logs, or test-specific logic.
// Add these to your test for debugging
page.on('console', msg => console.log(`PAGE LOG: ${msg.text()}`));
// Add a pause for debugging
// Use debugger statement to pause in dev tools
await page.evaluate(() => {
debugger;
});
Run your test with the --debug
flag to enable DevTools:
# Run with inspector
node --inspect-brk output/your-test.js
# For Playwright tests with inspector
npx playwright test --debug
Create a watch-test.js
script for live reloading:
const chokidar = require('chokidar');
const { exec } = require('child_process');
const path = require('path');
// File to watch
const testFile = process.argv[2] || 'output/simple-playwright-test.js';
console.log(`Watching ${testFile} for changes...`);
// Start watching
chokidar.watch(testFile).on('change', (filePath) => {
console.log(`File ${path.basename(filePath)} changed, running test...`);
// Run the test
const child = exec(`node ${filePath}`, (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error.message}`);
return;
}
if (stderr) {
console.error(`Stderr: ${stderr}`);
return;
}
console.log(`Test output: ${stdout}`);
});
// Stream output
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
});
console.log('Watcher started! Edit your test file to trigger a run.');
Install the dependency:
npm install chokidar
Then run:
node watch-test.js output/your-test.js
Playwright provides a built-in visual debugger. Add this to your test:
// Trigger Playwright Inspector
await page.pause();
.vscode/launch.json
file:{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Current Test",
"program": "${file}",
"cwd": "${workspaceFolder}",
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Debug Playwright Test",
"program": "${workspaceFolder}/node_modules/.bin/playwright",
"args": ["test", "${relativeFile}"],
"console": "integratedTerminal"
}
]
}
When using visible: true
, you can also interact with the browser’s DevTools:
This provides a powerful way to debug tests while they’re running.
For more interactive debugging, combine AutoSpectra with Cline’s browser_action:
// Use Cline for visual exploration
browser_action({ action: "launch", url: "http://localhost:3000" });
browser_action({ action: "click", coordinate: "450,300" });
browser_action({ action: "close" });
// Then use AutoSpectra for automated tests
use_mcp_tool({
server_name: "autospectra",
tool_name: "navigate",
arguments: { url: "http://localhost:3000", visible: true }
});
This workflow allows you to visually identify elements before automating them in your tests.