Guides

Remote & multi-tab

Connect bl to a remote browser over a WebSocket, and coordinate work across several tabs.

Two related needs come up once your automation grows past a single local tab: driving a browser that lives somewhere else (a cloud grid, a container), and working across multiple tabs at once. browserlane handles both.

Connect to a remote browser

By default bl start launches a local Chrome. Pass a URL and it instead connects to a remote browser over a WebDriver BiDi WebSocket endpoint:

bl start ws://remote-host:9515/session
bl open https://example.com
bl map
bl stop

Once connected, every command works exactly as it does locally — the only difference is where the browser runs.

Connect via environment variables

If you don't pass a URL, bl start checks the BROWSERLANE_CONNECT_URL environment variable before falling back to launching a local browser. Set BROWSERLANE_CONNECT_API_KEY to send an Authorization: Bearer header with the connection — useful for hosted browser services that require a key:

export BROWSERLANE_CONNECT_URL=wss://cloud.example.com/session
export BROWSERLANE_CONNECT_API_KEY=my-api-key
bl start    # connects using the env vars

This is the convenient form for CI: set the two variables in the environment and every bl command in the job targets the remote browser without repeating the URL.

ws:// vs wss://

Use ws:// for a plaintext endpoint (typically local or inside a trusted network) and wss:// for a TLS endpoint (anything over the public internet). Hosted services generally give you a wss:// URL plus an API key.

Work across multiple tabs

A session can hold several open tabs. List them, open new ones, and switch between them — commands always act on the current tab.

bl tabs
# [0] https://example.com
# [1] https://docs.example.com

Open, switch, close

bl tab new https://docs.example.com    # open a new tab (and navigate)
bl text "h1"                           # acts in the new tab — it's now current

bl tab switch 0                        # switch back to the first tab by index
bl tab switch docs.example.com         # …or switch by URL substring

bl tab close 1                         # close tab at index 1
bl tab close                           # close the current tab

bl tab new with no URL opens a blank tab; bl tab switch takes either a numeric index (from bl tabs) or a substring of the tab's URL; bl tab close defaults to the current tab when you omit the index.

A two-tab workflow

Open a reference tab alongside your main one, read from it, then return:

bl open https://app.example.com
bl tab new https://docs.example.com    # second tab, now current
bl text "h1"                           # read something from the docs
bl tab switch 0                        # back to the app
bl map                                 # carry on with the app

Refs are per-tab and per-state

@e1, @e2, … come from bl map on whichever tab was current at the time. After bl tab switch, the page underneath your refs has changed — run bl map again on the tab you switched to before acting on refs.

On this page