1234567891011121314# 1. Create a session playwriter session new # outputs: 1 # 2. Navigate playwriter -s 1 -e "state.page = context.pages().find(p => p.url() === 'about:blank') ?? await context.newPage(); await state.page.goto('https://example.com')" # 3. Observe (snapshot to see interactive elements) playwriter -s 1 -e "snapshot({ page: state.page })" # 4. Act (use locators from the snapshot) playwriter -s 1 -e "await state.page.locator('role=link[name=\"More information...\"]').click()" # 5. Observe again (verify the action worked) playwriter -s 1 -e "console.log('URL:', state.page.url()); console.log(await snapshot({ page: state.page })); console.log(await getLatestLogs({ page: state.page, sinceLastCall: true }))"
1npm install -g playwriter
1npx playwriter@latest session new
1npx -y skills add remorses/playwriter
1234567891011121314# Create a new session playwriter session new # Navigate to a page playwriter -s 1 -e "state.page = context.pages().find(p => p.url() === 'about:blank') ?? await context.newPage(); await state.page.goto('https://example.com')" # Get an accessibility snapshot playwriter -s 1 -e "snapshot({ page: state.page })" # Click a link using the locator from the snapshot playwriter -s 1 -e "await state.page.locator('role=link[name=\"More information...\"]').click()" # Take a screenshot playwriter -s 1 -e "await state.page.screenshot({ path: './example.png', scale: 'css' })"
12345678{ "mcpServers": { "playwriter": { "command": "npx", "args": ["-y", "playwriter@latest"] } } }
execute tool that accepts any Playwright code. Your agent sends JavaScript and gets back the result, snapshots, and screenshots automatically.12345678# Download Chrome for Testing (first time only) playwriter browser install # Create a session with headless Chrome playwriter session new --browser headless # Use it normally playwriter -s 1 -e "state.page = await context.newPage(); await state.page.goto('https://example.com')"
1playwriter session new --direct