playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

APACHE-2.0 License

Downloads
85.1M
Stars
66.1K
Committers
574

Bot releases are hidden (Show)

playwright - v1.31.1

Published by mxschmitt over 1 year ago

Highlights

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

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
playwright - v1.31.0

Published by dgozman over 1 year ago

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 in playwright.config.
  • New option maxRedirects for method Route.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
playwright - v1.30.0

Published by dgozman over 1 year ago

🎉 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
playwright - v1.29.2

Published by aslushnikov almost 2 years ago

Highlights

https://github.com/microsoft/playwright/issues/19661 - [BUG] 1.29.1 browserserver + page.goto = net::ERR_SOCKS_CONNECTION_FAILED

Browser Versions

  • Chromium 109.0.5414.46
  • Mozilla Firefox 107.0
  • WebKit 16.4

This version was also tested against the following stable channels:

  • Google Chrome 108
  • Microsoft Edge 108
playwright - v1.29.1

Published by aslushnikov almost 2 years ago

Highlights

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

Browser Versions

  • Chromium 109.0.5414.46
  • Mozilla Firefox 107.0
  • WebKit 16.4

This version was also tested against the following stable channels:

  • Google Chrome 108
  • Microsoft Edge 108
playwright - v1.29.0

Published by aslushnikov almost 2 years ago

New APIs

  • 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;
    

Miscellaneous

Browser Versions

  • Chromium 109.0.5414.46
  • Mozilla Firefox 107.0
  • WebKit 16.4

This version was also tested against the following stable channels:

  • Google Chrome 108
  • Microsoft Edge 108
playwright - v1.28.1

Published by aslushnikov almost 2 years ago

Highlights

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

Browser Versions

  • Chromium 108.0.5359.29
  • Mozilla Firefox 106.0
  • WebKit 16.4

This version was also tested against the following stable channels:

  • Google Chrome 107
  • Microsoft Edge 107
playwright - v1.28

Published by aslushnikov almost 2 years ago

Playwright Tools

  • Record at Cursor in VSCode. You can run the test, position the cursor at the end of the test and continue generating the test.
  • Live Locators in VSCode. You can hover and edit locators in VSCode to get them highlighted in the opened browser.
  • Live Locators in CodeGen. Generate a locator for any element on the page using "Explore" tool.
  • Codegen and Trace Viewer Dark Theme. Automatically picked up from operating system settings.

Test Runner

New APIs

Browser Versions

  • Chromium 108.0.5359.29
  • Mozilla Firefox 106.0
  • WebKit 16.4

This version was also tested against the following stable channels:

  • Google Chrome 107
  • Microsoft Edge 107
playwright - v1.27.1

Published by yury-s about 2 years ago

Highlights

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

Browser Versions

  • Chromium 107.0.5304.18
  • Mozilla Firefox 105.0.1
  • WebKit 16.0

This version was also tested against the following stable channels:

  • Google Chrome 106
  • Microsoft Edge 106
playwright - v1.27.0

Published by dgozman about 2 years ago

Locators

With these new APIs, inspired by Testing Library, writing locators is a joy:

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.

Other highlights

  • 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.

Behavior Changes

  • 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" }]]
    

Browser Versions

  • Chromium 107.0.5304.18
  • Mozilla Firefox 105.0.1
  • WebKit 16.0

This version was also tested against the following stable channels:

  • Google Chrome 106
  • Microsoft Edge 106
playwright - v1.26.1

Published by aslushnikov about 2 years ago

Highlights

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]

Browser Versions

  • Chromium 106.0.5249.30
  • Mozilla Firefox 104.0
  • WebKit 16.0

This version was also tested against the following stable channels:

  • Google Chrome 105
  • Microsoft Edge 105
playwright - v1.26.0

Published by aslushnikov about 2 years ago

Assertions

Other Highlights

  • New option maxRedirects for apiRequestContext.get(url[, options]) and others to limit redirect count.
  • New command-line flag --pass-with-no-tests that allows the test suite to pass when no files are found.
  • New command-line flag --ignore-snapshots to skip snapshot expectations, such as expect(value).toMatchSnapshot() and expect(page).toHaveScreenshot().

Behavior Change

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.

Browser Versions

  • Chromium 106.0.5249.30
  • Mozilla Firefox 104.0
  • WebKit 16.0

This version was also tested against the following stable channels:

  • Google Chrome 105
  • Microsoft Edge 105
playwright - v1.25.2

Published by aslushnikov about 2 years ago

Highlights

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

Browser Versions

  • Chromium 105.0.5195.19
  • Mozilla Firefox 103.0
  • WebKit 16.0

This version was also tested against the following stable channels:

  • Google Chrome 104
  • Microsoft Edge 104
playwright - v1.25.1

Published by aslushnikov about 2 years ago

Highlights

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

Browser Versions

  • Chromium 105.0.5195.19
  • Mozilla Firefox 103.0
  • WebKit 16.0

This version was also tested against the following stable channels:

  • Google Chrome 104
  • Microsoft Edge 104
playwright - v1.25.0

Published by aslushnikov about 2 years ago

VSCode Extension

  • 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 Runner

  • 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);
    });
    
  • Added test.describe.fixme(title, callback).

  • 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.

Announcements

  • 🎁 We now ship Ubuntu 22.04 Jammy Jellyfish docker image: mcr.microsoft.com/playwright:v1.25.0-jammy.
  • ðŸŠĶ This is the last release with macOS 10.15 support (deprecated as of 1.21).
  • ðŸŠĶ This is the last release with Node.js 12 support, we recommend upgrading to Node.js LTS (16).
  • ⚠ïļ Ubuntu 18 is now deprecated and will not be supported as of Dec 2022.

Browser Versions

  • Chromium 105.0.5195.19
  • Mozilla Firefox 103.0
  • WebKit 16.0

This version was also tested against the following stable channels:

  • Google Chrome 104
  • Microsoft Edge 104
playwright - v1.24.2

Published by aslushnikov about 2 years ago

Highlights

This patch includes the following bug fixes:

https://github.com/microsoft/playwright/issues/15977 - [BUG] test.use of storage state regression in 1.24

Browser Versions

  • Chromium 104.0.5112.48
  • Mozilla Firefox 102.0
  • WebKit 16.0

This version was also tested against the following stable channels:

  • Google Chrome 103
  • Microsoft Edge 103
playwright - v1.24.1

Published by aslushnikov about 2 years ago

Highlights

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

Browser Versions

  • Chromium 104.0.5112.48
  • Mozilla Firefox 102.0
  • WebKit 16.0

This version was also tested against the following stable channels:

  • Google Chrome 103
  • Microsoft Edge 103
playwright - v1.24.0

Published by aslushnikov about 2 years ago

🌍 Multiple Web Servers in 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;

🐂 Debian 11 Bullseye Support

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 ✅ ✅ ✅ ✅

ðŸ•ĩïļ Anonymous Describe

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 }) => {
    // ...
  });
});

ðŸ§Đ Component Tests Update

Playwright 1.24 Component Tests introduce beforeMount and afterMount hooks.
Use these to configure your app for tests.

Vue + Vue Router

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);
});

React + Next.js

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;
});

Browser Versions

  • Chromium 104.0.5112.48
  • Mozilla Firefox 102.0
  • WebKit 16.0

This version was also tested against the following stable channels:

  • Google Chrome 103
  • Microsoft Edge 103
playwright - v1.23.4

Published by yury-s over 2 years ago

Highlights

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)

Browser Versions

  • Chromium 104.0.5112.20
  • Mozilla Firefox 100.0.2
  • WebKit 15.4

This version was also tested against the following stable channels:

  • Google Chrome 103
  • Microsoft Edge 103
playwright - v1.23.3

Published by aslushnikov over 2 years ago

Highlights

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

Browser Versions

  • Chromium 104.0.5112.20
  • Mozilla Firefox 100.0.2
  • WebKit 15.4

This version was also tested against the following stable channels:

  • Google Chrome 103
  • Microsoft Edge 103
Package Rankings
Top 0.21% on Npmjs.org
Top 4.06% on Proxy.golang.org
Badges
Extracted from project README
npm version Chromium version Firefox version WebKit version Join Discord