NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #275 most downloaded on PyPI
A high-level API to automate web browsers
Last release 19 days ago
15 Sep 2026
Ships fairly regularly
a new release about every 6 weeks
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
6 years old
85 releases · first in 2021
One column per quarter.
page.frame_locator() and frame.frame_locator() called without a selector search in any frame of the subtree, so you no longer need to locate the ifram
page.frame_locator() and frame.frame_locator() called without a selector search in any frame of the
subtree, so you no longer need to locate the iframe first:
# Finds the button in any frame on the page.
page.frame_locator().get_by_role("button").click()The rest of the locator resolves inside a single frame, just like a regular locator, and an error is thrown when it
matches elements in several frames.
New locator.visible returns a locator that matches only visible elements. It is the recommended
replacement for the :visible CSS pseudo-class:
page.locator("button").visible.click()New aria_snapshots and screen_snapshots options of
tracing.start() capture an aria snapshot and a screenshot of the page on every action:
context.tracing.start(snapshots=True, aria_snapshots=True, screen_snapshots=True)With aria and screen snapshots recorded, the new Display Aria mode in the trace viewer shows the action screenshot
side by side with the aria snapshot, and hovering an aria node highlights it on the screenshot.
http_credentials now also accepts an array of credentials. The first entry matching the request origin is used, and entries without an origin match any request.opfs includes the origin private file system in the storage state, so it can be persisted and restored into later contexts.playwright install --no-remove keeps the browsers of other Playwright installations instead of removing them.playwright codegen --http-credentials records against pages behind HTTP authentication.This version was also tested against the following stable channels:
page.screenshot() and locator.screenshot() can now capture screenshots in the WebP format. Playwright infers the format from a .webp file extension, o
page.screenshot() and locator.screenshot() can now capture screenshots in the WebP format. Playwright infers the format from a .webp file extension, or you can set the type explicitly. Quality 100 (the default) is lossless, while lower values use lossy compression:
page.screenshot(path="homepage.webp", quality=50)scroll option ("auto" | "none") on actions to opt out of Playwright's automatic scrolling into view.navigator.clipboard no longer read or overwrite the clipboard of the machine running them.This version was also tested against the following stable channels:
New Credentials virtual authenticator, available via browserContext.credentials , lets tests register passkeys and answer navigator.credentials.create
New Credentials virtual authenticator, available via browserContext.credentials, lets tests register passkeys and answer navigator.credentials.create() / navigator.credentials.get() ceremonies in the page — no real hardware key required, works in all browsers:
context = browser.new_context()
# Seed a passkey your backend provisioned for a test user.
context.credentials.create("example.com",
id=credential_id,
user_handle=user_handle,
private_key=private_key,
public_key=public_key,
)
context.credentials.install()
page = context.new_page()
page.goto("https://example.com/login")
# The page's navigator.credentials.get() is answered with the seeded passkey.You can also let the app register a passkey once in a setup test, read it back with credentials.get(), and seed it into later tests — see Credentials for details.
New WebStorage API, available via page.localStorage and page.sessionStorage, reads and writes the page's storage for the current origin:
page.local_storage.set_item("token", "abc")
token = page.local_storage.get_item("token")
items = page.session_storage.items()artifacts_dir in browserType.connect_over_cdp() controls where artifacts such as traces and downloads are stored when attached to an existing browser.cursor in screencast.show_actions() controls the cursor decoration rendered for pointer actions.on_frame callback in screencast.start() now receives a timestamp of when the frame was presented by the browser.This version was also tested against the following stable channels:
console_message.location() now exposes line / column properties ( line_number / column_number are deprecated).
timeout parameters now accept datetime.timedelta — applies wherever a timeout is taken, e.g. page.goto(), locator.click(), expect(...).to_be_visible().async with now works for objects returned from screencast.show_actions(), screencast.show_overlays(), etc.tracing.start_har() / tracing.stop_har() expose HAR recording as a first-class tracing API, with the same content, mode and url_filter options as record_har:
context.tracing.start_har("trace.har")
page = context.new_page()
page.goto("https://playwright.dev")
context.tracing.stop_har()New locator.drop() simulates an external drag-and-drop of files or clipboard-like data onto an element. Playwright dispatches dragenter, dragover, and drop with a synthetic DataTransfer in the page context — works cross-browser and is great for testing upload zones:
page.locator("#dropzone").drop(
files={"name": "note.txt", "mime_type": "text/plain", "buffer": b"hello"},
)
page.locator("#dropzone").drop(
data={
"text/plain": "hello world",
"text/uri-list": "https://example.com",
},
)page.locator("body").boxes option on locator.aria_snapshot() / page.aria_snapshot() appends each element's bounding box as [box=x,y,width,height], useful for AI consumption.description in page.get_by_role() / locator.get_by_role() / frame.get_by_role() / frame_locator.get_by_role() for matching the accessible description.pseudo in expect(locator).to_have_css() reads computed styles from ::before or ::after.style in locator.highlight() applies extra inline CSS to the highlight overlay, plus new page.hide_highlight() to clear all highlights.no_defaults in browser_type.connect_over_cdp() disables Playwright's default overrides on the default context (download behavior, focus emulation, media emulation), so attaching to a user's daily-driver browser doesn't disturb its state.line / column properties (line_number / column_number are deprecated).handle option on browser_context.expose_binding() and page.expose_binding().This version was also tested against the following stable channels:
New page.screencast API provides a unified interface for capturing page content with:
New page.screencast API provides a unified interface for capturing page content with:
Screencast recording — record video with precise start/stop control, as an alternative to the recordVideoDir option:
page.screencast.start(path="video.webm")
# ... perform actions ...
page.screencast.stop()Action annotations — enable built-in visual annotations that highlight interacted elements and display action titles during recording:
page.screencast.show_actions(position="top-right")screencast.show_actions() accepts position ('top-left', 'top', 'top-right', 'bottom-left', 'bottom', 'bottom-right'), duration (ms per annotation), and font_size (px). Returns a disposable to stop showing actions.
Visual overlays — add chapter titles and custom HTML overlays on top of the page for richer narration:
page.screencast.show_chapter("Adding TODOs",
description="Type and press enter for each TODO",
duration=1000,
)
page.screencast.show_overlay('<div style="color: red">Recording</div>')Real-time frame capture — stream JPEG-encoded frames for custom processing like thumbnails, live previews, AI vision, and more:
page.screencast.start(
on_frame=lambda frame: send_to_vision_model(frame["data"]),
)Agentic video receipts — coding agents can produce video evidence of their work. After completing a task, an agent can record a walkthrough video with rich annotations for human review:
page.screencast.start(path="receipt.webm")
page.screencast.show_actions(position="top-right")
page.screencast.show_chapter("Verifying checkout flow",
description="Added coupon code support per ticket #1234",
)
# Agent performs the verification steps...
page.locator("#coupon").fill("SAVE20")
page.locator("#apply-coupon").click()
expect(page.locator(".discount")).to_contain_text("20%")
page.screencast.show_chapter("Done",
description="Coupon applied, discount reflected in total",
)
page.screencast.stop()The resulting video serves as a receipt: chapter titles provide context, action annotations highlight each interaction, and the visual walkthrough is faster to review than text logs.
page.locator('body').aria_snapshot().depth and mode in locator.aria_snapshot().filter in page.console_messages() and page.page_errors() controls which messages are returned.live in tracing.start() for real-time trace updates.artifacts_dir in browser_type.launch() to configure the artifacts directory.New browser.bind() API makes a launched browser available for playwright-cli, @playwright/mcp, and other clients to connect to.
Bind a browser — start a browser and bind it so others can connect:
server_info = await browser.bind("my-session",
workspace_dir="/my/project",
)Connect from playwright-cli — connect to the running browser from your favorite coding agent.
playwright-cli attach my-session
playwright-cli -s my-session snapshotConnect from @playwright/mcp — or point your MCP server to the running browser.
@playwright/mcp --endpoint=my-sessionConnect from a Playwright client — use API to connect to the browser. Multiple clients at a time are supported!
browser = await chromium.connect(server_info["endpoint"])Pass host and port options to bind over WebSocket instead of a named pipe:
server_info = await browser.bind("my-session",
host="localhost",
port=0,
)
# server_info["endpoint"] is a ws:// URLCall browser.unbind() to stop accepting new connections.
Run playwright-cli show to open the Dashboard that lists all the bound browsers, their statuses, and allows interacting with them:
This version was also tested against the following stable channels:
New 'system' theme option follows your OS dark/light mode preference
Thanks to @cpAdm for contributing these improvements!
browser_type.connect_over_cdp() now accepts an is_local option. When set to True, it tells Playwright that it runs on the same host as the CDP server, enabling file system optimizations.
_react and _vue selectors. See locators guide for alternatives.:light selector engine suffix. Use standard CSS selectors instead.devtools from browser_type.launch() has been removed. Use args=['--auto-open-devtools-for-tabs'] instead.This version was also tested against the following stable channels:
After 3 years of being deprecated, we removed page.accessibility from our API. Please use other libraries such as Axe if you need to test page accessi…
Starting with this release, Playwright switches from Chromium, to using Chrome for Testing builds. Both headed and headless browsers are subject to this. Your tests should still be passing after upgrading to Playwright 1.57.
We're expecting no functional changes to come from this switch. The biggest change is the new icon and title in your toolbar.
If you still see an unexpected behaviour change, please file an issue.
On Arm64 Linux, Playwright continues to use Chromium.
After 3 years of being deprecated, we removed page.accessibility from our API. Please use other libraries such as Axe if you need to test page accessibility. See our Node.js guide for integration with Axe.
steps in locator.click() and locator.drag_to() that configures the number of mousemove events emitted while moving the mouse pointer to the target element.PLAYWRIGHT_DISABLE_SERVICE_WORKER_NETWORK environment variable.PLAYWRIGHT_DISABLE_SERVICE_WORKER_CONSOLE environment variable.Event browserContext.on("backgroundpage") has been deprecated and will not be emitted. Method browserContext. background_pages() will return an empty…
input placeholderAutomatic to_be_visible() assertions: Codegen can now generate automatic to_be_visible() assertions for common UI interactions. This feature can be en
to_be_visible() assertions: Codegen can now generate automatic to_be_visible() assertions for common UI interactions. This feature can be enabled in the Codegen settings UI.This version was also tested against the following stable channels:
New cookie property partition_key in BrowserContext.cookies() and browserContext.add_cookies() . This property allows to save and restore partitioned
New cookie property partition_key in BrowserContext.cookies() and browserContext.add_cookies(). This property allows to save and restore partitioned cookies. See CHIPS MDN article for more information. Note that browsers have different support and defaults for cookie partitioning.
New option --user-data-dir in multiple commands. You can specify the same user data dir to reuse browsing state, like authentication, between sessions.
playwright codegen --user-data-dir=./user-dataplaywright open does not open the test recorder anymore. Use playwright codegen instead.
This version was also tested against the following stable channels:
New method locator.describe() to describe a locator. Used for trace viewer.
New method locator.describe() to describe a locator. Used for trace viewer.
button = page.get_by_test_id("btn-sub").describe("Subscribe button")
button.click()python -m playwright install --list will now list all installed browsers, versions and locations.
This version was also tested against the following stable channels:
macOS 13 is now deprecated and will no longer receive WebKit updates. Please upgrade to a more recent macOS version to continue benefiting from the la…
New method expect(locator).to_contain_class() to ergonomically assert individual class names on the element.
expect(page.get_by_role("listitem", name="Ship v1.52")).to_contain_class("done")
Aria Snapshots got two new properties: /children for strict matching and /url for links.
expect(locator).to_match_aria_snapshot("""
- list
- /children: equal
- listitem: Feature A
- listitem:
- link "Feature B":
- /url: "https://playwright.dev"
""")
max_redirects in apiRequest.new_context() to control the maximum number of redirects.ref in locator.aria_snapshot() to generate reference for each element in the snapshot which can later be used to locate the element.Cookie header anymore. If a Cookie header is provided, it will be ignored, and the cookie will be loaded from the browser's cookie store. To set custom cookies, use browserContext.add_cookies().This version was also tested against the following stable channels:
New option `indexed_db` for browserContext.storage_state() allows to save and restore IndexedDB contents. Useful when your application uses IndexedDB
New option indexed_db for browserContext.storage_state() allows to save and restore IndexedDB contents. Useful when your application uses IndexedDB API to store authentication tokens, like Firebase Authentication.
Here is an example following the authentication guide:
# Save storage state into the file. Make sure to include IndexedDB.
storage = context.storage_state(path="state.json", indexed_db=True)
# Create a new context with the saved storage state.
context = browser.new_context(storage_state="state.json")
New option visible for locator.filter() allows matching only visible elements.
# Ignore invisible todo items.
todo_items = page.get_by_test_id("todo-item").filter(visible=True)
# Check there are exactly 3 visible ones.
expect(todo_items).to_have_count(3)
New option contrast for methods page.emulate_media() and browser.new_context() allows to emulate the prefers-contrast media feature.
New option fail_on_status_code makes all fetch requests made through the APIRequestContext throw on response codes other than 2xx and 3xx.
This version was also tested against the following stable channels:
Playwright's Pytest plugin now has support for Async Fixtures.
canvas content in traces is error-prone. Display is now disabled by default, and can be enabled via the Display canvas content UI setting.Call and Network panels now display additional time information.<input>, <select>, or a number of other editable elements.This version was also tested against the following stable channels:
https://github.com/microsoft/playwright-python/issues/2679 - [Bug]: Warning: Validation of the RECORD file of playwright-1.49.0-py3-none-manylinux1_x8
https://github.com/microsoft/playwright-python/issues/2679 - [Bug]: Warning: Validation of the RECORD file of playwright-1.49.0-py3-none-manylinux1_x86_64.whl failed
This version was also tested against the following stable channels:
New assertion expect(locator).toMatchAriaSnapshot() verifies page structure by comparing to an expected accessibility tree, represented as YAML.
New assertion expect(locator).toMatchAriaSnapshot() verifies page structure by comparing to an expected accessibility tree, represented as YAML.
page.goto("https://playwright.dev")
expect(page.locator('body')).to_match_aria_snapshot('''
- banner:
- heading /Playwright enables reliable/ [level=1]
- link "Get started"
- link "Star microsoft/playwright on GitHub"
- main:
- img "Browsers (Chromium, Firefox, WebKit)"
- heading "Any browser • Any platform • One API"
''')
You can generate this assertion with Test Generator or by calling locator.ariaSnapshot().
Learn more in the aria snapshots guide.
New method tracing.group() allows you to visually group actions in the trace viewer.
# All actions between group and group_end
# will be shown in the trace viewer as a group.
page.context.tracing.group("Open Playwright.dev > API")
page.goto("https://playwright.dev/")
page.get_by_role("link", name="API").click()
page.context.tracing.group_end()
chrome and msedge channels switch to new headless modeThis change affects you if you're using one of the following channels in your playwright.config.ts:
chrome, chrome-dev, chrome-beta, or chrome-canarymsedge, msedge-dev, msedge-beta, or msedge-canaryAfter updating to Playwright v1.49, run your test suite. If it still passes, you're good to go. If not, you will probably need to update your snapshots, and adapt some of your test code around PDF viewers and extensions. See issue #33566 for more details.
You can opt into the new headless mode by using 'chromium' channel. As official Chrome documentation puts it:
New Headless on the other hand is the real Chrome browser, and is thus more authentic, reliable, and offers more features. This makes it more suitable for high-accuracy end-to-end web app testing or browser extension testing.
See issue #33566 for the list of possible breakages you could encounter and more details on Chromium headless. Please file an issue if you see any problems after opting in.
pytest test_login.py --browser-channel chromium
<canvas> elements inside a snapshot now draw a preview.This version was also tested against the following stable channels:
New methods page.route_web_socket() and browser_context.route_web_socket() allow to intercept, modify and mock WebSocket connections initiated in the
New methods page.route_web_socket() and browser_context.route_web_socket() allow to intercept, modify and mock WebSocket connections initiated in the page. Below is a simple example that mocks WebSocket communication by responding to a "request" with a "response".
def message_handler(ws: WebSocketRoute, message: Union[str, bytes]):
if message == "request":
ws.send("response")
page.route_web_socket("/ws", lambda ws: ws.on_message(
lambda message: message_handler(ws, message)
))
See WebSocketRoute for more details.
This version was also tested against the following stable channels:
no_wait_after in locator.selectOption() was deprecated.
The Network tab in the trace viewer has several nice improvements:
mcr.microsoft.com/playwright-python:v1.47.0 now serves a Playwright image based on Ubuntu 24.04 Noble.
To use the 22.04 jammy-based image, please use mcr.microsoft.com/playwright-python:v1.47.0-jammy instead.:latest/:focal/:jammy tag for Playwright Docker images is no longer being published. Pin to a specific version for better stability and reproducibility.cert and key as bytes instead of file paths.no_wait_after in locator.selectOption() was deprecated.macos-13. We recommend upgrading GitHub Actions to macos-14.This version was also tested against the following stable channels:
Playwright now allows to supply client-side certificates, so that server can verify them, as specified by TLS Client Authentication.
Playwright now allows to supply client-side certificates, so that server can verify them, as specified by TLS Client Authentication.
You can provide client certificates as a parameter of browser.new_context() and api_request.new_context(). The following snippet sets up a client certificate for https://example.com:
context = browser.new_context(
client_certificates=[
{
"origin": "https://example.com",
"certPath": "client-certificates/cert.pem",
"keyPath": "client-certificates/key.pem",
}
],
)
When using the Pytest plugin, it can be added like this:
@pytest.fixture(scope="session")
def browser_context_args(browser_context_args):
return {
**browser_context_args,
"client_certificates": [
{
"origin": "https://example.com",
"certPath": "client-certificates/cert.pem",
"keyPath": "client-certificates/key.pem",
}
],
}
base_url.max_retries option in apiRequestContext.fetch() which retries on the ECONNRESET network error.This version was also tested against the following stable channels:
https://github.com/microsoft/playwright-java/issues/1617 - [Bug]: Trace Viewer not reporting all actions https://github.com/microsoft/playwright/issue
https://github.com/microsoft/playwright-java/issues/1617 - [Bug]: Trace Viewer not reporting all actions https://github.com/microsoft/playwright/issues/31764 - [Bug]: some actions do not appear in the trace file
This version was also tested against the following stable channels:
Utilizing the new Clock API allows to manipulate and control time within tests to verify time-related behavior. This API covers many common scenarios,
Utilizing the new Clock API allows to manipulate and control time within tests to verify time-related behavior. This API covers many common scenarios, including:
# Initialize clock with some time before the test time and let the page load
# naturally. `Date.now` will progress as the timers fire.
page.clock.install(time=datetime.datetime(2024, 2, 2, 8, 0, 0))
page.goto("http://localhost:3333")
# Pretend that the user closed the laptop lid and opened it again at 10am.
# Pause the time once reached that point.
page.clock.pause_at(datetime.datetime(2024, 2, 2, 10, 0, 0))
# Assert the page state.
expect(page.get_by_test_id("current-time")).to_have_text("2/2/2024, 10:00:00 AM")
# Close the laptop lid again and open it at 10:30am.
page.clock.fast_forward("30:00")
expect(page.get_by_test_id("current-time")).to_have_text("2/2/2024, 10:30:00 AM")
See the clock guide for more details.
<input type=file webkitdirectory> elements.page.get_by_label("Upload directory").set_input_files('mydir')
ControlOrMeta modifier key. This key maps to Meta on macOS and maps to Control on Windows and Linux.# Press the common keyboard shortcut Control+S or Meta+S to trigger a "Save" operation.
page.keyboard.press("ControlOrMeta+S")
httpCredentials.send in apiRequest.newContext() that allows to either always send the Authorization header or only send it in response to 401 Unauthorized.This version was also tested against the following stable channels:
expect(locator).to_have_accessible_name() checks if the element has the specified accessible name:
Accessibility assertions
expect(locator).to_have_accessible_name() checks if the element has the specified accessible name:
locator = page.get_by_role("button")
expect(locator).to_have_accessible_name("Submit")
expect(locator).to_have_accessible_description() checks if the element has the specified accessible description:
locator = page.get_by_role("button")
expect(locator).to_have_accessible_description("Upload a photo")
expect(locator).to_have_role() checks if the element has the specified ARIA role:
locator = page.get_by_test_id("save-button")
expect(locator).to_have_role("button")
Locator handler
no_wait_after option.times option in page.add_locator_handler() to specify maximum number of times the handler should be run.locator = page.get_by_text("This interstitial covers the button")
page.add_locator_handler(locator, lambda overlay: overlay.locator("#close").click(), times=3, no_wait_after=True)
# Run your tests that can be interrupted by the overlay.
# ...
page.remove_locator_handler(locator)
Miscellaneous options
ignore_case option.This version was also tested against the following stable channels:
Method [BrowserContext.clear_cookies([options])](https://playwright.dev/python/docs/api/class-browsercontext#browser-context-clear-cookies) now suppor
Method BrowserContext.clear_cookies([options]) now supports filters to remove only some cookies.
# Clear all cookies.
context.clear_cookies()
# New: clear cookies with a particular name.
context.clear_cookies(name="session-id")
# New: clear cookies for a particular domain.
context.clear_cookies(domain="my-origin.com")
New method locator.content_frame converts a {@link Locator} object to a FrameLocator. This can be useful when you have a Locator object obtained somewhere, and later on would like to interact with the content inside the frame.
locator = page.locator("iframe[name='embedded']")
# ...
frame_locator = locator.content_frame
frame_locator.getByRole("button").click()
New method frameLocator.owner converts a FrameLocator object to a Locator. This can be useful when you have a FrameLocator object obtained somewhere, and later on would like to interact with the iframe element.
frame_locator = page.frame_locator("iframe[name='embedded']")
# ...
locator = frame_locator.owner
expect(locator).to_be_visible()
Conda builds are now published for macOS-arm64 and Linux-arm64.
This version was also tested against the following stable channels:
New method page.add_locator_handler(locator, handler) registers a callback that will be invoked when specified element becomes visible and may block P
New method page.add_locator_handler(locator, handler) registers a callback that will be invoked when specified element becomes visible and may block Playwright actions. The callback can get rid of the overlay. Here is an example that closes a cookie dialog when it appears.
# Setup the handler.
page.add_locator_handler(
page.get_by_role("heading", name="Hej! You are in control of your cookies."),
lambda: page.get_by_role("button", name="Accept all").click(),
)
# Write the test as usual.
page.goto("https://www.ikea.com/")
page.get_by_role("link", name="Collection of blue and white").click()
expect(page.get_by_role("heading", name="Light and easy")).to_be_visible()
tagged and outline.This version was also tested against the following stable channels:
https://github.com/microsoft/playwright-python/issues/2258 - [REGRESSION] Failing step is not highlighted in red in actions panel for versions after 1
https://github.com/microsoft/playwright-python/issues/2258 - [REGRESSION] Failing step is not highlighted in red in actions panel for versions after 1.39.0 https://github.com/microsoft/playwright/issues/29123 - [REGRESSION] route.continue: Protocol error (Fetch.continueRequest): Invalid InterceptionId.
This version was also tested against the following stable channels:
https://github.com/microsoft/playwright/issues/29067 - [REGRESSION] Codegen/Recorder: not all clicks are being actioned nor recorded https://github.co
https://github.com/microsoft/playwright/issues/29067 - [REGRESSION] Codegen/Recorder: not all clicks are being actioned nor recorded https://github.com/microsoft/playwright/issues/29019 - [REGRESSION] trace.playwright.dev does not currently support the loading from URL
This version was also tested against the following stable channels:
New method page.unroute_all() removes all routes registered by page.route() and page.route_from_har(). Optionally allows to wait for ongoing routes to
style in page.screenshot() and locator.screenshot() to add custom CSS to the page before taking a screenshot.This version was also tested against the following stable channels:
New tools to generate assertions:
New tools to generate assertions:
Here is an example of a generated test with assertions:
from playwright.sync_api import Page, expect
def test_example(page: Page) -> None:
page.goto("https://playwright.dev/")
page.get_by_role("link", name="Get started").click()
expect(page.get_by_label("Breadcrumbs").get_by_role("list")).to_contain_text("Installation")
expect(page.get_by_label("Search")).to_be_visible()
page.get_by_label("Search").click()
page.get_by_placeholder("Search docs").fill("locator")
expect(page.get_by_placeholder("Search docs")).to_have_value("locator");
reason in page.close([options]), browserContext.close([options]) and browser.close([options]). Close reason is reported for all operations interrupted by the closure.firefox_user_prefs in browserType.launch_persistent_context(userDataDir[, options]).This version was also tested against the following stable channels:
This version was also tested against the following stable channels:
Python 3.12 support.
This version was also tested against the following stable channels:
The following methods were deprecated: [page.type()], [frame.type()], [locator.type()] and [elementHandle.type()]. Please use [locator.fill()] instead…
page.type(), frame.type(), locator.type() and elementHandle.type().
Please use locator.fill() instead which is much faster. Use locator.press_sequentially() only if there is a
special keyboard handling on the page, and you need to press keys one-by-one.This version was also tested against the following stable channels:
New --full-page-screenshot command line flag allows taking a full page screenshot on failure.
New --full-page-screenshot command line flag allows taking a full page screenshot on failure.
It is now possible to override the context options for a single test by using the browser_context_args marker.
pytest-playwright is now also getting published on Anaconda
Playwright now supports Debian 12 Bookworm on both x86_64 and arm64 for Chromium, Firefox and WebKit. Let us know if you encounter any issues!
Linux support looks like this:
| Ubuntu 20.04 | Ubuntu 22.04 | Debian 11 | Debian 12 | |
|---|---|---|---|---|
| Chromium | ✅ | ✅ | ✅ | ✅ |
| WebKit | ✅ | ✅ | ✅ | ✅ |
| Firefox | ✅ | ✅ | ✅ | ✅ |
This version was also tested against the following stable channels:
This version was also tested against the following stable channels:
🏝️ Summer maintenance release.
This version was also tested against the following stable channels:
New option mask_color for methods `Page.screenshot()` and `Locator.screenshot()` to change default masking color.
New option mask_color for methods Page.screenshot() and Locator.screenshot() to change default masking color.
New uninstall CLI command to uninstall browser binaries:
$ playwright uninstall # remove browsers installed by this installation
$ playwright uninstall --all # remove all ever-install Playwright browsers
This version was also tested against the following stable channels:
New `Locator.and_` to create a locator that matches both locators.
New Locator.and_ to create a locator that matches both locators.
button = page.get_by_role("button").and_(page.get_by_title("Subscribe"))
Its now possible to set a global expect timeout and change the 5 second default:
from playwright.sync_api import expect
expect.set_options(timeout=10_000)
New events BrowserContext.on("console") and BrowserContext.on("dialog") to subscribe to any dialogs
and console messages from any page from the given browser context. Use the new properties ConsoleMessage.page
and Dialog.page to pin-point event source.
This version was also tested against the following stable channels:
Use `Locator.or_` to create a locator that matches either of the two locators. Consider a scenario where you'd like to click on a "New email" button,
Use Locator.or_ to create a locator that matches either of the two locators.
Consider a scenario where you'd like to click on a "New email" button, but sometimes a security settings dialog shows up instead.
In this case, you can wait for either a "New email" button, or a dialog and act accordingly:
new_email = page.get_by_role("button", name="New email")
dialog = page.get_by_text("Confirm security settings")
expect(new_email.or_(dialog)).is_visible()
if (dialog.is_visible())
page.get_by_role("button", name="Dismiss").click()
new_email.click()
Use new options has_not and has_not_text in Locator.filter
to find elements that do not match certain conditions.
row_locator = page.locator("tr")
row_locator
.filter(has_not_text="text in column 1")
.filter(has_not=page.get_by_role("button", name="column 2 button"))
.screenshot()
Use new web-first assertion expect(locator).to_be_attached() to ensure that the element
is present in the page's DOM. Do not confuse with the expect(locator).to_be_visible() that ensures that
element is both attached & visible.
Locator.orhas_not in Locator.filterhas_not_text in Locator.filterexpect(locator).to_be_attachedtimeout in method: Route.fetchmcr.microsoft.com/playwright/python:v1.33.0 now serves a Playwright image based on Ubuntu Jammy.
To use the focal-based image, please use mcr.microsoft.com/playwright/python:v1.33.0-focal instead.This version was also tested against the following stable channels:
[BUG]: fix: discard trace without path did not work in https://github.com/microsoft/playwright-python/pull/1836
Custom expect message, see test assertions documentation.
update_mode and update_content in page.route_from_har() and browser_context.route_from_har().name in method tracing.start_chunk().This version was also tested against the following stable channels:
https://github.com/microsoft/playwright/issues/21093 - [Regression v1.31] Headless Windows shows cascading cmd windows
https://github.com/microsoft/playwright/issues/21093 - [Regression v1.31] Headless Windows shows cascading cmd windows
This version was also tested against the following stable channels:
New assertion `expect(locator).to_be_in_viewport()` ensures that locator points to an element that intersects viewport, according to the intersection
New assertion expect(locator).to_be_in_viewport() ensures that locator points to an element that intersects viewport, according to the intersection observer API.
from playwright.sync_api import expect
locator = page.get_by_role("button")
# Make sure at least some part of element intersects viewport.
expect(locator).to_be_in_viewport()
# Make sure element is fully outside of viewport.
expect(locator).not_to_be_in_viewport()
# Make sure that at least half of the element intersects viewport.
expect(locator).to_be_in_viewport(ratio=0.5)
max_redirects for method Route.fetch.This version was also tested against the following stable channels:
Maintenance release with bugfixes and new browsers only.
Maintenance release with bugfixes and new browsers only.
This version was also tested against the following stable channels:
fix: fulfill with json in https://github.com/microsoft/playwright-python/pull/1701
New method `Route.fetch` and new option json for `Route.fulfill`:
New method Route.fetch and new option json for Route.fulfill:
def handle_route(route: Route):
# Fetch original settings.
response = route.fetch()
# Force settings theme to a predefined value.
json = response.json()
json["theme"] = "Solorized"
# Fulfill with modified data.
route.fulfill(json=json)
page.route("**/api/settings", handle_route)
New method Locator.all to iterate over all matching elements:
# Check all checkboxes!
checkboxes = page.get_by_role("checkbox")
for checkbox in checkboxes.all():
checkbox.check()
Locator.select_option matches now by value or label:
<select multiple>
<option value="red">Red</div>
<option value="green">Green</div>
<option value="blue">Blue</div>
</select>
element.select_option("Red")
postData in method Route.continue now supports any values.This version was also tested against the following stable channels:
Live Locators in CodeGen. Generate a locator for any element on the page using "Explore" tool.
This version was also tested against the following stable channels:
This patch release includes the following bug fixes:
This patch release includes the following bug fixes:
https://github.com/microsoft/playwright/pull/18010 - fix(generator): generate nice locators for arbitrary selectors https://github.com/microsoft/playwright/pull/17952 - fix: fix typo in treeitem role typing
This version was also tested against the following stable channels:
With these new APIs, inspired by Testing Library, writing locators is a joy:
With these new APIs, inspired by Testing Library, writing locators is a joy:
page.get_by_text(text) to locate by text content.page.get_by_role(role) to locate by ARIA role, ARIA attributes and accessible name.page.get_by_label(label) to locate a form control by associated label's text.page.get_by_placeholder(placeholder) to locate an input by placeholder.page.get_by_alt_text(altText) to locate an element, usually image, by its text alternative.page.get_by_title(title) to locate an element by its title.page.get_by_label("User Name").fill("John")
page.get_by_label("Password").fill("secret-password")
page.get_by_role("button", name="Sign in").click()
expect(page.get_by_text("Welcome, John!")).to_be_visible()
All the same methods are also available on Locator, FrameLocator and Frame classes.
expect(locator).to_have_attribute(name, value) with an empty value does not match missing attribute anymore. For example, the following snippet will succeed when button does not have a disabled attribute.
expect(page.get_by_role("button")).to_have_attribute("disabled", "")
This version was also tested against the following stable channels:
fix(driver): with CWD which contained spaces
New option enabled for `method: LocatorAssertions.to_be_enabled`.
enabled for method: LocatorAssertions.to_be_enabled.method: LocatorAssertions.to_have_text now pierces open shadow roots.editable for method: LocatorAssertions.to_be_editable.visible for method: LocatorAssertions.to_be_visible.max_redirects for method: APIRequestContext.get and others to limit redirect count.A bunch of Playwright APIs already support the wait_until: "domcontentloaded" option.
For example:
page.goto("https://playwright.dev", wait_until="domcontentloaded")
Prior to 1.26, this would wait for all iframes to fire the DOMContentLoaded
event.
To align with web specification, the 'domcontentloaded' value only waits for
the target frame to fire the 'DOMContentLoaded' event. Use wait_until="load" to wait for all iframes.
This version was also tested against the following stable channels:
[BUG] Jammy images not available in advertised location
[REGRESSION] 1.25.0 distributes "scripts" as a package
🪦 This is the last release with macOS 10.15 support (deprecated as of 1.21).
mcr.microsoft.com/playwright/python:v1.25.0-jammy.This version was also tested against the following stable channels:
fix Route.abort not reported as handled #1458
Playwright now supports Debian 11 Bullseye on x86_64 for Chromium, Firefox and WebKit. Let us know if you encounter any issues!
Playwright now supports Debian 11 Bullseye on x86_64 for Chromium, Firefox and WebKit. Let us know if you encounter any issues!
Linux support looks like this:
| Ubuntu 18.04 | Ubuntu 20.04 | Ubuntu 22.04 | Debian 11 | |
|---|---|---|---|---|
| Chromium | ✅ | ✅ | ✅ | ✅ |
| WebKit | ✅ | ✅ | ✅ | ✅ |
| Firefox | ✅ | ✅ | ✅ | ✅ |
We rewrote our Getting Started docs to be more end-to-end testing focused. Check them out on playwright.dev.
This version was also tested against the following stable channels:
[BUG] Frame is emitted on Page events domcontentloaded/load #1399
Now you can record network traffic into a HAR file and re-use this traffic in your tests.
Now you can record network traffic into a HAR file and re-use this traffic in your tests.
To record network into HAR file:
npx playwright open --save-har=github.har.zip https://github.com/microsoft
Alternatively, you can record HAR programmatically:
context = browser.new_context(record_har_path="github.har.zip")
# ... do stuff ...
context.close()
Use the new methods method: Page.route_from_har or method: BrowserContext.route_from_har to serve matching responses from the HAR file:
context.route_from_har("github.har.zip")
Read more in our documentation.
You can now use method: Route.fallback to defer routing to other handlers.
Consider the following example:
# Remove a header from all requests
def remove_header_handler(route: Route) -> None:
headers = route.request.all_headers()
if "if-none-match" in headers:
del headers["if-none-match"]
route.fallback(headers=headers)
page.route("**/*", remove_header_handler)
# Abort all images
def abort_images_handler(route: Route) -> None:
if route.request.resource_type == "image":
route.abort()
else:
route.fallback()
page.route("**/*", abort_images_handler)
Note that the new methods method: Page.route_from_har or method: BrowserContext.route_from_har also participate in routing and could be deferred to.
method: LocatorAssertions.to_have_values that asserts all selected values of <select multiple> element.method: LocatorAssertions.to_contain_text and method: LocatorAssertions.to_have_text now accept ignore_case option.If there's a service worker that's in your way, you can now easily disable it with a new context option service_workers:
context = browser.new_context(service_workers="block")
page = context.new_page()
Using .zip path for recordHar context option automatically zips the resulting HAR:
context = browser.new_context(record_har_path="github.har.zip")
If you intend to edit HAR by hand, consider using the "minimal" HAR recording mode
that only records information that is essential for replaying:
context = browser.new_context(record_har_mode="minimal", record_har_path="har.har")
Playwright now runs on Ubuntu 22 amd64 and Ubuntu 22 arm64.
Role selectors that allow selecting elements by their ARIA role, ARIA attributes and accessible name.
Role selectors that allow selecting elements by their ARIA role, ARIA attributes and accessible name.
# Click a button with accessible name "log in"
page.click("role=button[name='log in']")
Read more in our documentation.
New [method: Locator.filter] API to filter an existing locator
buttons = page.locator("role=button")
# ...
submit_button = buttons.filter(has_text="Submit")
submit_button.click()
Codegen now supports generating Pytest Tests
This version was also tested against the following stable channels:
New experimental role selectors that allow selecting elements by their ARIA role, ARIA attributes and accessible name.
New experimental role selectors that allow selecting elements by their ARIA role, ARIA attributes and accessible name.
# Click a button with accessible name "log in"
page.click("role=button[name='log in']")
To use role selectors, make sure to pass PLAYWRIGHT_EXPERIMENTAL_FEATURES=1 environment variable.
Read more in our documentation.
New scale option in Page.screenshot for smaller sized screenshots.
New caret option in Page.screenshot to control text caret. Defaults to "hide".
mcr.microsoft.com/playwright docker image no longer contains Python. Please use mcr.microsoft.com/playwright/python
as a Playwright-ready docker image with pre-installed Python.Locator.set_input_files API.This version was also tested against the following stable channels:
This patch includes the following bug fixes:
This patch includes the following bug fixes:
https://github.com/microsoft/playwright/issues/12711 - [REGRESSION] Page.screenshot hangs on some sites https://github.com/microsoft/playwright/issues/12807 - [BUG] Cookies get assigned before fulfilling a response https://github.com/microsoft/playwright/issues/12821 - [BUG] Chromium: Cannot click, element intercepts pointer events https://github.com/microsoft/playwright/issues/12887 - [BUG] Locator.count() with _vue selector with Repro https://github.com/microsoft/playwright/issues/12974 - [BUG] Regression - chromium browser closes during test or debugging session on macos
This version was also tested against the following stable channels:
New options for methods `page.screenshot()`, `locator.screenshot()` and `elementHandle.screenshot()`:
page.screenshot(), locator.screenshot() and elementHandle.screenshot():
animations: "disabled" rewinds all CSS animations and transitions to a consistent statemask: Locator[] masks given elements, overlaying them with pink #FF00FF boxes.locator.highlight() visually reveals element(s) for easier debugging.mcr.microsoft.com/playwright/python. Please switch over to it if you use
Python. This is the last release that includes Python inside our javascript mcr.microsoft.com/playwright docker image.This version was also tested against the following stable channels:
This patch includes the following bug fixes:
This patch includes the following bug fixes:
https://github.com/microsoft/playwright-python/pull/1167 - [BUG] Task exception was never retrieved when continue_ race with page closed event https://github.com/microsoft/playwright/issues/12106 - [BUG] Error: EBUSY: resource busy or locked when using volumes in docker-compose with playwright 1.19.0 and mcr.microsoft.com/playwright:v1.15.0-focal https://github.com/microsoft/playwright/issues/12075 - [Question] After update to 1.19 firefox fails to run
This version was also tested against the following stable channels:
`python page.locator("article", has=page.locator(".highlight")).click() `
has option that makes sure it contains another locator inside:page.locator("article", has=page.locator(".highlight")).click()
The snippet above will select article that has highlight in it and will press the button in it. Read more in locator documentation
method: Locator.pagemethod: Page.screenshot and method: Locator.screenshot now automatically hides blinking caretThis version was also tested against the following stable channels:
Your coding agent can read these notes before it upgrades. Set up the MCP server →