
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
autoplaywright-ai
Advanced tools
AI-powered Playwright test automation using natural language commands with Azure OpenAI
A library that integrates with Playwright tests to execute commands in plain English using Azure OpenAI. The LLM analyzes DOM snapshots and translates natural language commands into Playwright actions.
npm install autoplaywright-ai
# Peer dependency (if not already installed)
npm install @playwright/test
NEVER commit credentials to version control!
.env to your .gitignore file.env.example as a template without real valuesCreate a .env file in the project root (copy from .env.sample):
# Copy the sample file
cp .env.sample .env
# Edit .env and add your actual values:
AZURE_OPENAI_API_KEY=your-actual-api-key
AZURE_OPENAI_RESOURCE=your-resource-name
AZURE_OPENAI_DEPLOYMENT=your-deployment-name
The environment variables are automatically loaded when running Playwright tests.
import { test } from '@playwright/test';
import { auto } from 'autoplaywright-ai';
test('navigate GitHub with natural language', async ({ page }) => {
const config = {
azureResource: process.env.AZURE_OPENAI_RESOURCE!,
azureDeployment: process.env.AZURE_OPENAI_DEPLOYMENT!,
model: 'gpt-4o'
};
await page.goto('https://github.com/microsoft/playwright');
// Use natural language commands
await auto('Click on the Issues tab', { page }, config);
await auto('Click on the first issue', { page }, config);
const issueTitle = await auto('Get the issue title', { page }, config);
console.log('Issue title:', issueTitle);
});
auto(command, context, config)Simple function for executing single commands.
command: Natural language commandcontext: Object with either page or locator propertyconfig: LLM configurationAutoPlaywright classFor more control and advanced features:
const autoPlaywright = new AutoPlaywright(context, config, options);
// Execute single command
await autoPlaywright.execute('Click the submit button');
// Execute multiple commands
await autoPlaywright.executeMultiple([
'Fill in the email field with "test@example.com"',
'Fill in the password field',
'Click the login button'
]);
// Retry command
await autoPlaywright.retryExecute('Click the dynamic button', 3, 1000);
// Helper methods
await autoPlaywright.exists('login button');
await autoPlaywright.getText('page heading');
await autoPlaywright.count('product cards');
The LLM understands these Playwright commands:
navigate, goto, reload, goBack, goForwardclick, type, fill, select, check, uncheck, hover, presswait, waitForNavigationgetText, getAttribute, isVisible, countscreenshot, evaluateinterface LLMConfig {
apiKey?: string; // Falls back to AZURE_OPENAI_API_KEY env var
azureResource: string; // Your Azure OpenAI resource name
azureDeployment: string; // Your deployment name
model?: string; // Default: 'gpt-4o'
temperature?: number; // Default: 0.3
maxTokens?: number; // Default: 500
}
Enable debug mode to see detailed logs:
const autoPlaywright = new AutoPlaywright(
{ page, test },
config,
{ debug: true }
);
AutoPlaywright fully supports iframe interactions by accepting locators:
// Get iframe locator
const iframe = page.frameLocator('iframe#payment-frame');
const iframeBody = iframe.locator('body');
// Create AI instance for iframe
const iframeAI = new AutoPlaywright({ locator: iframeBody }, config);
// Interact with iframe content
await iframeAI.execute('Fill in the credit card number');
await iframeAI.execute('Click the submit button');
// Or use the simple auto function
await auto('Click the accept button', { locator: iframeBody }, config);
page.waitForURL() after navigation commandsexists() helper for conditional flows# Install dependencies
npm install
# Run TypeScript compiler
npm run build
# Run tests
npm test
MIT# autotest
FAQs
AI-powered Playwright test automation using natural language commands with Azure OpenAI
We found that autoplaywright-ai demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.