File: release-notes.md | Updated: 11/18/2025
On this page
Version 1.55ā
isVisible() assertions: Codegen can now generate automatic isVisible() 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:
Version 1.54ā
New cookie property partitionKey in BrowserContext.cookies()
and BrowserContext.addCookies()
. 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.
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="codegen --user-data-dir=./user-data"
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args=open command does not open the test recorder anymore. Use mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args=codegen instead.
This version was also tested against the following stable channels:
Version 1.53ā
New Steps in Trace Viewer:
New method Locator.describe() to describe a locator. Used for trace viewer.
Locator button = page.getByTestId("btn-sub").describe("Subscribe button");button.click();
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --list" will now list all installed browsers, versions and locations.
This version was also tested against the following stable channels:
Version 1.52ā
New method assertThat(locator).containsClass() to ergonomically assert individual class names on the element.
assertThat(page.getByRole(AriaRole.LISTITEM, new Page.GetByRoleOptions().setName("Ship v1.52"))).containsClass("done");
Aria Snapshots
got two new properties: /children
for strict matching and /url for links.
assertThat(locator).toMatchAriaSnapshot(""" - list - /children: equal - listitem: Feature A - listitem: - link "Feature B": - /url: "https://playwright.dev"""");
? and [] anymore. We recommend using regular expressions instead.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.addCookies()
.This version was also tested against the following stable channels:
Version 1.51ā
New option setIndexedDB for BrowserContext.storageState() 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.context.storageState(new BrowserContext.StorageStateOptions() .setPath(Paths.get("state.json")) .setIndexedDB(true));// Create a new context with the saved storage state.BrowserContext context = browser.newContext(new Browser.NewContextOptions() .setStorageStatePath(Paths.get("state.json")));
New option setVisible for Locator.filter() allows matching only visible elements.
// Ignore invisible todo items.Locator todoItems = page.getByTestId("todo-item") .filter(new Locator.FilterOptions().setVisible(true));// Check there are exactly 3 visible ones.assertThat(todoItems).hasCount(3);
New option setContrast for methods Page.emulateMedia()
and Browser.newContext()
allows to emulate the prefers-contrast media feature.
New option setFailOnStatusCode 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:
Version 1.50ā
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:
Version 1.49ā
New assertion assertThat(locator).matchesAriaSnapshot() verifies page structure by comparing to an expected accessibility tree, represented as YAML.
page.navigate("https://playwright.dev");assertThat(page.locator("body")).matchesAriaSnapshot(""" - 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 groupEnd// will be shown in the trace viewer as a group.page.context().tracing().group("Open Playwright.dev > API");page.navigate("https://playwright.dev/");page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("API")).click();page.context().tracing().groupEnd();
chrome and msedge channels switch to new headless modeāThis 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.
Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setChannel("chromium"));
<canvas> elements inside a snapshot now draw a preview.This version was also tested against the following stable channels:
Version 1.48ā
New methods Page.routeWebSocket()
and BrowserContext.routeWebSocket()
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".
page.routeWebSocket("/ws", ws -> { ws.onMessage(frame -> { if ("request".equals(frame.text())) ws.send("response"); });});
See WebSocketRoute for more details.
This version was also tested against the following stable channels:
Version 1.47ā
The Network tab in the trace viewer has several nice improvements:
mcr.microsoft.com/playwright/java:v1.47.0 now serves a Playwright image based on Ubuntu 24.04 Noble. To use the 22.02 jammy-based image, please use mcr.microsoft.com/playwright/java: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.macos-13. We recommend upgrading GitHub Actions to macos-14.This version was also tested against the following stable channels:
Version 1.46ā
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.newContext()
and APIRequest.newContext()
. The following snippet sets up a client certificate for https://example.com:
BrowserContext context = browser.newContext(new Browser.NewContextOptions() .setClientCertificates(asList(new ClientCertificate("https://example.com") .setCertPath(Paths.get("client-certificates/cert.pem")) .setKeyPath(Paths.get("client-certificates/key.pem")))));
baseURL.maxRetries option in APIRequestContext.fetch()
which retries on the ECONNRESET network error.This version was also tested against the following stable channels:
Version 1.45ā
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:
testing with predefined time;
keeping consistent time and timers;
monitoring inactivity;
ticking through time manually.
// 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(new Clock.InstallOptions().setTime("2024-02-02T08:00:00"));page.navigate("http://localhost:3333");Locator locator = page.getByTestId("current-time");// Pretend that the user closed the laptop lid and opened it again at 10am.// Pause the time once reached that point.page.clock().pauseAt("2024-02-02T10:00:00");// Assert the page state.assertThat(locator).hasText("2/2/2024, 10:00:00 AM");// Close the laptop lid again and open it at 10:30am.page.clock().fastForward("30:00");assertThat(locator).hasText("2/2/2024, 10:30:00 AM");
See the clock guide for more details.
Method Locator.setInputFiles()
now supports uploading a directory for <input type=file webkitdirectory> elements.
page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
Multiple methods like Locator.click()
or Locator.press()
now support a 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");
New property httpCredentials.send in APIRequest.newContext()
that allows to either always send the Authorization header or only send it in response to 401 Unauthorized.
Playwright now supports Chromium, Firefox and WebKit on Ubuntu 24.04.
v1.45 is the last release to receive WebKit update for macOS 12 Monterey. Please update macOS to keep using the latest WebKit.
This version was also tested against the following stable channels:
Version 1.44ā
Accessibility assertions
assertThat(locator).hasAccessibleName() checks if the element has the specified accessible name:
Locator locator = page.getByRole(AriaRole.BUTTON);assertThat(locator).hasAccessibleName("Submit");
assertThat(locator).hasAccessibleDescription() checks if the element has the specified accessible description:
Locator locator = page.getByRole(AriaRole.BUTTON);assertThat(locator).hasAccessibleDescription("Upload a photo");
assertThat(locator).hasRole() checks if the element has the specified ARIA role:
Locator locator = page.getByTestId("save-button");assertThat(locator).hasRole(AriaRole.BUTTON);
Locator handler
After executing the handler added with Page.addLocatorHandler()
, Playwright will now wait until the overlay that triggered the handler is not visible anymore. You can opt-out of this behavior with the new setNoWaitAfter option.
You can use new setTimes option in Page.addLocatorHandler()
to specify maximum number of times the handler should be run.
The handler in Page.addLocatorHandler() now accepts the locator as argument.
New Page.removeLocatorHandler() method for removing previously added locator handlers.
Locator locator = page.getByText("This interstitial covers the button");page.addLocatorHandler(locator, overlay -> { overlay.locator("#close").click();}, new Page.AddLocatorHandlerOptions().setTimes(3).setNoWaitAfter(true));// Run your tests that can be interrupted by the overlay.// ...page.removeLocatorHandler(locator);
Miscellaneous options
New method FormData.append()
allows to specify repeating fields with the same name in setMultipart
option in RequestOptions:
FormData formData = FormData.create();formData.append("file", new FilePayload("f1.js", "text/javascript","var x = 2024;".getBytes(StandardCharsets.UTF_8)));formData.append("file", new FilePayload("f2.txt", "text/plain", "hello".getBytes(StandardCharsets.UTF_8)));APIResponse response = context.request().post("https://example.com/uploadFile", RequestOptions.create().setMultipart(formData));
expect(page).toHaveURL(url) now supports setIgnoreCase option
.
This version was also tested against the following stable channels:
Version 1.43ā
Method BrowserContext.clearCookies() now supports filters to remove only some cookies.
// Clear all cookies.context.clearCookies();// New: clear cookies with a particular name.context.clearCookies(new BrowserContext.ClearCookiesOptions().setName("session-id"));// New: clear cookies for a particular domain.context.clearCookies(new BrowserContext.ClearCookiesOptions().setDomain("my-origin.com"));
New method Locator.contentFrame() converts a 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 locator = page.locator("iframe[name='embedded']");// ...FrameLocator frameLocator = locator.contentFrame();frameLocator.getByRole(AriaRole.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.
FrameLocator frameLocator = page.frameLocator("iframe[name='embedded']");// ...Locator locator = frameLocator.owner();assertThat(locator).isVisible();
This version was also tested against the following stable channels:
Version 1.42ā
Add new @UsePlaywright
annotation to your test classes to start using Playwright fixtures for Page
, BrowserContext
, Browser
, APIRequestContext
and Playwright
in the test methods.
package org.example;import com.microsoft.playwright.Page;import com.microsoft.playwright.junit.UsePlaywright;import org.junit.jupiter.api.Test;import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;import static org.junit.jupiter.api.Assertions.assertEquals;@UsePlaywrightpublic class TestExample { void shouldNavigateToInstallationGuide(Page page) { page.navigate("https://playwright.dev/java/"); page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("Docs")).click(); assertThat(page.getByRole(AriaRole.HEADING, new Page.GetByRoleOptions().setName("Installation"))).isVisible(); } @Test void shouldCheckTheBox(Page page) { page.setContent("<input id='checkbox' type='checkbox'></input>"); page.locator("input").check(); assertEquals(true, page.evaluate("window['checkbox'].checked")); } @Test void shouldSearchWiki(Page page) { page.navigate("https://www.wikipedia.org/"); page.locator("input[name=\"search\"]").click(); page.locator("input[name=\"search\"]").fill("playwright"); page.locator("input[name=\"search\"]").press("Enter"); assertThat(page).hasURL("https://en.wikipedia.org/wiki/Playwright"); }}
In the example above, all three test methods use the same Browser . Each test uses its own BrowserContext and Page .
Custom options
Implement your own OptionsFactory to initialize the fixtures with custom configuration.
import com.microsoft.playwright.junit.Options;import com.microsoft.playwright.junit.OptionsFactory;import com.microsoft.playwright.junit.UsePlaywright;@UsePlaywright(MyTest.CustomOptions.class)public class MyTest { public static class CustomOptions implements OptionsFactory { @Override public Options getOptions() { return new Options() .setHeadless(false) .setContextOption(new Browser.NewContextOptions() .setBaseURL("https://github.com")) .setApiRequestOptions(new APIRequest.NewContextOptions() .setBaseURL("https://playwright.dev")); } } @Test public void testWithCustomOptions(Page page, APIRequestContext request) { page.navigate("/"); assertThat(page).hasURL(Pattern.compile("github")); APIResponse response = request.get("/"); assertTrue(response.text().contains("Playwright")); }}
Learn more about the fixtures in our JUnit guide .
New method Page.addLocatorHandler() 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.addLocatorHandler( page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Hej! You are in control of your cookies.")), () -> { page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Accept all")).click(); });// Write the test as usual.page.navigate("https://www.ikea.com/");page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("Collection of blue and white")).click();assertThat(page.getByRole(AriaRole.HEADING, new Page.GetByRoleOptions().setName("Light and easy"))).isVisible();
This version was also tested against the following stable channels:
Version 1.41ā
This version was also tested against the following stable channels:
Version 1.40ā
New tools to generate assertions:
Here is an example of a generated test with assertions:
page.navigate("https://playwright.dev/");page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("Get started")).click();assertThat(page.getByLabel("Breadcrumbs").getByRole(AriaRole.LIST)).containsText("Installation");assertThat(page.getByLabel("Search")).isVisible();page.getByLabel("Search").click();page.getByPlaceholder("Search docs").fill("locator");assertThat(page.getByPlaceholder("Search docs")).hasValue("locator");
This version was also tested against the following stable channels:
Version 1.39ā
Evergreen browsers update.
This version was also tested against the following stable channels:
Version 1.38ā
This version was also tested against the following stable channels:
Version 1.37ā
New methods BrowserContext.newCDPSession() and Browser.newBrowserCDPSession() create a Chrome DevTools Protocol session for the page and browser respectively.
CDPSession cdpSession = page.context().newCDPSession(page);cdpSession.send("Runtime.enable");JsonObject params = new JsonObject();params.addProperty("expression", "window.foo = 'bar'");cdpSession.send("Runtime.evaluate", params);Object foo = page.evaluate("window['foo']");assertEquals("bar", foo);
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:
Version 1.36ā
šļø Summer maintenance release.
This version was also tested against the following stable channels:
Version 1.35ā
New option maskColor for methods Page.screenshot()
and Locator.screenshot()
to change default masking color.
New uninstall CLI command to uninstall browser binaries:
$ mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="uninstall" # remove browsers installed by this installation$ mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="uninstall --all" # remove all ever-install Playwright browsers
This version was also tested against the following stable channels:
Version 1.34ā
New Locator.and() to create a locator that matches both locators.
Locator button = page.getByRole(AriaRole.BUTTON).and(page.getByTitle("Subscribe"));
New events BrowserContext.onConsoleMessage(handler) and BrowserContext.onDialog(handler) to subscribe to any dialogs and console messages from any page from the given browser context. Use the new methods ConsoleMessage.page() and Dialog.page() to pin-point event source.
This version was also tested against the following stable channels:
Version 1.33ā
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:
Locator newEmail = page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("New email"));Locator dialog = page.getByText("Confirm security settings");assertThat(newEmail.or(dialog)).isVisible();if (dialog.isVisible()) page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Dismiss")).click();newEmail.click();
Use new options setHasNot and setHasNotText in Locator.filter() to find elements that do not match certain conditions.
Locator rowLocator = page.locator("tr");rowLocator .filter(new Locator.FilterOptions().setHasNotText("text in column 1")) .filter(new Locator.FilterOptions().setHasNot( page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("column 2 button" )))) .screenshot();
Use new web-first assertion assertThat(locator).isAttached() to ensure that the element is present in the page's DOM. Do not confuse with the assertThat(locator).isVisible() that ensures that element is both attached & visible.
New option setHasNot in Locator.filter()
New option setHasNotText in Locator.filter()
New option setTimeout in Route.fetch()
mcr.microsoft.com/playwright/java:v1.33.0 now serves a Playwright image based on Ubuntu Jammy. To use the focal-based image, please use mcr.microsoft.com/playwright/java:v1.33.0-focal instead.This version was also tested against the following stable channels:
Version 1.32ā
This version was also tested against the following stable channels:
Version 1.31ā
New assertion assertThat(locator).isInViewport() ensures that locator points to an element that intersects viewport, according to the intersection observer API .
Locator locator = page.getByRole(AriaRole.BUTTON);// Make sure at least some part of element intersects viewport.assertThat(locator).isInViewport();// Make sure element is fully outside of viewport.assertThat(locator).not().isInViewport();// Make sure that at least half of the element intersects viewport.assertThat(locator).isInViewport(new LocatorAssertions.IsInViewportOptions().setRatio(0.5));
This version was also tested against the following stable channels:
Version 1.30ā
This version was also tested against the following stable channels:
Version 1.29ā
New method Route.fetch() :
page.route("**/api/settings", route -> { // Fetch original settings. APIResponse response = route.fetch(); // Force settings theme to a predefined value. String body = response.text().replace("\"theme\":\"default\"", "\"theme\":\"Solorized\""); // Fulfill with modified data. route.fulfill(new Route.FulfillOptions().setResponse(response).setBody(body));});
New method Locator.all() to iterate over all matching elements:
// Check all checkboxes!Locator checkboxes = page.getByRole(AriaRole.CHECKBOX);for (Locator checkbox : checkboxes.all()) checkbox.check();
Locator.selectOption() matches now by value or label:
<select multiple> <option value="red">Red</option> <option value="green">Green</option> <option value="blue">Blue</option></select>
element.selectOption("Red");
This version was also tested against the following stable channels:
Version 1.28ā

This version was also tested against the following stable channels:
Version 1.27ā
With these new APIs writing locators is a joy:
Page.getByText() to locate by text content.
Page.getByRole() to locate by ARIA role , ARIA attributes and accessible name .
Page.getByLabel() to locate a form control by associated label's text.
Page.getByTestId()
to locate an element based on its data-testid attribute (other attribute can be configured).
Page.getByPlaceholder() to locate an input by placeholder.
Page.getByAltText() to locate an element, usually image, by its text alternative.
Page.getByTitle() to locate an element by its title.
page.getByLabel("User Name").fill("John");page.getByLabel("Password").fill("secret-password");page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Sign in")).click();assertThat(page.getByText("Welcome, John!")).isVisible();
All the same methods are also available on Locator , FrameLocator and Frame classes.
assertThat(locator).hasAttribute()
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.
assertThat(page.getByRole(AriaRole.BUTTON)).hasAttribute("disabled", "");
This version was also tested against the following stable channels:
Version 1.26ā
enabled for assertThat(locator).isEnabled()
.editable for assertThat(locator).isEditable()
.visible for assertThat(locator).isVisible()
.setMaxRedirects for APIRequestContext.get()
and others to limit redirect count.A bunch of Playwright APIs already support the setWaitUntil(WaitUntilState.DOMCONTENTLOADED) option. For example:
page.navigate("https://playwright.dev", new Page.NavigateOptions().setWaitUntil(WaitUntilState.DOMCONTENTLOADED));
Prior to 1.26, this would wait for all iframes to fire the DOMContentLoaded event.
To align with web specification, the WaitUntilState.DOMCONTENTLOADED value only waits for the target frame to fire the 'DOMContentLoaded' event. Use setWaitUntil(WaitUntilState.LOAD) to wait for all iframes.
This version was also tested against the following stable channels:
Version 1.25ā
setDefaultAssertionTimeout
.This version was also tested against the following stable channels:
Version 1.24ā
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 20.04 | Ubuntu 22.04 | Debian 11 | :--- | :---: | :---: | :---: | :---: | | Chromium | ā | ā | ā | | WebKit | ā | ā | ā | | Firefox | ā | ā | ā |
Version 1.23ā
Now you can record network traffic into a HAR file and re-use this traffic in your tests.
To record network into HAR file:
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="open --save-har=example.har --save-har-glob='**/api/**' https://example.com"
Alternatively, you can record HAR programmatically:
BrowserContext context = browser.newContext(new Browser.NewContextOptions() .setRecordHarPath(Paths.get("example.har")) .setRecordHarUrlFilter("**/api/**"));// ... Perform actions ...// Close context to ensure HAR is saved to disk.context.close();
Use the new methods Page.routeFromHAR() or BrowserContext.routeFromHAR() to serve matching responses from the HAR file:
context.routeFromHAR(Paths.get("example.har"));
Read more in our documentation .
You can now use Route.fallback() to defer routing to other handlers.
Consider the following example:
// Remove a header from all requests.page.route("**/*", route -> { Map<String, String> headers = new HashMap<>(route.request().headers()); headers.remove("X-Secret"); route.resume(new Route.ResumeOptions().setHeaders(headers));});// Abort all images.page.route("**/*", route -> { if ("image".equals(route.request().resourceType())) route.abort(); else route.fallback();});
Note that the new methods Page.routeFromHAR() and BrowserContext.routeFromHAR() also participate in routing and could be deferred to.
<select multiple> element.ignoreCase option.If there's a service worker that's in your way, you can now easily disable it with a new context option serviceWorkers:
BrowserContext context = browser.newContext(new Browser.NewContextOptions() .setServiceWorkers(ServiceWorkerPolicy.BLOCK));
Using .zip path for recordHar context option automatically zips the resulting HAR:
BrowserContext context = browser.newContext(new Browser.NewContextOptions() .setRecordHarPath(Paths.get("example.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:
BrowserContext context = browser.newContext(new Browser.NewContextOptions() .setRecordHarPath(Paths.get("example.har")) .setRecordHarMode(HarMode.MINIMAL));
Playwright now runs on Ubuntu 22 amd64 and Ubuntu 22 arm64.
Version 1.22ā
Role selectors that allow selecting elements by their ARIA role , ARIA attributes and accessible name .
// Click a button with accessible name "log in"page.locator("role=button[name='log in']").click();
Read more in our documentation .
New Locator.filter() API to filter an existing locator
Locator buttonsLocator = page.locator("role=button");// ...Locator submitButton = buttonsLocator.filter(new Locator.FilterOptions().setHasText("Submit"));submitButton.click();
Playwright for Java now supports Ubuntu 20.04 ARM64 and Apple M1. You can now run Playwright for Java tests on Apple M1, inside Docker on Apple M1, and on Raspberry Pi.
Version 1.21ā
New role selectors that allow selecting elements by their ARIA role , ARIA attributes and accessible name .
// Click a button with accessible name "log in"page.locator("role=button[name='log in']").click();
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".
This version was also tested against the following stable channels:
Version 1.20ā
ScreenshotAnimations.DISABLED rewinds all CSS animations and transitions to a consistent statemask: Locator[] masks given elements, overlaying them with pink #FF00FF boxes.This version was also tested against the following stable channels:
Version 1.19ā
Locator now supports a has option that makes sure it contains another locator inside:
page.locator("article", new Page.LocatorOptions().setHas(page.locator(".highlight"))).click();
Read more in locator documentation
New Locator.page()
Page.screenshot() and Locator.screenshot() now automatically hide blinking caret
Playwright Codegen now generates locators and frame locators
This version was also tested against the following stable channels:
Version 1.18ā
Playwright for Java 1.18 introduces new API Testing that lets you send requests to the server directly from Java! Now you can:
To do a request on behalf of Playwright's Page, use new Page.request() API:
// Do a GET request on behalf of pageAPIResponse res = page.request().get("http://example.com/foo.json");
Read more about it in our API testing guide .
Playwright for Java 1.18 introduces Web-First Assertions .
Consider the following example:
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;public class TestExample { @Test void statusBecomesSubmitted() { // ... page.locator("#submit-button").click(); assertThat(page.locator(".status")).hasText("Submitted"); }}
Playwright will be re-testing the node with the selector .status until fetched Node has the "Submitted" text. It will be re-fetching the node and checking it over and over, until the condition is met or until the timeout is reached. You can pass this timeout as an option.
Read more in our documentation .
Each locator can now be optionally filtered by the text it contains:
page.locator("li", new Page.LocatorOptions().setHasText("my item")) .locator("button").click();
Read more in locator documentation
Tracing
now can embed Java sources to recorded traces, using new setSources
option.

acceptDownloads
option now defaults to true.This version was also tested against the following stable channels:
Version 1.17ā
Playwright 1.17 introduces frame locators
iframe and then locate elements in that iframe. Frame locators are strict by default, will wait for iframe to appear and can be used in Web-First assertions.
Frame locators can be created with either Page.frameLocator() or Locator.frameLocator() method.
Locator locator = page.frameLocator("#my-frame").locator("text=Submit");locator.click();
Read more at our documentation .
Playwright Trace Viewer is now available online at https://trace.playwright.dev
! Just drag-and-drop your trace.zip file to inspect its contents.
NOTE: trace files are not uploaded anywhere; trace.playwright.dev is a progressive web application that processes traces locally.


Playwright now supports Ubuntu 20.04 ARM64. You can now run Playwright tests inside Docker on Apple M1 and on Raspberry Pi.
You can now use Playwright to install stable version of Edge on Linux:
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install msedge"
Version 1.16ā
Wait for a locator to resolve to a single element with a given state. Defaults to the state: 'visible'.
Locator orderSent = page.locator("#order-sent");orderSent.waitFor();
Read more about Locator.waitFor() .
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="show-trace" and drop trace files to the trace viewer PWARead more about Trace Viewer .
This version of Playwright was also tested against the following stable channels:
Version 1.15ā
By using Mouse.wheel() you are now able to scroll vertically or horizontally.
Previously it was not possible to get multiple header values of a response. This is now possible and additional helper functions are available:
Its now possible to emulate the forced-colors CSS media feature by passing it in the Browser.newContext()
or calling Page.emulateMedia()
.
times option to specify how many times this route should be matched.Version 1.14ā
Selector ambiguity is a common problem in automation testing. "strict" mode ensures that your selector points to a single element and throws otherwise.
Set setStrict(true) in your action calls to opt in.
// This will throw if you have more than one button!page.click("button", new Page.ClickOptions().setStrict(true));
Locator represents a view to the element(s) on the page. It captures the logic sufficient to retrieve the element at any given moment.
The difference between the Locator and ElementHandle is that the latter points to a particular element, while Locator captures the logic of how to retrieve that element.
Also, locators are "strict" by default!
Locator locator = page.locator("button");locator.click();
Learn more in the documentation .
React and Vue selectors allow selecting elements by its component name and/or property values. The syntax is very similar to attribute selectors and supports all attribute selector operators.
page.locator("_react=SubmitButton[enabled=true]").click();page.locator("_vue=submit-button[enabled=true]").click();
Learn more in the react selectors documentation and the vue selectors documentation .
nthand visible
selector enginesā
nth
selector engine is equivalent to the :nth-match pseudo class, but could be combined with other selector engines.
visible
selector engine is equivalent to the :visible pseudo class, but could be combined with other selector engines.
// select the first button among all buttonsbutton.click("button >> nth=0");// or if you are using locators, you can use first(), nth() and last()page.locator("button").first().click();// click a visible buttonbutton.click("button >> visible=true");
Version 1.13ā
recordHar option in Browser.newContext()
.console.log() calls.new baseURL option in Browser.newContext()
and Browser.newPage()
Page.inputValue() , Frame.inputValue() and ElementHandle.inputValue()
new force option in Page.fill()
, Frame.fill()
, and ElementHandle.fill()
new force option in Page.selectOption()
, Frame.selectOption()
, and ElementHandle.selectOption()
Version 1.12ā
Playwright Trace Viewer is a new GUI tool that helps exploring recorded Playwright traces after the script ran. Playwright traces let you examine:
Traces are recorded using the new BrowserContext.tracing() API:
Browser browser = playwright.chromium().launch();BrowserContext context = browser.newContext();// Start tracing before creating / navigating a page.context.tracing().start(new Tracing.StartOptions() .setScreenshots(true) .setSnapshots(true));Page page = context.newPage();page.navigate("https://playwright.dev");// Stop tracing and export it into a zip archive.context.tracing().stop(new Tracing.StopOptions() .setPath(Paths.get("trace.zip")));
Traces are examined later with the Playwright CLI:
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="show-trace trace.zip"
That will open the following GUI:

š Read more in trace viewer documentation .
This version of Playwright was also tested against the following stable channels:
reducedMotion option in Page.emulateMedia()
, BrowserType.launchPersistentContext()
, Browser.newContext()
and Browser.newPage()
tracesDir option in BrowserType.launch()
and BrowserType.launchPersistentContext()
new BrowserContext.tracing() API namespace
new Download.page() method
Version 1.11ā
š„ New video: Playwright: A New Test Automation Framework for the Modern Web (slides )
screen option in the Browser.newContext()
method to emulate window.screen dimensionsposition option in Page.check()
and Page.uncheck()
methodstrial option to dry-run actions in Page.check()
, Page.uncheck()
, Page.click()
, Page.dblclick()
, Page.hover()
and Page.tap()Version 1.10ā
This version of Playwright was also tested against the following stable channels:
'channel' option. Read more in our documentation
.Version 1.9ā
PWDEBUG=1 environment variable to launch the Inspector:has-text("example") matches any element containing "example" somewhere inside, possibly in a child or a descendant element. See more examples
.dialog event is configured. Learn more
about this.Version 1.8ā
Selecting elements based on layout
with :left-of(), :right-of(), :above() and :below().
Playwright now includes command line interface, former playwright-cli.
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="--help"
Page.selectOption() now waits for the options to be present.
New methods to assert element state like Page.isEditable() .
'editable' in ElementHandle.waitForElementState()
.Version 1.7ā
storageState option in Browser.newContext()
and Browser.newPage()
to setup browser context state.Chromium 89.0.4344.0
Mozilla Firefox 84.0b9
WebKit 14.1