Key Changes
- HAR Recording on Tracing:
tracing.startHar()andtracing.stopHar()are now first-class tracing APIs. This allows for scoped HAR recordings usingawait 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 aPageobject. A newboxesoption forariaSnapshot()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, whileBrowserContextnow mirrors page lifecycle events likedownload,frameattached,pageclose, andpageload. This simplifies managing events across multiple pages within a context. For locators,getByRole()gains adescriptionoption, enabling more precise accessibility testing by matching the accessible description.expect(locator).toHaveCSS()can now inspect computed styles of pseudo-elements (::before,::after) using thepseudooption. Visual debugging is enhanced withlocator.highlight()supporting astyleoption for custom overlays, andpage.hideHighlight()to clear them. Network control is also improved withwebSocketRoute.protocols()to retrieve requested WebSocket subprotocols andbrowserType.connectOverCDP()offering anoDefaultsoption 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.
