Docs/Start and manage a browser session
#

Start and manage a browser session

Drive a real browser from the CLI to explore or verify a web app. You work through snapshots (an accessibility tree plus a screenshot) and issue commands against element refs.

Feedback. Tell Cofactor the moment a step in this guide is wrong, unclear or missing; a command fails in a way the guide did not predict; you took a detour or had to guess; or a tool you needed does not exist. Send it when it happens, not only at the end: one sentence on what happened and what would have helped. Run cofactor feedback "<what happened; what would have helped>" --topic instructions --command "cofactor session guide <section>", or call the cofactor_feedback_submit MCP tool with the same text, topic and command. Never include secrets, customer data, real names or URLs; use neutral examples (Acme, example.com).

Start a session

bash
cofactor session start --url https://app.example.com
cofactor session start --credential                       # (interactive picker)
cofactor session start --credential "Admin User" --url https://app.example.com
cofactor session start --storage-state ./auth.json --url <url>
cofactor session start --headless --url <url>

Credentials belong to an application and carry saved login state, so a session started with --credential is already signed in. Load one into a running session with cofactor session load-credential.

Credentials only work for the deployed app they were saved against. Their cookies are bound to that domain. For localhost or 127.0.0.1, start without --credential, ask the user to sign in in the browser window, and wait for them to confirm before continuing (or pass --storage-state with a local file).

Manage sessions

bash
cofactor session list
cofactor session status
cofactor session stop            # (or: stop --all)
cofactor session snapshot --session s1     # (target one when several exist)

Always stop sessions you started when you finish.

Inside an ADE session

In an ADE (cofactor dev) the browser does not run on the editor. session start opens it inside your paired app copy, next to the app it tests, so bring the copy up first and sync it after you edit (cofactor dev app up, cofactor dev app sync; cofactor dev app url prints its address).

bash
cofactor session start                         # logged out, on the copy's first page
cofactor session start --persona admin         # signed in as a persona the app's sandbox config declares
cofactor session navigate --url <url from `cofactor dev app url`>
cofactor session snapshot
cofactor session click --ref <ref>
cofactor session stop                          # prints a link to the recording

Every other command works as above. What differs:

  • There is one browser per ADE session, confined to the copy's own addresses.
  • It records video; session stop prints the link.
  • session start refuses, with no local browser instead, when the copy cannot host one. Run cofactor dev app down, then cofactor dev app up, to rebuild it.
  • Sign in with --persona. These are not available: --credential, --storage-state, --headless, --url, --cloud-relay, $CREDENTIAL placeholders, load-credential, save-credential, take-control, resume-cloud, call-recipe, upload, downloads, read-download and pdf.
  • The browser ends with cofactor dev app down, when the ADE session ends, or after 15 minutes without a command. After the copy is replaced, start again.

The loop

text
snapshot -> read -> act -> snapshot -> verify

Never assume an action worked; look at the page afterwards. Run cofactor session --help for the full command list.

Hand the exploring to an agent

To have a Cofactor agent explore an application from a prompt and report what it finds, instead of driving the browser yourself, read cofactor exploratory-test guide.

Safety

Sign in with a $CREDENTIAL placeholder or cofactor session load-credential (see the sign-in section). Never print or type a real password or token into the page or the transcript.