diff --git a/README.md b/README.md index a8075e7..5a540d8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # veb -Headless browser automation CLI for agents and humans. Full Playwright parity. +Headless browser automation CLI for agents and humans. ## Installation @@ -10,447 +10,253 @@ npx playwright install chromium pnpm build ``` -## Usage +## Quick Start ```bash -# Navigation -veb open https://example.com -veb back # Go back -veb forward # Go forward -veb reload # Reload page - -# Page info -veb url # Get current URL -veb title # Get page title - -# Clicking -veb click "#submit-btn" -veb dblclick "#item" -veb tap "#mobile-btn" # Touch tap - -# Form input -veb type "#search" "query" # Type character by character -veb fill "#email" "test@example.com" # Clear and fill (faster) -veb check "#agree" # Check checkbox/radio -veb uncheck "#newsletter" # Uncheck checkbox -veb select "#country" "US" # Select dropdown -veb clear-input "#field" # Clear input field -veb setvalue "#hidden" "val" # Set value directly - -# Keyboard -veb press Enter -veb press Tab -veb press "Control+a" # Keyboard shortcuts -veb press "Shift+Tab" - -# Mouse -veb hover "#menu" -veb focus "#input" -veb drag "#source" "#target" -veb wheel 300 # Scroll wheel (deltaY) -veb wheel 0 100 # Scroll wheel (deltaX, deltaY) -veb mousemove 100 200 # Move mouse to coordinates -veb mousedown # Press mouse button -veb mouseup # Release mouse button -veb mousedown right # Right-click down - -# Text operations -veb selectall "#input" # Select all text -veb clipboard copy # Copy to clipboard -veb clipboard paste # Paste from clipboard -veb clipboard read # Read clipboard content - -# File upload -veb upload "#file-input" ./document.pdf -veb upload "#files" ./a.png ./b.png - -# Downloads -veb download "#download-btn" ./file.zip - -# Waiting -veb wait "#loading" # Wait for selector -veb wait --text "Welcome" # Wait for text -veb wait 2000 # Wait 2 seconds -veb waitforurl "**/dashboard" # Wait for URL pattern -veb waitforload networkidle # Wait for network idle -veb waitforload domcontentloaded # Wait for DOM ready - -# Screenshots & PDF +veb open example.com +veb click "#submit" +veb fill "#email" "test@example.com" +veb get text "h1" veb screenshot page.png -veb screenshot --full page.png # Full page -veb screenshot -s "#hero" # Specific element -veb pdf report.pdf - -# Content extraction -veb snapshot # Accessibility tree (best for agents) -veb extract "#main" # Get HTML -veb eval "document.title" # Run JavaScript -veb innertext "#message" # Get inner text -veb innerhtml "#container" # Get inner HTML -veb inputvalue "#field" # Get input value - -# Element info -veb gettext "#message" # Get text content -veb getattr "#link" "href" # Get attribute -veb isvisible "#modal" # Check visibility -veb isenabled "#submit" # Check if enabled -veb ischecked "#checkbox" # Check if checked -veb count ".items" # Count matching elements -veb boundingbox "#element" # Get position/size -veb highlight "#element" # Highlight element (debugging) - -# Scrolling -veb scroll down 500 -veb scroll up -veb scroll -s "#container" down - -# Semantic locators (Playwright's recommended approach) -veb role button click --name "Submit" -veb role textbox fill "hello" --name "Email" -veb text "Sign In" click -veb text "Submit" click --exact -veb label "Email" fill "test@test.com" -veb placeholder "Search..." fill "query" -veb alt "Logo" click # By alt text -veb bytitle "Close" click # By title attribute -veb testid "submit-btn" click # By data-testid - -# Nth element (when multiple match) -veb first "a" click # Click first link -veb last "a" click # Click last link -veb nth "a" 2 click # Click 3rd link (0-indexed) -veb first ".item" text # Get text of first item - -# Frames/iframes -veb frame "#iframe" # Switch to iframe -veb mainframe # Switch back to main - -# Network interception -veb route "**/*.png" --abort # Block images -veb route "**/api/*" --body '{"mock":true}' # Mock API -veb unroute # Remove all routes -veb requests # View tracked requests -veb requests --filter "api" # Filter requests - -# Browser settings -veb viewport 1920 1080 # Set viewport size -veb device "iPhone 14" # Emulate device -veb geolocation 37.7749 -122.4194 # Set location (SF) -veb permissions grant geolocation notifications -veb media --dark # Dark mode -veb media --light # Light mode -veb media --print # Print media type -veb media --reduced-motion # Reduced motion -veb offline # Enable offline mode -veb offline off # Disable offline mode -veb headers '{"X-Custom":"value"}' # Set extra headers -veb credentials user pass # HTTP basic auth -veb timezone America/New_York # Set timezone (at launch) -veb locale fr-FR # Set locale (at launch) - -# Cookies -veb cookies # Get all cookies -veb cookies set '[{"name":"session","value":"abc123","domain":".example.com"}]' -veb cookies clear - -# Storage -veb storage local # Get all localStorage -veb storage local myKey # Get specific key -veb storage local set key value # Set value -veb storage local clear # Clear localStorage -veb storage session # sessionStorage (same commands) - -# Dialogs (alerts, confirms, prompts) -veb dialog accept # Accept next dialog -veb dialog accept "input text" # Accept prompt with text -veb dialog dismiss # Dismiss next dialog - -# Debugging & Tracing -veb trace start # Start recording trace -veb trace start --screenshots # With screenshots -veb trace stop ./trace.zip # Stop and save trace -veb state save ./auth.json # Save cookies/storage -veb state load ./auth.json # Load saved state -veb console # View console messages -veb console --clear # Clear console -veb errors # View page errors -veb errors --clear # Clear errors -veb pause # Pause (opens inspector) - -# Inject scripts/styles -veb addscript "console.log('hi')" -veb addscript https://example.com/lib.js -veb addstyle "body { background: red; }" -veb addstyle https://example.com/styles.css -veb setcontent '

Hello

' # Set page HTML directly - -# Custom events -veb dispatch "#btn" "click" -veb dispatch "#input" "focus" - -# Tabs -veb tab new -veb tab list -veb tab 0 # Switch to tab -veb tab close - -# Windows -veb window new - -# Sessions (isolate multiple agents) -veb --session agent1 open example.com -veb --session agent2 open google.com -VEB_SESSION=agent1 veb click "#btn" -veb session list - -# Close browser veb close ``` -## Agent Mode +## Commands -Use `--json` flag for machine-readable output: +### Core Commands ```bash -veb snapshot --json -veb eval "document.title" --json -veb isvisible "#modal" --json +veb open # Navigate to URL +veb click # Click element +veb type # Type into element +veb fill # Clear and fill +veb press # Press key (Enter, Tab, Control+a) +veb hover # Hover element +veb select # Select dropdown option +veb check # Check checkbox +veb uncheck # Uncheck checkbox +veb scroll [px] # Scroll (up/down/left/right) +veb drag # Drag and drop +veb upload # Upload files +veb screenshot [path] # Take screenshot (--full for full page) +veb pdf # Save as PDF +veb snapshot # Accessibility tree (best for AI) +veb eval # Run JavaScript +veb close # Close browser ``` -## All Commands +### Get Info -### Navigation -| Command | Description | -|---------|-------------| -| `open ` | Navigate to URL | -| `back` | Go back | -| `forward` | Go forward | -| `reload` | Reload page | -| `url` | Get current URL | -| `title` | Get page title | +```bash +veb get text # Get text content +veb get html # Get innerHTML +veb get value # Get input value +veb get attr # Get attribute +veb get title # Get page title +veb get url # Get current URL +veb get count # Count matching elements +veb get box # Get bounding box +``` -### Interaction -| Command | Description | -|---------|-------------| -| `click ` | Click element | -| `dblclick ` | Double-click | -| `tap ` | Touch tap | -| `type ` | Type text | -| `fill ` | Clear & fill | -| `press ` | Press key | -| `check ` | Check checkbox | -| `uncheck ` | Uncheck | -| `select ` | Select option | -| `hover ` | Hover | -| `focus ` | Focus | -| `drag ` | Drag & drop | -| `wheel [deltaY] [deltaX]` | Mouse wheel | -| `clear-input ` | Clear input | -| `setvalue ` | Set value | -| `selectall ` | Select all text | -| `upload ` | Upload files | -| `download ` | Download file | -| `scroll [amount]` | Scroll | -| `clipboard copy\|paste\|read` | Clipboard ops | +### Check State -### Element Info -| Command | Description | -|---------|-------------| -| `gettext ` | Get text content | -| `innertext ` | Get inner text | -| `innerhtml ` | Get inner HTML | -| `inputvalue ` | Get input value | -| `getattr ` | Get attribute | -| `isvisible ` | Check visibility | -| `isenabled ` | Check enabled | -| `ischecked ` | Check checked | -| `count ` | Count elements | -| `boundingbox ` | Get bounds | -| `highlight ` | Highlight element | +```bash +veb is visible # Check if visible +veb is enabled # Check if enabled +veb is checked # Check if checked +``` -### Semantic Locators -| Command | Description | -|---------|-------------| -| `role ` | By ARIA role | -| `text ` | By text | -| `label