Low-level Chromium process management.
Spawns a headless Chromium instance and provides the WebSocket debugger URL
needed to connect via Automator.Client or Automator.Scraper.
Example
browser = Automator.Chromium.spawn()
# => %Automator.Chromium{chromium: #Port<...>, os_pid: 1234, port: 9222, ws_url: "ws://...", user_data_dir: "/tmp/..."}
# Connect to the browser target
{:ok, client} = Automator.Client.start_link(browser.ws_url)
{:ok, result} = Automator.Client.send_command(client, "Browser.getVersion")
Automator.Chromium.kill(browser)Browser Flags
Chromium is launched with these flags:
| Flag | Value |
|---|---|
--headless | new |
--no-sandbox | — |
--disable-gpu | — |
--window-size | 1920,1080 |
--user-data-dir | unique temp directory (cleaned up on kill/1) |
--remote-debugging-port | auto-detected (available TCP port) |
Each invocation gets a fresh --user-data-dir so concurrent spawns don't
contend over the default profile. Without it, Chrome for Testing silently
exits on macOS.
When to Use
Use Chromium directly when you want to:
- Connect multiple
Automator.Clientinstances to the same browser - Manage the browser lifecycle independently of scraping sessions
- Access the browser-level WebSocket target (not a page target)
For most use cases, prefer Automator.Scraper which handles this automatically.
Summary
Functions
Kills the Chromium process by OS PID and removes its --user-data-dir.
Spawns a headless Chromium instance on an available port.
Types
@type t() :: %Automator.Chromium{ chromium: port(), os_pid: non_neg_integer(), port: :inet.port_number(), user_data_dir: String.t() | nil, ws_url: String.t() }
Functions
Kills the Chromium process by OS PID and removes its --user-data-dir.
Example
browser = Automator.Chromium.spawn()
Automator.Chromium.kill(browser)
Spawns a headless Chromium instance on an available port.
Launches Chromium with --headless=new, --no-sandbox, --disable-gpu,
--window-size=1920,1080, and a unique --user-data-dir under the system
temp directory. Finds an available TCP port automatically and sets
--remote-debugging-port to it.
Returns an %Automator.Chromium{} struct with :chromium, :os_pid,
:port, :ws_url, and :user_data_dir.
Example
browser = Automator.Chromium.spawn()
IO.puts(browser.ws_url)
# => "ws://localhost:9222/devtools/browser/..."