This guide explains how to set up and use UniAuto MCP Server with VSCode and the Claude Extension.
Alternatively, add these settings directly to your settings.json
:
{
"claude.smithery.enabled": true,
"claude.smithery.path": "/path/to/smithery/executable", // Only if not in PATH
"claude.smithery.tools": ["uniauto-mcp-server"]
}
If you prefer not to use extensions:
uniauto-server
curl -X POST http://localhost:3000/api/mcp/invoke \
-H "Content-Type: application/json" \
-d '{"action":"navigate","parameters":{"url":"https://example.com"}}'
Once set up, you can ask Claude to perform test automation tasks directly in VSCode:
Write a test script using UniAuto to test the login functionality of our application at http://localhost:8080.
Claude will generate and execute the test script, providing feedback in the chat.
GitHub Copilot can also work with UniAuto through custom commands:
/test
or your chosen prefixAsk your AI assistant to create test files using UniAuto commands:
Create a test file for our user registration page that uses UniAuto's self-healing capabilities.
The assistant will generate a test file like:
// userRegistration.test.js
const { invokeAutomation } = require('./uniauto-client');
describe('User Registration', () => {
test('should successfully register a new user', async () => {
await invokeAutomation('navigate', { url: 'http://localhost:8080/register' });
await invokeAutomation('type', { selector: '#email', text: 'test@example.com' });
// More commands...
});
});
Execute tests using Jest or your preferred test runner:
npm test
VSCode’s Test Explorer will also recognize and display these tests if properly configured.
Use your AI assistant to generate tests based on application specs:
Based on this user story: "As a user, I want to reset my password", generate a UniAuto test.
AI can help maintain tests when the UI changes:
This test is failing because the 'Submit' button selector changed. Can you update it using UniAuto's self-healing?
UniAuto can capture screenshots during test execution:
await invokeAutomation('screenshot', { fileName: 'login-form.png' });
These screenshots will be saved in the public/screenshots
directory for examination.
Add this to your launch.json
to debug tests:
{
"type": "node",
"request": "launch",
"name": "Debug UniAuto Tests",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": ["--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
If you encounter issues, ask your AI assistant:
My UniAuto test is failing with "element not found". How can I debug this?