-
Hand the tab to the user with
handoff(): for a step only the user can do, like a sign-in, a 2FA code, a captcha or a phone approval.handoffshows a Playwriter card in the tab without stealing focus and returns a link for the chat. Opening the link brings the tab to the front and scrolls to the step.const { link } = await handoff({ page: state.page, message: 'Sign in to Discord with your own account.' }) await handoff({ page: state.page, message: 'Enter the 6-digit code.', target: state.page.locator('#otp') }) // rings the field await handoff({ page: state.page, message: 'Approve the sign-in on your phone.', manual: true }) // adds a Done button await waitForHandoff({ page: state.page, until: /\/channels\/@me/ }) // URL RegExp, or a function run in the page await waitForHandoff({ page: state.page }) // manual: waits for Done await clearHandoff({ page: state.page }) // remove the card without waiting
The card shows one line saying what to do, in the top-right corner or beside a
targetelement with a ring around it. If the user closes the card with its X,waitForHandoffthrows so the agent can ask in chat. The card works on pages with a strict CSP and Trusted Types, lets clicks through, follows the system light or dark mode, and comes back after navigations until the handoff ends.Watch how it works: https://playwriter.dev/assets/handoff-explainer.mp4
-
releasePage({ page })hands a tab back to the user without closing it: the tab stays open, Playwriter detaches the debugger from it and takes it out of the tab group, and no session can see it anymore. Chrome hides the "started debugging this browser" banner once no tab is attached. For Playwright the page is closed. It is a global inexecuteand an export of theplaywriterpackage:import { releasePage } from 'playwriter' await releasePage({ page })
Needs extension 0.0.180 or newer. With an older extension
releasePagethrows and the tab stays attached. -
Authorization: Bearer <token>on the/cdpWebSocket: withplaywriter serve --token, the/cdpWebSocket only read the token from?token=, where other local users can read it withps. The relay now also accepts the header, like the HTTP routes do.?token=keeps working, and a traforo tunnel still needs it.const browser = await chromium.connectOverCDP('ws://127.0.0.1:19988/cdp/session1', { headers: { Authorization: `Bearer ${process.env.PLAYWRITER_TOKEN}` }, })
-
Agents use headless Chrome only when the user asks: the skill, the CLI
--browserhelp and the MCPsession_newdescription say this. The skill also says to never use headless on live production sites like x.com, Google or Reddit unless asked. -
Attach Playwriter's own pages with an icon click: extension 0.0.175 blocked every
chrome-extension://page, so a click on the welcome or tutorial page did nothing. Now a user click attaches the tab. Agents still cannot open or navigate to these pages, and automatic attach paths (popups, tabs dragged into a Playwriter group) still skip them. Remote control peers cannot send commands to a tab attached this way. -
Tabs attach reliably when another extension's iframe is still loading: pages with iframes from extensions like LastPass or 1Password could fail to attach with "Cannot access a chrome-extension:// URL of different extension". The extension now removes these iframes before every attach attempt, not only after a failed attach.
-
The extension no longer keeps Chrome busy when pages change their title: every tab update made the extension set the icon, title and badge of every open tab again. With 20 tabs that update their title every second, Chrome used about 1.5 CPU cores and attaching a new tab could time out. Now only the tabs whose state changed are updated. Icons, titles and badges look the same as before.
-
editor.edit()writesnewStringas is: anewStringwith$$,$&,$`or$'was rewritten.$$('a')became$('a')and$&became the replaced text.
Thanks @colinhacks for #145 and @bardrop for #148!