Releases: microsoft/playwright
v1.34.0
Playwright v1.33 & v1.34 updates
Highlights
-
New property
testProject.teardown
to specify a project that needs to run after this
and all dependent projects have finished. Teardown is useful to cleanup any resources acquired by this project.A common pattern would be a
setup
dependency with a correspondingteardown
:// playwright.config.ts import { defineConfig } from '@playwright/test'; export default defineConfig({ projects: [ { name: 'setup', testMatch: /global.setup\.ts/, teardown: 'teardown', }, { name: 'teardown', testMatch: /global.teardown\.ts/, }, { name: 'chromium', use: devices['Desktop Chrome'], dependencies: ['setup'], }, { name: 'firefox', use: devices['Desktop Firefox'], dependencies: ['setup'], }, { name: 'webkit', use: devices['Desktop Safari'], dependencies: ['setup'], }, ], });
-
New method
expect.configure
to create pre-configured expect instance with its own defaults such astimeout
andsoft
.const slowExpect = expect.configure({ timeout: 10000 }); await slowExpect(locator).toHaveText('Submit'); // Always do soft assertions. const softExpect = expect.configure({ soft: true });
-
New options
stderr
andstdout
intestConfig.webServer
to configure output handling:// playwright.config.ts import { defineConfig } from '@playwright/test'; export default defineConfig({ // Run your local dev server before starting the tests webServer: { command: 'npm run start', url: 'http://127.0.0.1:3000', reuseExistingServer: !process.env.CI, stdout: 'pipe', stderr: 'pipe', }, });
-
New
locator.and()
to create a locator that matches both locators.const button = page.getByRole('button').and(page.getByTitle('Subscribe'));
-
New events
browserContext.on('console')
andbrowserContext.on('dialog')
to subscribe to any dialogs
and console messages from any page from the given browser context. Use the new methodsconsoleMessage.page()
anddialog.page()
to pin-point event source.
⚠️ Breaking changes
-
npx playwright test
no longer works if you install bothplaywright
and@playwright/test
. There's no need
to install both, since you can always import browser automation APIs from@playwright/test
directly:// automation.ts import { chromium, firefox, webkit } from '@playwright/test'; /* ... */
-
Node.js 14 is no longer supported since it reached its end-of-life on April 30, 2023.
Browser Versions
- Chromium 114.0.5735.26
- Mozilla Firefox 113.0
- WebKit 16.4
This version was also tested against the following stable channels:
- Google Chrome 113
- Microsoft Edge 113
v1.33.0
Playwright v1.33 & v1.34 updates
Locators Update
-
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:const newEmail = page.getByRole('button', { name: 'New' }); const dialog = page.getByText('Confirm security settings'); await expect(newEmail.or(dialog)).toBeVisible(); if (await dialog.isVisible()) await page.getByRole('button', { name: 'Dismiss' }).click(); await newEmail.click();
-
Use new options
hasNot
andhasNotText
inlocator.filter()
to find elements that do not match certain conditions.const rowLocator = page.locator('tr'); await rowLocator .filter({ hasNotText: 'text in column 1' }) .filter({ hasNot: page.getByRole('button', { name: 'column 2 button' }) }) .screenshot();
-
Use new web-first assertion
locatorAssertions.toBeAttached()
to ensure that the element
is present in the page's DOM. Do not confuse with thelocatorAssertions.toBeVisible()
that ensures that
element is both attached & visible.
New APIs
locator.or()
- New option
hasNot
inlocator.filter()
- New option
hasNotText
inlocator.filter()
locatorAssertions.toBeAttached()
- New option
timeout
inroute.fetch()
reporter.onExit()
⚠️ Breaking change
- The
mcr.microsoft.com/playwright:v1.33.0
now serves a Playwright image based on Ubuntu Jammy.
To use the focal-based image, please usemcr.microsoft.com/playwright:v1.33.0-focal
instead.
Browser Versions
- Chromium 113.0.5672.53
- Mozilla Firefox 112.0
- WebKit 16.4
This version was also tested against the following stable channels:
- Google Chrome 112
- Microsoft Edge 112
v1.32.3
Highlights
#22144 - [BUG] WebServer only starting after timeout
#22191 - chore: allow reusing browser between the tests
#22215 - [BUG] Tests failing in toPass often marked as passed
Browser Versions
- Chromium 112.0.5615.29
- Mozilla Firefox 111.0
- WebKit 16.4
This version was also tested against the following stable channels:
- Google Chrome 111
- Microsoft Edge 111
v1.32.2
Highlights
#21993 - [BUG] Browser crash when using Playwright VSC extension and trace-viewer enabled in config
#22003 - [Feature] Make Vue component mount props less restrictive
#22089 - [REGRESSION]: Tests failing with "Error: tracing.stopChunk"
Browser Versions
- Chromium 112.0.5615.29
- Mozilla Firefox 111.0
- WebKit 16.4
This version was also tested against the following stable channels:
- Google Chrome 111
- Microsoft Edge 111
v1.32.1
Highlights
#21832 - [BUG] Trace is not opening on specific broken locator
#21897 - [BUG] --ui fails to open with error reading mainFrame from an undefined this._page
#21918 - [BUG]: UI mode, skipped tests not being found
#21941 - [BUG] UI mode does not show webServer startup errors
#21953 - [BUG] Parameterized tests are not displayed in the UI mode
Browser Versions
- Chromium 112.0.5615.29
- Mozilla Firefox 111.0
- WebKit 16.4
This version was also tested against the following stable channels:
- Google Chrome 111
- Microsoft Edge 111
v1.32.0
📣 Introducing UI Mode (preview)
New UI Mode lets you explore, run and debug tests. Comes with a built-in watch mode.
Engage with a new flag --ui
:
npx playwright test --ui
New APIs
- New options
option: updateMode
andoption: updateContent
inpage.routeFromHAR()
andbrowserContext.routeFromHAR()
. - Chaining existing locator objects, see locator docs for details.
- New property
TestInfo.testId
. - New option
name
in methodTracing.startChunk()
.
⚠️ Breaking change in component tests
Note: component tests only, does not affect end-to-end tests.
@playwright/experimental-ct-react
now supports React 18 only.- If you're running component tests with React 16 or 17, please replace
@playwright/experimental-ct-react
with@playwright/experimental-ct-react17
.
Browser Versions
- Chromium 112.0.5615.29
- Mozilla Firefox 111.0
- WebKit 16.4
This version was also tested against the following stable channels:
- Google Chrome 111
- Microsoft Edge 111
v1.31.2
Highlights
#20784 - [BUG] ECONNREFUSED on GitHub Actions with Node 18
#21145 - [REGRESSION]: firefox-1378 times out on await page.reload() when URL contains a #hash
#21226 - [BUG] Playwright seems to get stuck when using shard option and last test is skipped
#21227 - Using the webServer config with a Vite dev server?
#21312 - throw if defineConfig is not used for component testing
Browser Versions
- Chromium 111.0.5563.19
- Mozilla Firefox 109.0
- WebKit 16.4
This version was also tested against the following stable channels:
- Google Chrome 110
- Microsoft Edge 110
v1.31.1
Highlights
#21093 - [Regression v1.31] Headless Windows shows cascading cmd windows
#21106 - fix(loader): experimentalLoader with node@18
Browser Versions
- Chromium 111.0.5563.19
- Mozilla Firefox 109.0
- WebKit 16.4
This version was also tested against the following stable channels:
- Google Chrome 110
- Microsoft Edge 110
v1.31.0
New APIs
-
New property
TestProject.dependencies
to configure dependencies between projects.Using dependencies allows global setup to produce traces and other artifacts,
see the setup steps in the test report and more.// playwright.config.ts import { defineConfig } from '@playwright/test'; export default defineConfig({ projects: [ { name: 'setup', testMatch: /global.setup\.ts/, }, { name: 'chromium', use: devices['Desktop Chrome'], dependencies: ['setup'], }, { name: 'firefox', use: devices['Desktop Firefox'], dependencies: ['setup'], }, { name: 'webkit', use: devices['Desktop Safari'], dependencies: ['setup'], }, ], });
-
New assertion
expect(locator).toBeInViewport()
ensures that locator points to an element that intersects viewport, according to the intersection observer API.const button = page.getByRole('button'); // Make sure at least some part of element intersects viewport. await expect(button).toBeInViewport(); // Make sure element is fully outside of viewport. await expect(button).not.toBeInViewport(); // Make sure that at least half of the element intersects viewport. await expect(button).toBeInViewport({ ratio: 0.5 });
Miscellaneous
- DOM snapshots in trace viewer can be now opened in a separate window.
- New method
defineConfig
to be used inplaywright.config
. - New option
maxRedirects
for methodRoute.fetch
. - Playwright now supports Debian 11 arm64.
- Official docker images now include Node 18 instead of Node 16.
⚠️ Breaking change in component tests
Note: component tests only, does not affect end-to-end tests.
playwright-ct.config
configuration file for component testing now requires calling defineConfig
.
// Before
import { type PlaywrightTestConfig, devices } from '@playwright/experimental-ct-react';
const config: PlaywrightTestConfig = {
// ... config goes here ...
};
export default config;
Replace config
variable definition with defineConfig
call:
// After
import { defineConfig, devices } from '@playwright/experimental-ct-react';
export default defineConfig({
// ... config goes here ...
});
Browser Versions
- Chromium 111.0.5563.19
- Mozilla Firefox 109.0
- WebKit 16.4
This version was also tested against the following stable channels:
- Google Chrome 110
- Microsoft Edge 110
v1.30.0
🎉 Happy New Year 🎉
Maintenance release with bugfixes and new browsers only. We are baking some nice features for v1.31.
Browser Versions
- Chromium 110.0.5481.38
- Mozilla Firefox 108.0.2
- WebKit 16.4
This version was also tested against the following stable channels:
- Google Chrome 109
- Microsoft Edge 109