Say “Hi” to AI in New Playwright 1.51.1 Features

By Eduard Dublyer, CTO of Skipper Soft

As an expert in test automation and the CTO of Skipper Soft – a company providing Test Automation as a Service – I am constantly looking for new features that can enhance the efficiency and reliability of our automated testing solutions. The latest release of Playwright, version 1.51.1, introduces some exciting features that are bound to make the lives of test automation engineers much easier.

Let’s explore these new features and understand why they matter.


IndexedDB Storage State – Persistent Authentication Made Simple

One of the most frustrating issues for test automation engineers is handling authentication mechanisms that rely on IndexedDB. Until now, Playwright has allowed cookies and localStorage to be saved, but IndexedDB content was out of reach. With the latest release, you can save and restore IndexedDB contents using the indexedDB option in browserContext.storageState().

Why It’s Useful: This feature ensures you can quickly restore authenticated sessions, improving test speed and reliability for applications using IndexedDB for session storage, such as those with Firebase Authentication.

Example:

// Saving IndexedDB state const context = await browser.newContext(); await page.goto('https://example.com'); await context.storageState({ path: 'state.json', indexedDB: true }); // Restoring IndexedDB state const context = await browser.newContext({   storageState: 'state.json' });

AI-Friendly Debugging – A New Era of Intelligent Troubleshooting

Introducing a “Copy prompt” button makes interacting with AI tools much more effective. This feature generates structured prompts, including error messages and relevant contexts, which you can directly use with tools like ChatGPT.

Why It’s Useful: Debugging becomes much faster and more streamlined, especially when AI tools are part of your debugging workflow. It saves time for engineers and speeds up the process of finding root causes.


Visibility Filtering – Zeroing In On What Matters

Playwright now supports locator.filter() with a visible option, making it simpler to target only visible elements on the page.

Why It’s Useful: Writing tests for applications with complex UIs becomes significantly easier. It eliminates the need for complicated selectors and makes test scripts cleaner and more reliable.

Example:

await page.locator('.login-button').filter({ visible: true }).click();

Git Metadata in Reports – Enhanced Traceability

With the new captureGitInfo option, you can include Git commit and diff information directly in your HTML reports. This feature is invaluable for CI/CD pipelines.

Why It’s Useful: It improves collaboration between developers and testers by providing clear traceability between test results and code changes.

Example:

const config = {   reporter: [['html', { outputFolder: 'playwright-report', captureGitInfo: true }]] };

Enhanced Test Steps – More Control and Better Debugging

The introduction of TestStepInfo provides greater control over the execution of test steps. Now, you can add attachments or skip steps based on certain conditions.

Why It’s Useful: Creating dynamic test scenarios with conditional logic becomes a reality. It also provides detailed logging, making debugging simpler.

Example:

await test.step('Take screenshot if login fails', async () => {   if (!await page.locator('.dashboard').isVisible()) {     await page.screenshot({ path: 'error.png' });   } });

Conclusion

Playwright 1.51.1 brings impressive enhancements that address long-standing challenges in test automation. As the CTO of Skipper Soft, I strongly recommend adopting these features into your test automation frameworks to reduce maintenance overhead and improve overall testing efficiency. At Skipper Soft, we are excited to integrate these updates into our Test Automation as a Service offering, further improving the quality and speed of our testing solutions.

Stay tuned for more insights as we continue to push the boundaries of what’s possible in test automation!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *