Microsoft's new Python tool makes web app testing easier using PlayWright JS

Microsoft has announced a new API tool allowing developers to write Python-based web applications across Chrome, Chromium-based Edge, Safari, and Mozilla Firefox.

Playwright library allows developers to control the browser with just a few lines of Python code.

For instance taking a screen shot from a web page in Python is now as easy as: 

from playwright import sync_playwright

with sync_playwright() as p:
    for browser_type in [p.chromium, p.firefox, p.webkit]:
        browser = browser_type.launch()
        page = browser.newPage()

The library is designed to automate cross-browser testing for single page web app and Progressive Web Apps (PWAs). The Python library is currently in a preview form. It is designed to accelerate the web apps testing across Windows, macOS and Linux platforms. You can even use it to emulate smartphones of different screen sizes.

The library is currently in an early stage of development. It uses an event-driven architecture that can listen to precise browse events like DOM changes, network requests and page navigations. It also provides a standard surface to monitor and modify network traffic.

Here is the official Github library released.