Introduction to Microsoft Playwright and its features in brief — Part 01

Introduction to Microsoft Playwright and its features in brief — Part 01

Microsoft Playwright?was released in 2011 as an open-source project built on top of?Puppeteer. It is relatively new on the market but has quickly gained popularity. The release history can be found in their official?GitHub Repository.

The following features are some unique and useful features regarding test automation. These items will be discussed later with code samples.

Cross-browser and Cross-language

Playwright started as a Javascript-based library, but they expanded it to support?TypeScript,?Python,?.NET, and?Java. The most interesting thing is that the playwright community has also built a?Go Library. The goal of Playwright is to provide developers and testers with a single API to automate their web applications across all modern rendering engines, including Chromium, WebKit, and Firefox.

Cross-platform

It is a cross-platform automation library, as it can run on Windows, Linux, and macOS, locally or in CI. Playwright launches?headless browsers?by default. Headless browsers do not display the UI, so it is necessary to use the command lines. Only one line in the configuration file needs to be changed to switch between headless and non-headless modes.

No alt text provided for this image
Supported languages, browsers and platforms

Test Mobile Web

It uses Native mobile emulation of Google Chrome for Android and Mobile Safari to test on the Mobile Web. The same rendering engine also works on Desktops and in the Cloud.

No alt text provided for this image
Native mobile emulation of Google Chrome

Auto-wait

Unlike other frameworks or libraries, Playwright waits for the elements to be actionable before performing actions automatically. This feature is called?Playwright Auto-wait. It auto-waits for all the relevant checks to pass and only then performs the requested action. If the required checks do not pass within the given timeout, the action fails with a TimeoutError.

Dynamic Web Assertions

In the case of?assertions, the checks are retried automatically until the required conditions are met. Playwright Test uses the?expect?the library to perform the test assertions. This library has a set of matchers that can apply to different scenarios. When it comes to tracing, it provides captured execution traces, videos, and screenshots to get rid of the flakes.

Supports for iFrame and Shadow DOM

IFrames and Shadow DOMs fully support the playwright. Therefore, the advanced test scripts can be executed seamlessly in iFrames and Shadow DOMs, even in multiple tabs.

Browser Context and Authentication Reusability

Tests are executed under full isolation since it creates a fresh browser context for each test. Creating a new browser context takes only a handful of milliseconds. Repetitive log-in operations can also be bypassed by reusing the authentication state of the context. This saves a considerable amount of execution time.


Conclusion

This is the first article in this Playwright series, and it will continue until a hybrid automation framework is built using Playwright, Allure reports, and Gitlab CI. So keep tuned in.

What’s next?

Playwright vs Cypress vs Selenium — Part 02


Originally published at https://harshasuraweera.medium.com/introduction-to-microsoft-playwright-and-its-features-part-0-1acde194fcce

Don Manula Udugahapattuwa

MSc. Cyber Security | CEH | MSc. Big Data Analytics | Performance Engineering

2 年

Hi Harsha, Checkout Sitespeed.io Should have similar capabilities. Maybe you can do a comparison. My article on sitespeed: https://lnkd.in/d3742rSv

要查看或添加评论,请登录

Harsha Suraweera的更多文章

社区洞察

其他会员也浏览了