Skip to main content

Sessions, Tabs & Frames

Sessions

BAP browser pages persist across CLI invocations. When a client disconnects, the server parks the browser context. On reconnect with the same session ID, state is restored.

Named Sessions

Use the -s flag to create and reuse named sessions:
bap -s=checkout goto https://shop.example.com
bap -s=checkout act fill:label:"Search"="headphones" press:Enter
bap -s=checkout screenshot
All three commands operate on the same browser session. Without -s, the default session ID is cli-<port> (e.g., cli-9222).

List Sessions

bap sessions
Shows all active sessions with page counts.
-s
string
Named session identifier. Commands with the same -s value share a browser context.
Dormant sessions expire after 5 minutes (300 seconds) by default. After expiry, a new browser context is created on next use.

Tabs

List Open Tabs

bap tabs

Open a New Tab

bap tab-new
bap tab-new https://example.com

Switch to a Tab

bap tab-select 2
index
number
required
Tab index (1-based) from the bap tabs output.

Close a Tab

bap tab-close
Closes the currently active tab.

Frames

For pages with iframes, use frame commands to switch context.

List Frames

bap frames
Shows all frames in the current page with their IDs.

Switch to a Frame

bap frame-switch <id>
id
string
required
Frame ID from the bap frames output.
After switching, all subsequent commands (click, fill, observe, etc.) operate within the selected frame.
After switching to a frame, remember to switch back to the main frame when done. Use bap frames to see available frames and their IDs.

Multi-Session Workflows

Run parallel workflows in separate sessions:
# Terminal 1: Shopping flow
bap -s=shop goto https://shop.example.com

# Terminal 2: Admin panel
bap -s=admin goto https://admin.example.com

# Each session has its own browser context, cookies, and state