ConnectOnionConnectOnion
DocsUseful ToolsBrowserAutomation

BrowserAutomation

Natural language browser automation via Playwright. Navigate, click, type, screenshot — describe what you want, no CSS selectors needed.

Log in once, sessions persist in ~/.co/browser_profile/. Uses a vision LLM to find elements by description.

Installation

code
1pip install playwright 2playwright install chromium

Quick Start

With an agent

main.py
1from connectonion import Agent 2from connectonion.useful_tools.browser_tools import BrowserAutomation 3 4browser = BrowserAutomation() 5agent = Agent("web", tools=[browser], model="co/gemini-2.5-pro") 6 7agent.input("go to news.ycombinator.com and get the top 5 story titles")

Direct usage

main.py
1from connectonion.useful_tools.browser_tools import BrowserAutomation 2 3with BrowserAutomation() as browser: 4 browser.go_to("https://example.com") 5 browser.click("the contact button") 6 browser.keyboard_type("hello@example.com") 7 browser.keyboard_press("Enter") 8 browser.take_screenshot("result.png")

API Reference

Navigation

  • go_to(url)
  • get_current_url()
  • get_text()
  • get_links_from_page(filter?)

Interaction

  • click(description)
  • keyboard_type(text)
  • keyboard_press(key)
  • scroll(times?, description?)

Screenshot

  • take_screenshot(path?, full_page?)
  • set_viewport(width, height)

Waiting

  • wait(seconds)
  • wait_for_element(description)
  • wait_for_text(text)
  • wait_for_manual_login(site)

Persistent Sessions

Log in once — cookies and sessions persist to ~/.co/browser_profile/ automatically:

main.py
1# First run — log in manually 2browser = BrowserAutomation() 3browser.go_to("https://x.com") 4browser.wait_for_manual_login("X.com") # You handle 2FA/CAPTCHA 5# Session saved automatically 6 7# Every run after — already logged in 8browser = BrowserAutomation() 9browser.go_to("https://x.com") # Session restored

Screenshots

main.py
1# Returns base64 image (saved to .tmp/ automatically) 2browser.take_screenshot() 3 4# Custom filename 5browser.take_screenshot("login_page.png") 6 7# Full page capture 8browser.take_screenshot(full_page=True) 9 10# Headless vs visible 11BrowserAutomation(headless=True) # Default — runs in background 12BrowserAutomation(headless=False) # Open visible window

Enjoying ConnectOnion?

⭐ Star us on GitHub = ☕ Coffee chat with our founder. We love meeting builders.