Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
APACHE-2.0 License
Bot releases are visible (Hide)
Published by mxschmitt over 1 year ago
https://github.com/microsoft/playwright/issues/21093 - [Regression v1.31] Headless Windows shows cascading cmd windows
https://github.com/microsoft/playwright/pull/21106 - fix(loader): experimentalLoader with node@18
This version was also tested against the following stable channels:
Published by dgozman over 1 year ago
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 });
defineConfig
to be used in playwright.config
.maxRedirects
for method Route.fetch
.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 ...
});
This version was also tested against the following stable channels:
Published by dgozman over 1 year ago
Maintenance release with bugfixes and new browsers only. We are baking some nice features for v1.31.
This version was also tested against the following stable channels:
Published by aslushnikov almost 2 years ago
https://github.com/microsoft/playwright/issues/19661 - [BUG] 1.29.1 browserserver + page.goto = net::ERR_SOCKS_CONNECTION_FAILED
This version was also tested against the following stable channels:
Published by aslushnikov almost 2 years ago
https://github.com/microsoft/playwright/issues/18928 - [BUG] Electron firstWindow times out after upgrading to 1.28.0
https://github.com/microsoft/playwright/issues/19246 - [BUG] Electron firstWindow times out after upgrading to 1.28.1
https://github.com/microsoft/playwright/issues/19412 - [REGRESSION]: 1.28 does not work with electron-serve anymore.
https://github.com/microsoft/playwright/issues/19540 - [BUG] electron.app.getAppPath() returns the path one level higher if you run electron pointing to the directory
https://github.com/microsoft/playwright/issues/19548 - [REGRESSION]: Ubuntu 18 LTS not supported anymore
This version was also tested against the following stable channels:
Published by aslushnikov almost 2 years ago
New method route.fetch()
and new option json
for route.fulfill()
:
await page.route('**/api/settings', async route => {
// Fetch original settings.
const response = await route.fetch();
// Force settings theme to a predefined value.
const json = await response.json();
json.theme = 'Solorized';
// Fulfill with modified data.
await route.fulfill({ json });
});
New method locator.all()
to iterate over all matching elements:
// Check all checkboxes!
const checkboxes = page.getByRole('checkbox');
for (const checkbox of await checkboxes.all())
await checkbox.check();
Locator.selectOption
matches now by value or label:
<select multiple>
<option value="red">Red</div>
<option value="green">Green</div>
<option value="blue">Blue</div>
</select>
await element.selectOption('Red');
Retry blocks of code until all assertions pass:
await expect(async () => {
const response = await page.request.get('https://api.example.com');
await expect(response).toBeOK();
}).toPass();
Read more in our documentation.
Automatically capture full page screenshot on test failure:
// playwright.config.ts
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {
screenshot: {
mode: 'only-on-failure',
fullPage: true,
}
}
};
export default config;
jsconfig.json
.args
and proxy
for androidDevice.launchBrowser()
.postData
in method route.continue()
now supports serializable values.This version was also tested against the following stable channels:
Published by aslushnikov almost 2 years ago
This patch release includes the following bug fixes:
https://github.com/microsoft/playwright/issues/18928 - [BUG] Electron firstWindow times out after upgrading to 1.28.0
https://github.com/microsoft/playwright/issues/18920 - [BUG] [expanded=false] in role selector returns elements without aria-expanded attribute
https://github.com/microsoft/playwright/issues/18865 - [BUG] regression in killing web server process in 1.28.0
This version was also tested against the following stable channels:
Published by aslushnikov almost 2 years ago
Configure retries and test timeout for a file or a test with test.describe.configure([options])
.
// Each test in the file will be retried twice and have a timeout of 20 seconds.
test.describe.configure({ retries: 2, timeout: 20_000 });
test('runs first', async ({ page }) => {});
test('runs second', async ({ page }) => {});
Use testProject.snapshotPathTemplate
and testConfig.snapshotPathTemplate
to configure a template controlling location of snapshots generated by expect(page).toHaveScreenshot(name[, options])
and expect(screenshot).toMatchSnapshot(name[, options])
.
// playwright.config.ts
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
testDir: './tests',
snapshotPathTemplate: '{testDir}/__screenshots__/{testFilePath}/{arg}{ext}',
};
export default config;
locator.blur([options])
locator.clear([options])
android.launchServer([options])
and android.connect(wsEndpoint[, options])
androidDevice.on('close')
This version was also tested against the following stable channels:
Published by yury-s about 2 years ago
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/17999 - chore: don't fail on undefined video/trace
https://github.com/microsoft/playwright/issues/17955 - [Question] Github Actions test compatibility check failed mitigation?
https://github.com/microsoft/playwright/issues/17960 - [BUG] Codegen 1.27 creates NUnit code that does not compile
https://github.com/microsoft/playwright/pull/17952 - fix: fix typo in treeitem role typing
This version was also tested against the following stable channels:
Published by dgozman about 2 years ago
With these new APIs, inspired by Testing Library, writing locators is a joy:
page.getByText(text, options)
to locate by text content.page.getByRole(role, options)
to locate by ARIA role, ARIA attributes and accessible name.page.getByLabel(label, options)
to locate a form control by associated label's text.page.getByPlaceholder(placeholder, options)
to locate an input by placeholder.page.getByAltText(altText, options)
to locate an element, usually image, by its text alternative.page.getByTitle(title, options)
to locate an element by its title.await page.getByLabel('User Name').fill('John');
await page.getByLabel('Password').fill('secret-password');
await page.getByRole('button', { name: 'Sign in' }).click();
await expect(page.getByText('Welcome, John!')).toBeVisible();
All the same methods are also available on Locator, FrameLocator and Frame classes.
workers
option in the playwright.config.ts
now accepts a percentage string to use some of the available CPUs. You can also pass it in the command line:
npx playwright test --workers=20%
New options host
and port
for the html reporter.
reporters: [['html', { host: 'localhost', port: '9223' }]]
New field FullConfig.configFile
is available to test reporters, specifying the path to the config file if any.
As announced in v1.25, Ubuntu 18 will not be supported as of Dec 2022. In addition to that, there will be no WebKit updates on Ubuntu 18 starting from the next Playwright release.
expect(locator).toHaveAttribute(name, value, options)
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.
await expect(page.getByRole('button')).toHaveAttribute('disabled', '');
Command line options --grep
and --grep-invert
previously incorrectly ignored grep
and grepInvert
options specified in the config. Now all of them are applied together.
JSON reporter path resolution is performed relative to the config directory instead of the current working directory:
["json", { outputFile: "./test-results/results.json" }]]
This version was also tested against the following stable channels:
Published by aslushnikov about 2 years ago
This patch includes the following bug fixes:
https://github.com/microsoft/playwright/issues/17500 - [BUG] No tests found using the test explorer - pw/[email protected]
This version was also tested against the following stable channels:
Published by aslushnikov about 2 years ago
expect(locator).toBeEnabled([options])
.expect(locator).toHaveText(expected[, options])
now pierces open shadow roots.expect(locator).toBeEditable([options])
.expect(locator).toBeVisible([options])
.maxRedirects
for apiRequestContext.get(url[, options])
and others to limit redirect count.--pass-with-no-tests
that allows the test suite to pass when no files are found.--ignore-snapshots
to skip snapshot expectations, such as expect(value).toMatchSnapshot()
and expect(page).toHaveScreenshot()
.A bunch of Playwright APIs already support the waitUntil: 'domcontentloaded' option. For example:
await page.goto('https://playwright.dev', {
waitUntil: '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 waitUntil: 'load'
to wait for all iframes.
This version was also tested against the following stable channels:
Published by aslushnikov about 2 years ago
This patch includes the following bug fixes:
https://github.com/microsoft/playwright/issues/16937 - [REGRESSION]: session storage failing >= 1.25.0 in firefox
https://github.com/microsoft/playwright/issues/16955 - Not using channel on config file when Show and Reuse browser is checked
This version was also tested against the following stable channels:
Published by aslushnikov about 2 years ago
This patch includes the following bug fixes:
https://github.com/microsoft/playwright/issues/16319 - [BUG] webServer.command esbuild fails with ESM and Yarn
https://github.com/microsoft/playwright/issues/16460 - [BUG] Component test fails on 2nd run when SSL is used
https://github.com/microsoft/playwright/issues/16665 - [BUG] custom selector engines don't work when running in debug mode
This version was also tested against the following stable channels:
Published by aslushnikov about 2 years ago
New Playwright actions view
Pick selector
You can pick selector right from a live page, before or after running a test
Record new test
Start recording where you left off with the new 'Record new test' feature.
Show & reuse browser
Watch your tests running live & keep devtools open. Develop while continuously running tests.
test.step(title, body)
now returns the value of the step function:
test('should work', async ({ page }) => {
const pageTitle = await test.step('get title', async () => {
await page.goto('https://playwright.dev');
return await page.title();
});
console.log(pageTitle);
});
New 'interrupted'
test status.
Enable tracing via CLI flag: npx playwright test --trace=on
.
New property testCase.id
that can be use in reporters as a history ID.
mcr.microsoft.com/playwright:v1.25.0-jammy
.This version was also tested against the following stable channels:
Published by aslushnikov about 2 years ago
This patch includes the following bug fixes:
https://github.com/microsoft/playwright/issues/15977 - [BUG] test.use of storage state regression in 1.24
This version was also tested against the following stable channels:
Published by aslushnikov about 2 years ago
This patch includes the following bug fixes:
https://github.com/microsoft/playwright/issues/15898 - [BUG] Typescript error: The type for webServer config property (TestConfigWebServer) is not typed correctly
https://github.com/microsoft/playwright/issues/15913 - [BUG] hooksConfig is required for mount fixture
https://github.com/microsoft/playwright/issues/15932 - [BUG] - Install MS Edge on CI Fails
This version was also tested against the following stable channels:
Published by aslushnikov about 2 years ago
playwright.config.ts
Launch multiple web servers, databases, or other processes by passing an array of configurations:
// playwright.config.ts
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
webServer: [
{
command: 'npm run start',
port: 3000,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
},
{
command: 'npm run backend',
port: 3333,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
}
],
use: {
baseURL: 'http://localhost:3000/',
},
};
export default config;
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 | â | â | â | â |
It is now possible to call test.describe(callback)
to create suites without a title. This is useful for giving a group of tests a common option with test.use(options)
.
test.describe(() => {
test.use({ colorScheme: 'dark' });
test('one', async ({ page }) => {
// ...
});
test('two', async ({ page }) => {
// ...
});
});
Playwright 1.24 Component Tests introduce beforeMount
and afterMount
hooks.
Use these to configure your app for tests.
For example, this could be used to setup App router in Vue.js:
// src/component.spec.ts
import { test } from '@playwright/experimental-ct-vue';
import { Component } from './mycomponent';
test('should work', async ({ mount }) => {
const component = await mount(Component, {
hooksConfig: {
/* anything to configure your app */
}
});
});
// playwright/index.ts
import { router } from '../router';
import { beforeMount } from '@playwright/experimental-ct-vue/hooks';
beforeMount(async ({ app, hooksConfig }) => {
app.use(router);
});
A similar configuration in Next.js would look like this:
// src/component.spec.jsx
import { test } from '@playwright/experimental-ct-react';
import { Component } from './mycomponent';
test('should work', async ({ mount }) => {
const component = await mount(<Component></Component>, {
// Pass mock value from test into `beforeMount`.
hooksConfig: {
router: {
query: { page: 1, per_page: 10 },
asPath: '/posts'
}
}
});
});
// playwright/index.js
import router from 'next/router';
import { beforeMount } from '@playwright/experimental-ct-react/hooks';
beforeMount(async ({ hooksConfig }) => {
// Before mount, redefine useRouter to return mock value from test.
router.useRouter = () => hooksConfig.router;
});
This version was also tested against the following stable channels:
Published by yury-s over 2 years ago
This patch includes the following bug fix:
https://github.com/microsoft/playwright/issues/15717 - [REGRESSION]: Suddenly stopped working despite nothing having changed (experimentalLoader.js:load
did not call the next hook in its chain and did not explicitly signal a short circuit)
This version was also tested against the following stable channels:
Published by aslushnikov over 2 years ago
This patch includes the following bug fixes:
https://github.com/microsoft/playwright/issues/15557 - [REGRESSION]: Event Listeners not being removed if same handler is used for different events
This version was also tested against the following stable channels: