Browser automation with Playwright CLI and Azure Playwright Service
This skill is the operational reference for browser tasks. The base prompt owns the non-negotiable lifecycle rules; this skill provides the concrete Playwright CLI command patterns.
Remote browser connection
Reuse an active browser session for follow-up browser work in the same hosted agent session whenever one is available. If no active browser is available, call
create_sessionwith no arguments.After
create_sessionreturns, callget_live_view_url. The server injects the URL directly into the response — do NOT repeat or output it yourself. Do not include the raw CDP URL in user-facing text.Call
run_playwright_cliwithsessionId='browser'and the command:open about:blankThe CDP URL is injected automatically by the server -- do NOT pass it. This must be a standalone handshake command. Do not combine it with target navigation,
eval,snapshot, or any other browser operation.Run all subsequent commands with the same
sessionId(browser):goto https://example.com snapshotUse
goto <url>for target navigation after the handshake; do not useopen <url>for normal page navigation. If a follow-up command says the local session is not open, reconnect withcommand: open about:blank. Do not callcreate_sessionfor this recovery.Keep the browser session open after successful work so follow-up tasks can continue in the same live browser. Call
close_browser_sessiononly when the user explicitly asks to close the browser, when the session is unusable, or before replacing it with a fresh remote browser.
If the initial open about:blank command fails, do not retry repeatedly. Call
close_browser_session, then call create_session again to create a fresh
remote browser.
Common commands
Pass only the arguments shown below to run_playwright_cli.command; do not
include playwright-cli or -s=<sessionId>.
# Navigation
open about:blank
goto https://playwright.dev
go-back
go-forward
reload
# Page state
snapshot
screenshot
# Interactions
click e3
dblclick e7
fill e5 "user@example.com"
fill e5 "search text" --submit
type "search query"
press Enter
hover e4
select e9 "option-value"
check e12
uncheck e12
# Date/calendar fields - use fill with the value format the field expects
fill e8 "2026-06-15"
fill e8 "06/15/2026"
# Tabs
tab-list
tab-new https://example.com/other
tab-select 0
tab-close
# Extraction and diagnostics
eval "document.title"
eval "JSON.stringify([...document.querySelectorAll('a')].map(a => a.href))"
console
After most commands, Playwright CLI emits page status and a snapshot. Use refs
from the snapshot, such as e15, for subsequent interactions.
Cleanup
Do not close a healthy remote browser at the end of a normal task. When the user
asks to close the browser, or when replacing a broken session, call
close_browser_session with just sessionId='browser'.