Skip to content

Browser Automation Resource

Note: This capability is now provided as an installable component. See the Components guide for how to install and use it.

Install: kdeps component install browser

Usage: run: { component: { name: browser, with: { url: "...", action: "navigate", selector: "...", screenshotPath: "..." } } }

The Browser component enables browser automation via Playwright, supporting page navigation, text extraction, and screenshots.

Note: The component exposes three actions: navigate, screenshot, and getText. For advanced automation (form fill, click, evaluate JavaScript, sessions, stealth mode), use a Python resource with playwright directly.

Component Inputs

InputTypeRequiredDefaultDescription
urlstringyesURL to navigate to
actionstringnonavigateAction: navigate, screenshot, or getText
selectorstringnoCSS selector for getText action
screenshotPathstringno/tmp/screenshot.pngFile path for screenshot action output

Using the Browser Component

Navigate and get page text:

yaml
run:
  component:
    name: browser
    with:
      url: "https://example.com"
      action: getText

Take a screenshot:

yaml
run:
  component:
    name: browser
    with:
      url: "https://example.com"
      action: screenshot
      screenshotPath: "/tmp/page.png"

Get text from a specific element:

yaml
run:
  component:
    name: browser
    with:
      url: "https://example.com"
      action: getText
      selector: ".article-content"

Access the result via output('<callerActionId>').


Actions

ActionDescription
navigateNavigate to the URL and return the final page URL
screenshotCapture a PNG screenshot of the page
getTextExtract visible text from the page or from a CSS selector

Result Map

KeyTypeDescription
successbooltrue if the action completed without error.
textstringExtracted text (getText action).
screenshotPathstringPath to saved screenshot (screenshot action).
urlstringFinal page URL after navigation.

Expression Support

All fields support KDeps expressions:

yaml
run:
  component:
    name: browser
    with:
      url: "{{ get('target_url') }}"
      action: getText
      selector: "{{ get('css_selector') }}"

Full Example: Screenshot Pipeline

yaml
# Step 1: Take a screenshot of a dashboard
- apiVersion: kdeps.io/v1
  kind: Resource

  metadata:
    actionId: capture
    name: Capture Dashboard

  run:
    component:
      name: browser
      with:
        url: "{{ get('dashboard_url') }}"
        action: screenshot
        screenshotPath: /tmp/dashboard.png

# Step 2: Send the screenshot by email
- apiVersion: kdeps.io/v1
  kind: Resource

  metadata:
    actionId: notify
    name: Send Screenshot
    requires:
      - capture

  run:
    component:
      name: email
      with:
        to: "{{ get('recipient') }}"
        subject: "Dashboard snapshot"
        body: "Screenshot saved at: {{ output('capture').screenshotPath }}"
        smtpHost: "{{ env('SMTP_HOST') }}"
        smtpUser: "{{ env('SMTP_USER') }}"
        smtpPass: "{{ env('SMTP_PASS') }}"

Installation

Playwright browsers must be installed on the host running kdeps:

bash
npx playwright install chromium
# or install all browsers:
npx playwright install

  • HTTP Client - Simple HTTP requests without a browser
  • Scraper - Text extraction from already-fetched pages
  • Python - Custom Python automation scripts (for advanced Playwright use)

Released under the Apache 2.0 License.