# For OpenAI (default)OPENAI_API_KEY=your_openai_api_key_hereLLM_PROVIDER=openai # Optional, this is defaultAUTOBROWSE_LLM_MODEL=gpt-4o-mini # Optional, defaults to gpt-4o-mini# Or for Google AIGOOGLE_API_KEY=your_google_key_hereLLM_PROVIDER=googleAUTOBROWSE_LLM_MODEL=gemini-2.0-flash-lite # Or other supported model
Auto-Browse supports multiple LLM providers, with OpenAI as the default.
Here’s a complete example showing form automation:
Copy
import { auto } from "@auto-browse/auto-browse";async function main() { try { // Navigate to the form await auto("go to https://httpbin.org/forms/post"); // Take a snapshot to analyze the page structure await auto("take a snapshot"); // Fill out the form await auto('type "John Doe" in the customer name field'); await auto('select "Large" for size'); await auto('select "Mushroom" for topping'); await auto('check "cheese" in extras'); // Submit the form await auto("click the Order button"); // Take a snapshot of the response page await auto("take a snapshot of the response page"); } catch (error) { console.error("Error:", error); }}// Run the scriptmain().catch(console.error);
Auto-Browse seamlessly integrates with Playwright tests:
Copy
import { test, expect } from "@playwright/test";import { auto } from "@auto-browse/auto-browse";test("example test", async ({ page }) => { await page.goto("https://example.com"); // Get text using natural language const headerText = await auto("get the header text"); // Type in an input using natural language await auto('type "Hello World" in the search box'); // Click elements using natural language await auto("click the login button");});