Auto-Detection Mode

Auto-Detection mode is a powerful feature of Auto-Browse that automatically manages page contexts and browser state, making it easier to write and maintain automation scripts.

Overview

When using Auto-Browse, you don’t need to explicitly manage page contexts. The library will:
  • Detect the current page context automatically
  • Create new browser instances when needed
  • Handle page lifecycle management
  • Clean up resources properly

Basic Usage

The simplest way to use Auto-Browse is to let it handle context management:
import { auto } from "auto-browse";

async function example() {
	// Auto-Browse will create and manage the browser/page
	await auto("go to https://example.com");
	await auto("take a snapshot");
	await auto("click the login button");
}

How It Works

  1. Browser Management
    • Creates browser instance when needed
    • Reuses existing browser when possible
    • Handles cleanup automatically
  2. Page Context
    • Detects active page context
    • Creates new pages when required
    • Manages multiple pages efficiently
  3. State Management
    • Tracks page state automatically
    • Handles navigation events
    • Maintains context between commands

Integration Example

Auto-Browse works seamlessly with both standalone and Playwright modes:
import { auto } from "auto-browse";

async function example() {
	// Auto-Browse manages everything automatically
	await auto("go to https://example.com");
	await auto("click Sign Up");
	await auto('type "user@example.com" in email field');
	await auto("submit form");
	await auto("verify success message");
}

Key Benefits

  • Automatic Context Management: No need to manually create or manage browser/page instances
  • State Tracking: Maintains context between commands automatically
  • Multi-Page Support: Handles tabs, popups, and navigation seamlessly
  • Error Handling: Cleans up resources automatically on errors

Next Steps