Key Changes

  • HAR Recording on Tracing: tracing.startHar() and tracing.stopHar() are now first-class tracing APIs. This allows for scoped HAR recordings using await using, simplifying network traffic capture during tests.
    await using har = await context.tracing.startHar('trace.har');
    const page = await context.newPage();
    await page.goto('https://playwright.dev');
    // HAR is finalized when `har` goes out of scope.
    
  • Drop API: The new locator.drop() method simulates external drag-and-drop actions, supporting files or data. This is valuable for testing upload zones and interactive elements, working consistently across browsers.
    await page.locator('#dropzone').drop({
      files: { name: 'note.txt', mimeType: 'text/plain', buffer: Buffer.from('hello') },
    });
    
  • Aria Snapshots: expect(page).toMatchAriaSnapshot() now works directly on a Page object. A new boxes option for ariaSnapshot() adds bounding box coordinates, aiding AI-driven accessibility testing.
  • Test Control: test.abort() allows immediate test failure from fixtures, hooks, or route handlers with a custom message. This helps in managing unrecoverable test scenarios.
    test('does not publish to the shared page', async ({ page }) => {
      await page.route('**/publish', route => {
        test.abort('Tests must not publish to the shared page. Use the `clone` option.');
        return route.abort();
      });
      // ...
    });
    
  • New APIs: Playwright v1.60.0 introduces several new APIs for finer control and improved event handling. The browser.on('context') event allows monitoring new browser contexts, while BrowserContext now mirrors page lifecycle events like download, frameattached, pageclose, and pageload. This simplifies managing events across multiple pages within a context. For locators, getByRole() gains a description option, enabling more precise accessibility testing by matching the accessible description. expect(locator).toHaveCSS() can now inspect computed styles of pseudo-elements (::before, ::after) using the pseudo option. Visual debugging is enhanced with locator.highlight() supporting a style option for custom overlays, and page.hideHighlight() to clear them. Network control is also improved with webSocketRoute.protocols() to retrieve requested WebSocket subprotocols and browserType.connectOverCDP() offering a noDefaults option to disable Playwright’s default overrides.

Impact for QA Teams

These updates enhance test automation capabilities, particularly for network interaction, drag-and-drop scenarios, and accessibility testing. QA engineers can write more precise and reliable tests, improving test suite stability and coverage. For those new to Playwright, our Playwright tutorial for web testing provides a great starting point.