🧰 WebMCP
New page.webmcp and frame.webmcp give access to the tools that a page registers through
the experimental WebMCP browser API, so you can test them like
any other part of your app:
browser = chromium.launch(args=["--enable-features=WebMCP"])
page = browser.new_page()
page.goto("https://example.com")
for tool in page.webmcp.tools():
print(tool["name"], tool["description"])
result = page.webmcp.call_tool("add", {"a": 2, "b": 40})
print(result["content"][0]["text"]) # "42"Playwright MCP also supports WebMCP by default, with page-defined tools offered to the agent as webmcp_<tool>. Pass --no-webmcp to opt out.
playwright-cli exposes them as well:
playwright-cli webmcp-list
playwright-cli webmcp-call search_catalog --params '{"query":"cats"}'🎬 Better videos
Videos can now be recorded at a custom frame rate, and the decorations for actions are styled with plain CSS:
page.screencast.start(path="video.webm", size={"width": 1920, "height": 1080}, fps=60)
page.screencast.show_actions(
style={
"point": "width: 20px; height: 20px; border-radius: 50%; background: red",
"highlight": "outline: 2px solid #333; background: rgba(0, 128, 255, .15)",
"title": "font-size: 16px",
}
)- New
record_video_fpsoption and newfpsoption in
screencast.start(). Firefox and WebKit currently capture up to 25 frames per second. - New
styleoption takes CSS declarations for thepointmarker, the target
highlightand the actiontitle. It replaces thefont_sizeoption, which is now deprecated. - The cursor stays visible at the last action point, survives navigations and travels along a natural, eased path.
- Videos are encoded with VP9 instead of VP8, which takes less CPU and produces smaller files of the same or better
quality. - All video options are also available in Playwright MCP and
playwright-cli.
🪆 Locator.within()
New locator.within() combines two locators that you already have, reading in the natural order —
"this button, within that dialog":
save_button = page.get_by_role("button", name="Save")
dialog = page.get_by_test_id("settings-dialog")
save_button.within(dialog).click()Relative locators such as locator.nth() or locator.first are resolved inside each parent
separately, which makes column-like queries straightforward:
# The third cell of every row, not the third cell in the table.
third_column = page.get_by_role("cell").nth(2).within(page.get_by_role("row"))
expect(third_column).to_have_text(["Apple", "Banana", "Cherry"])New APIs
-
New page.get_by_ref() locates an element by its aria ref, such as
e2, reported by page.aria_snapshot() in the"ai"mode. -
New option
include_shadowin page.content() and frame.content() serializes open shadow roots as declarative shadow DOM. -
New option
sign_countsets the initial signature counter of a virtual credential. credentials.create() and credentials.get() return the currentsign_count, and it is saved and restored together with the credentials in the storage state. -
New api_request_context.add_cookies(), api_request_context.cookies() and api_request_context.clear_cookies() manage cookies of a request context, mirroring the BrowserContext methods:
request.add_cookies( [{"name": "session-id", "value": "42", "url": "https://example.com"}] ) print(request.cookies("https://example.com")) request.clear_cookies(name="session-id")
Breaking Changes ⚠️
- Elements inside hidden iframes are considered hidden. Elements inside an iframe that is not visible, for example with
visibility: hidden, are now considered hidden by actions, locator.is_visible() and expect(locator).to_be_visible().
Browser Versions
- Chromium 156.0.8078.4
- Mozilla Firefox 157.0
- WebKit 27.2
This version was also tested against the following stable channels:
- Google Chrome 155
- Microsoft Edge 155