Skip to content

Commit fe3c616

Browse files
Merge pull request #7 from auto-browse/feature/refactor
Feature/refactor and synced with latest Playwright mcp tools and configs
2 parents ff62593 + df64732 commit fe3c616

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+5260
-3625
lines changed

.eslintrc.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5",
4+
"tabWidth": 2,
5+
"semi": true,
6+
"printWidth": 80
7+
}

README.md

Lines changed: 48 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -22,105 +22,49 @@ npm install @auto-browse/auto-browse
2222

2323
## ⚠️ Important: Playwright Version Requirements
2424

25-
> **Note:** Auto Browse currently requires specific versions of Playwright. This requirement will be relaxed in future versions.
25+
Auto Browse requires Playwright version 1.53.0 or higher.
2626

2727
### Required Versions
2828

2929
```bash
30-
"@playwright/test": "1.52.0-alpha-1743011787000"
31-
"playwright": "1.52.0-alpha-1743011787000"
30+
"@playwright/test": ">=1.53.0"
31+
"playwright": ">=1.53.0"
3232
```
3333

34-
### Version Conflicts
34+
### Installation
3535

36-
If you're using Auto Browse alongside an existing Playwright setup, you must upgrade to these specific versions. Here's how to handle common issues:
36+
If you encounter version conflicts, use the legacy peer deps flag:
3737

38-
1. **Installation Conflicts**
39-
40-
```bash
41-
npm install --legacy-peer-deps
42-
```
43-
44-
This flag helps resolve peer dependency conflicts during installation.
45-
46-
2. **Multiple Playwright Versions**
47-
48-
- Remove existing Playwright installations
49-
- Clear npm cache if needed: `npm cache clean --force`
50-
- Reinstall with the required versions
51-
52-
3. **Project Compatibility**
53-
- Update your project's Playwright configuration
54-
- Ensure your existing tests are compatible with the alpha version
55-
- Consider using a separate test environment if needed
56-
57-
> 🔄 Future releases will support a wider range of Playwright versions. Subscribe to our GitHub repository for updates.
38+
```bash
39+
npm install --legacy-peer-deps
40+
```
5841

59-
## Configuration
42+
## Quick Setup
6043

61-
Auto Browse requires environment variables for the LLM (Language Model) configuration. Create a `.env` file in your project root:
44+
1. Create a `.env` file in your project root:
6245

6346
```env
64-
# OpenAI (default)
47+
# For OpenAI (default)
6548
OPENAI_API_KEY=your_openai_api_key_here
66-
LLM_PROVIDER=openai # Optional, defaults to openai
67-
AUTOBROWSE_LLM_MODEL=gpt-4o-mini # Optional, defaults to gpt-4o-mini
49+
LLM_PROVIDER=openai # Optional
50+
AUTOBROWSE_LLM_MODEL=gpt-4o-mini # Optional
6851
69-
# Google AI
52+
# Or for Google AI
7053
GOOGLE_API_KEY=your_google_key_here
7154
LLM_PROVIDER=google
7255
AUTOBROWSE_LLM_MODEL=gemini-2.0-flash-lite
73-
74-
# Azure OpenAI
75-
AZURE_OPENAI_API_KEY=your_azure_key_here
76-
AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com/
77-
AZURE_OPENAI_API_VERSION=2024-12-01-preview
78-
AZURE_OPENAI_API_DEPLOYMENT_NAME=your-deployment-name
79-
LLM_PROVIDER=azure
80-
81-
# Anthropic
82-
ANTHROPIC_API_KEY=your_anthropic_key_here
83-
LLM_PROVIDER=anthropic
84-
AUTOBROWSE_LLM_MODEL=claude-3
85-
86-
# Google Vertex AI
87-
GOOGLE_APPLICATION_CREDENTIALS=path/to/credentials.json
88-
LLM_PROVIDER=vertex
89-
90-
# Ollama
91-
BASE_URL=http://localhost:11434 # Optional, defaults to this value
92-
LLM_PROVIDER=ollama
93-
AUTOBROWSE_LLM_MODEL=llama3.1
9456
```
9557

96-
You can find an example configuration in `example.env`.
97-
98-
### Environment Variables
99-
100-
| Variable | Description | Default | Required For |
101-
| ---------------------------------- | -------------------------------------- | ------------------------ | ------------ |
102-
| `LLM_PROVIDER` | LLM provider to use | `openai` | No |
103-
| `AUTOBROWSE_LLM_MODEL` | The LLM model to use | `gpt-4o-mini` | No |
104-
| `OPENAI_API_KEY` | OpenAI API key | - | OpenAI |
105-
| `GOOGLE_API_KEY` | Google AI API key | - | Google AI |
106-
| `AZURE_OPENAI_API_KEY` | Azure OpenAI API key | - | Azure |
107-
| `AZURE_OPENAI_ENDPOINT` | Azure OpenAI endpoint URL | - | Azure |
108-
| `AZURE_OPENAI_API_VERSION` | Azure OpenAI API version | `2024-12-01-preview` | Azure |
109-
| `AZURE_OPENAI_API_DEPLOYMENT_NAME` | Azure OpenAI deployment name | - | Azure |
110-
| `ANTHROPIC_API_KEY` | Anthropic API key | - | Anthropic |
111-
| `GOOGLE_APPLICATION_CREDENTIALS` | Path to Google Vertex credentials file | - | Vertex AI |
112-
| `BASE_URL` | Ollama API endpoint | `http://localhost:11434` | No |
58+
2. Start automating!
11359

11460
## Supported LLM Providers
11561

116-
Auto Browse supports multiple LLM providers:
117-
118-
- OpenAI (default) - GPT-4 and compatible models
119-
- Google AI - Gemini models
120-
- Azure OpenAI - GPT models on Azure
121-
- Anthropic - Claude models
122-
- Google Vertex AI - PaLM and Gemini models
123-
- Ollama - Run models locally
62+
- **OpenAI** (default) - GPT-4 and compatible models
63+
- **Google AI** - Gemini models
64+
- **Azure OpenAI** - GPT models on Azure
65+
- **Anthropic** - Claude models
66+
- **Google Vertex AI** - PaLM and Gemini models
67+
- **Ollama** - Run models locally
12468

12569
## Usage
12670

@@ -211,125 +155,65 @@ test("simplified example", async ({ page }) => {
211155

212156
### BDD Mode with Playwright-BDD
213157

214-
Auto Browse seamlessly integrates with [playwright-bdd](https://github.com/vitalets/playwright-bdd) for behavior-driven development. This allows you to write expressive feature files and implement steps using natural language commands.
215-
216-
#### Example Feature File
158+
Auto Browse integrates with [playwright-bdd](https://github.com/vitalets/playwright-bdd) for behavior-driven development:
217159

218160
```gherkin
219161
# features/homepage.feature
220162
Feature: Playwright Home Page
221-
222163
Scenario: Check title
223164
Given navigate to https://playwright.dev
224165
When click link "Get started"
225166
Then assert title "Installation"
226167
```
227168

228-
#### Step Definitions
229-
230169
```typescript
170+
// One step definition handles all actions
231171
import { auto } from "@auto-browse/auto-browse";
232172
import { Given, When as aistep, Then } from "./fixtures";
233173

234-
// Generic step that handles any natural language action
235174
aistep(/^(.*)$/, async ({ page }, action: string) => {
236175
await auto(action, { page });
237176
});
238177
```
239178

240-
#### Setup Requirements
241-
242-
1. Install dependencies:
243-
244-
```bash
245-
npm install --save-dev @playwright/test @cucumber/cucumber playwright-bdd
246-
```
247-
248-
2. Configure `playwright.config.ts`:
179+
### Key Actions
249180

250181
```typescript
251-
import { PlaywrightTestConfig } from "@playwright/test";
252-
253-
const config: PlaywrightTestConfig = {
254-
testDir: "./features",
255-
use: {
256-
baseURL: "https://playwright.dev"
257-
}
258-
};
259-
260-
export default config;
261-
```
262-
263-
This integration enables:
264-
265-
- Natural language test scenarios
266-
- Reusable step definitions
267-
- Cucumber reporter integration
268-
- Built-in Playwright context management
269-
270-
### Supported Actions
182+
// Navigation
183+
await auto("go to https://example.com");
271184

272-
1. **Clicking Elements**
185+
// Clicking
186+
await auto("click the submit button");
273187

274-
```typescript
275-
await auto("click the submit button");
276-
await auto("click the link that says Learn More");
277-
```
188+
// Typing
189+
await auto('type "username" in the email field');
278190

279-
2. **Typing Text**
191+
// Verification
192+
await auto("verify the success message is visible");
280193

281-
```typescript
282-
await auto('type "username" in the email field');
283-
await auto('enter "password123" in the password input');
284-
```
285-
286-
## Features
194+
// Taking snapshots
195+
await auto("take a snapshot");
196+
```
287197

288-
Core Features:
198+
## Core Features
289199

290-
- Natural language commands for browser automation
291-
- AI-powered computer and browser agent
292-
- Automate any browser task
293-
- Automatic page/context detection
294-
- TypeScript support
295-
- Playwright test integration
296-
- Zero configuration required
200+
- **Natural Language Commands** - Write automation in plain English
201+
- **AI-Powered Intelligence** - Smart element detection and interaction
202+
- **Auto Context Detection** - Automatically manages browser and page contexts
203+
- **Multiple LLM Support** - Works with OpenAI, Google AI, Anthropic, and more
204+
- **Playwright Integration** - Seamless integration with Playwright tests
205+
- **TypeScript Support** - Full type safety and IntelliSense
206+
- **Zero Configuration** - Works out of the box with minimal setup
297207

298-
Supported Operations:
208+
## Documentation
299209

300-
- Page Navigation (goto URL, back, forward)
301-
- Element Interactions (click, type, hover, drag-and-drop)
302-
- Form Handling (select options, file uploads, form submission)
303-
- Visual Verification (snapshots, screenshots, PDF export)
304-
- Keyboard Control (key press, text input)
305-
- Wait and Timing Control
306-
- Assertions and Validation
210+
📚 [Full Documentation](https://typescript.docs.auto-browse.com/quickstart) - Complete guides, examples, and API reference
307211

308212
## Best Practices
309213

310-
1. **Be Descriptive**
311-
312-
```typescript
313-
// Good
314-
await auto("click the submit button in the login form");
315-
316-
// Less Clear
317-
await auto("click submit");
318-
```
319-
320-
2. **Use Quotes for Input Values**
321-
322-
```typescript
323-
// Good
324-
await auto('type "John Doe" in the name field');
325-
326-
// Not Recommended
327-
await auto("type John Doe in the name field");
328-
```
329-
330-
3. **Leverage Existing Labels**
331-
- Use actual labels and text from your UI in commands
332-
- Maintain good accessibility practices in your app for better automation
214+
- **Be descriptive**: `"click the submit button in the login form"` vs `"click submit"`
215+
- **Use quotes for values**: `'type "John Doe" in the name field'`
216+
- **Take snapshots**: `"take a snapshot"` helps the AI understand page context
333217

334218
## Contributing
335219

0 commit comments

Comments
 (0)