kernel-agent-browser
Best practices for using agent-browser with Kernel cloud browsers. Use when automating websites with agent-browser -p kernel, dealing with bot detection, iframes, login persistence, or needing to find Kernel browser session IDs and live view URLs.
What this skill does
# Agent-Browser with Kernel Cloud Browsers This skill documents best practices for using agent-browser's built-in Kernel provider (`-p kernel`) for cloud browser automation. ## When to Use This Skill Use this skill when you need to: - **Automate websites** using `agent-browser -p kernel` commands - **Handle bot detection** on sites with aggressive anti-bot measures - **Persist login sessions** across automation runs using profiles - **Work with iframes** including cross-origin payment forms - **Get live view URLs** for debugging or manual intervention - **Find the underlying Kernel session ID** for advanced Playwright scripting - **Create site-specific automation skills** for new websites ## References - [Creating Site-Specific Skills](references/create-site-specific-skill.md) - Guide for building automation skills for specific websites ## Prerequisites Load the `kernel-cli` skill for Kernel CLI installation and authentication. ## Environment Variables Set these before your first `agent-browser -p kernel` call. The CLI holds state between invocations. | Variable | Description | Default | |----------|-------------|---------| | `KERNEL_API_KEY` | **Required.** Your Kernel API key for authentication | (none) | | `KERNEL_HEADLESS` | Run browser in headless mode (`true`/`false`) | `false` | | `KERNEL_STEALTH` | Enable stealth mode to avoid bot detection (`true`/`false`) | `true` | | `KERNEL_TIMEOUT_SECONDS` | Session timeout in seconds | `300` | | `KERNEL_PROFILE_NAME` | Browser profile name for persistent cookies/logins | (none) | ### Recommended Configuration ```bash export KERNEL_API_KEY="your-api-key" export KERNEL_TIMEOUT_SECONDS=600 # 10-minute timeout for complex workflows export KERNEL_STEALTH=true # Avoid bot detection (default) export KERNEL_PROFILE_NAME=mysite # Persist login sessions across runs ``` ### Profile Persistence When `KERNEL_PROFILE_NAME` is set: - The profile is created if it doesn't exist - Cookies, logins, and session data are automatically saved when the browser session ends - Future sessions with the same profile name restore the saved state This is especially useful for sites requiring login—authenticate once, reuse across sessions. ## Basic Usage ```bash agent-browser -p kernel open <url> # Navigate to page agent-browser -p kernel snapshot -i # Get interactive elements with refs agent-browser -p kernel click @e1 # Click element by ref agent-browser -p kernel fill @e2 "text" # Fill input by ref agent-browser -p kernel close # Close browser and save profile ``` Always use the `-p kernel` flag with each command. ## Semantic Selectors (Recommended) Instead of ephemeral `@e` refs that change on every page load, use **semantic selectors** via the `find` command for more stable, readable automation: ```bash # By ARIA role + accessible name (most stable) agent-browser -p kernel find role button click --name "Log In" agent-browser -p kernel find role textbox fill "[email protected]" --name "Email" # By visible text content agent-browser -p kernel find text "View Menus" click agent-browser -p kernel find text "Submit Order" click # By form label (great for inputs) agent-browser -p kernel find label "Username" fill "myuser" agent-browser -p kernel find label "Password" fill "secret123" # By placeholder text agent-browser -p kernel find placeholder "Search..." type "query" # By data-testid (if the site uses them) agent-browser -p kernel find testid "submit-btn" click # By position (when needed) agent-browser -p kernel find first "li.item" click agent-browser -p kernel find nth 2 ".card" hover ``` ### When to Use Which Selector | Selector Type | Best For | Stability | |---------------|----------|-----------| | `find role --name` | Buttons, links, navigation | ⭐⭐⭐ Most stable | | `find label` | Form inputs with labels | ⭐⭐⭐ Most stable | | `find text` | Clickable text elements | ⭐⭐ Stable | | `find testid` | Sites with test attributes | ⭐⭐⭐ Most stable | | `find placeholder` | Search boxes, inputs | ⭐⭐ Stable | | `@e` refs | Unknown sites, quick iteration | ⭐ Ephemeral | **Recommendation**: Use `find` for production automation. Use `@e` refs for exploration and quick prototyping, then convert to semantic selectors. ## Finding Session ID and Live View URL agent-browser creates a Kernel browser session under the hood. To get the session ID or live view URL: ```bash # List all Kernel browsers (find yours by profile name or creation time) kernel browsers list # Get live view URL for a specific session kernel browsers view <session-id> ``` This is useful when: - You need to execute Playwright scripts directly against the session - You want to share a live view URL with the user for manual intervention - You're debugging and want to watch the browser in real-time ## Handling Bot Detection ### Stealth Mode Stealth mode (`KERNEL_STEALTH=true`) is enabled by default and helps avoid detection. However, some sites have aggressive bot detection that still triggers. ### Manual Login Fallback If login automation fails due to bot detection: 1. Get the live view URL: ```bash kernel browsers list # Find your session by profile name kernel browsers view <session-id> ``` 2. Share the live view URL with the user and ask them to complete the login manually 3. Once logged in, continue automation—the profile will save the authenticated state ### JavaScript Fallback for Tricky Elements Some elements (especially on bot-protected sites) don't respond to standard commands: ```bash # Click by CSS selector agent-browser -p kernel eval "document.querySelector('.submit-btn').click()" # Fill by selector (with event dispatch) agent-browser -p kernel eval " const el = document.querySelector('#email'); el.value = '[email protected]'; el.dispatchEvent(new Event('input', {bubbles: true})); el.dispatchEvent(new Event('change', {bubbles: true})); " # Click by test ID agent-browser -p kernel eval "document.querySelector('[data-testid=\"submit\"]').click()" ``` ### Anti-Bot Form Fields Some payment processors (e.g., Point and Pay) use decoy form fields. Only fill fields matching specific patterns: ```bash agent-browser -p kernel eval " const realInputs = Array.from(document.querySelectorAll('input')) .filter(el => el.name && el.name.startsWith('xeiinput')); // Fill only these inputs " ``` ## Handling Iframes ### Same-Origin Iframes Use the frame command to switch context: ```bash agent-browser -p kernel frame "#iframe-id" # Switch to iframe agent-browser -p kernel snapshot -i # Snapshot within iframe agent-browser -p kernel click @e1 # Interact within iframe agent-browser -p kernel frame main # Return to main frame ``` ### Cross-Origin Iframes Cross-origin iframes require executing a Playwright script directly against the Kernel session: 1. Find the session ID: ```bash kernel browsers list ``` 2. Execute a Playwright script: ```bash kernel browsers exec <session-id> --code " const frame = page.frameLocator('#payment-iframe'); await frame.locator('#card-number').fill('4111111111111111'); await frame.locator('#submit').click(); " ``` See the kernel-cli skill for more details on executing Playwright code. ## Waiting Strategies **Smart waits are critical for fast, reliable automation.** Using condition-based waits instead of fixed timeouts can reduce execution time by 50%+ while improving reliability. ### Smart Waits (Recommended) ```bash # Wait for page load states agent-browser -p kernel wait --load domcontentloaded # DOM ready agent-browser -p kernel wait --load networkidle # Network settled # Wait for specific URL pattern (great for redirects after login) agent-browser -p kernel wait --url "**/dashboard" agent-browser -p kernel wait --url "**/order-confirmation" # Wait for text to appear (great for dynamic content) agent-browser -p kernel wait --text "Passwor
Related in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.