Hidden Gems of Playwright

The main tools for writing UI tests are: browser, IDE and testing framework documentation.

Hidden Gems of Playwright

maxFailures

const config: PlaywrightTestConfig = {
maxFailures: 10,
};
const config: PlaywrightTestConfig = {
maxFailures: process.env.CI ? 10 : 0,
};
Example of env.CI = true in a build configuration in TeamCity
Example of env.CI = true in a build configuration in TeamCity

Custom Expect Messages

await test('Should have proper page title', async () => {
await expect(page, 'Should have "Home" in title').toHaveTitle(/Home/);
});
Example of custom expect error message in HTML report
Example of custom expect error message in HTML report

test.slow

test('Test name', async ({ page }) => {
test.slow();
});

expect.soft

await test.step('Should have proper page title', async () => {
await expect.soft(page, 'Should have "Home" in title').toHaveTitle(/Home/);
});
Example of HTML report with failed soft assertion — all test steps are passed, but the entire test was marked as failed
Example of HTML report with failed soft assertion — all test steps are passed, but the entire test was marked as failed

test.step

test.describe('Home page toolbar', async () => {
test('Should have proper page title', async ( => {…});
test('Should have toolbar', async () => {…});
test('Should have proper toolbar title', async () => {…});
});
test('Home page toolbar', async ({ page }) => {
await test.step('Should have proper page title', async () => {…});
await test.step('Should have toolbar', async () => {…});
await test.step('Should have proper toolbar title', async () => {…});
});
Example of HTML report of identical tests: one with describe and child tests, another with child steps
Example of HTML report of identical tests: one with describe and child tests, another with child steps

test.fixme

test('Should have proper page title', async () => {
test.fixme();
await expect(page, 'Should have "Home" in title').toHaveTitle(/Home/);
});
Example of skipped test in a list reporter
Example of skipped test in a list reporter

Explore Selectors in Playwright Inspector

Example of exploring selector
Example of exploring selector

--

--

Quality assurance engineer: I’m testing web applications, APIs and doing automation testing.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrey Enin

Quality assurance engineer: I’m testing web applications, APIs and doing automation testing.