🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

browserctl-cli

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserctl-cli

Self-contained browserctl CLI with auto-start Chrome/Edge daemon (no Electron required)

Source
npmnpm
Version
0.1.2
Version published
Weekly downloads
21
-65%
Maintainers
1
Weekly downloads
 
Created
Source

browserctl-cli

Self-contained global CLI to drive a standalone Chrome/Edge via browserctl commands. Designed for non-Electron use: CI pipelines, local automation scripts, or any context where you want the full browserctl command set without the Electron shell.

The command set is identical to the Electron-embedded browserctl; the difference is the daemon runs as a plain Node.js process rather than inside Electron.

Requirements: Node.js ≥ 20, Google Chrome or Microsoft Edge installed.

Install

npm install -g browserctl-cli
# or
pnpm add -g browserctl-cli

Then:

browserctl open https://www.baidu.com
browserctl snapshot --interactive
browserctl quit

Global install registers the browserctl command (auto-starts a background daemon on first use).

Usage

Quick start:

browserctl open https://www.baidu.com
browserctl snapshot --interactive
browserctl fill @e1 "search query"
browserctl click @e2
browserctl screenshot --annotate --out shot.png
browserctl quit

Full command reference (same as desktop browserctl, minus Electron-only open-artifact / close):

browserctl health
browserctl open <url>                 # = navigate
browserctl snapshot [--max-nodes 200] [--compact|-c] [--depth N|-d N] [--scope <sel>|-s <sel>] [--tree | --interactive]
browserctl wait (--selector <css> [--state visible|hidden] | --text <text> | --url <glob> | --load load|domcontentloaded|networkidle | --fn <js> | --fn-file <path> | --fn-stdin | --ms <n>) [--timeout 10000]
browserctl eval (<js> | --file <path> | --stdin) [--timeout 10000]
browserctl click <@eN|selector> [--confirm "确认文案"]
browserctl fill <@eN|selector> (<text> | --text-file <path> | --text-stdin)
browserctl hover|dblclick|focus|type|check|uncheck <@eN|selector>
browserctl drag <@eN|selector> <@eN|selector>
browserctl upload <@eN|selector> <file...>
browserctl press <key> [@eN|selector] [--ctrl|--shift|--alt|--meta]
browserctl scroll [@eN|selector] [--to top|bottom] [--by <px>]
browserctl select <@eN|selector> (<value> | --label <文本>)
browserctl get url|title|value|text|html|count|box|styles|attr <@eN|selector> [attrName]
browserctl is visible|enabled|checked <@eN|selector>
browserctl find role|text|…  # positional;或 find <action> --role|--selector|… flag 模式
browserctl back|forward|reload
browserctl scrollintoview|scroll-into-view <@eN|selector>
browserctl dialog status|accept [text]|dismiss
browserctl extract-text
browserctl screenshot [--full] [--annotate] [--out <path>]
browserctl batch [--bail] [--json] "<cmd>"

Detailed syntax, find flag mode, dialog semantics, and batch examples: command reference.

Daemon lifecycle

The daemon process manages the browser session in the background.

Auto-start — the first browser command automatically starts the daemon (default: Chrome, headed, persistent profile at ~/.browserctl/profile-chrome). No explicit step needed.

Chrome window closed — if you close the browser window, the daemon exits automatically; the next browserctl command starts a fresh daemon and Chrome (login state is kept in the persistent profile). You do not need browserctl quit in this case.

Explicit start with non-default config — runs in the foreground; press Ctrl+C to stop:

browserctl serve --browser edge --headless

Stop — shuts down the daemon and closes the browser:

browserctl quit

Login state (OA / SSO)

Use the persistent profile to avoid repeated logins:

  • Run any command (e.g. browserctl open https://your-oa/) — Chrome opens with the persistent profile.
  • Log in manually in the browser window that appears.
  • Close the window or leave it open — the profile is preserved across restarts.

Subsequent daemon starts reuse the same profile, so login state is retained automatically.

Environment variables

VariableDefaultDescription
BROWSER_RUNTIME_BRIDGE_URLhttp://127.0.0.1:34555Daemon bridge URL (auto-set by CLI)
BROWSER_RUNTIME_TIMEOUT_MS60000Per-request socket timeout
BROWSERCTL_STATE_DIR~/.browserctlDaemon PID/state directory

Windows note: process cleanup

browserctl quit writes a stop signal and cleans the state file, but process.kill may not reliably terminate the daemon process on Windows. If the daemon lingers after quit:

  • Find the PID in ~/.browserctl/daemon.json.

  • Force-kill it:

    taskkill /PID <pid> /F
    

Chrome is closed indirectly by the daemon's shutdown handler; if Chrome also lingers, close it manually.

Keywords

browser

FAQs

Package last updated on 01 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts