DEV Community

Cover image for Playwright ?
Vibhanshu Jain
Vibhanshu Jain

Posted on

Playwright ?

I want to share about the trending tool Playwright, which I came across recently.

Playwright ?

Playwright is an End-to-End Testing framework, which comes with a lot of inbuilt features that you will require in any automation tool. Playwright tests anything that runs in a web browser. All of the architecture surroundings, It is built to handle modern JavaScript frameworks like React, Angular, Vue, Elm, etc.
In a nutshell, Playwright is a trending next generation front end testing tool built for the modern web

Playwright is all in one

When we say all in one, we don't need any other 3rd party tool to achieve our automation tasks/framework.
Unlike other tools, where we have to maintain and integrate multiple libraries to support automation framework, increasing the effort and cost required to maintain those libraries.
With Playwright, we don’t have to worry about any of these things, since most of the things which are required come along with Playwright itself.

Features of Playwright

There is multiple uniqueness, which makes Playwright one of the choices for Web automation. A few of them are:

Any browser • Any platform • One API

  • Cross-browser.
    Playwright supports all modern rendering engines including Chromium, WebKit, and Firefox.

  • Cross-platform.
    Test on Windows, Linux, and macOS, locally or on CI, headless or headed.

  • Cross-language.
    Use the Playwright API in TypeScript, JavaScript, Python, .NET, Java.

  • Test Mobile Web.
    Native mobile emulation of Google Chrome for Android and Mobile Safari. The same rendering engine works on your Desktop and in the Cloud.

Resilient • No flaky tests

  • Auto-wait.
    Playwright waits for elements to be actionable prior to performing actions. It also has a rich set of introspection events. The combination of the two eliminates the need for artificial timeouts - the primary cause of flaky tests.

  • Web-first assertions.
    Playwright assertions are created specifically for the dynamic web. Checks are automatically retried until the necessary conditions are met.

  • Tracing.
    Configure test retry strategy, capture execution trace, videos and screenshots to eliminate flakes.

No trade-offs • No limits
Browsers run web content belonging to different origins in different processes. Playwright is aligned with the modern browsers architecture and runs tests out-of-process. This makes Playwright free of the typical in-process test runner limitations.

  • Multiple everything.
    Test scenarios that span multiple tabs, multiple origins and multiple users. Create scenarios with different contexts for different users and run them against your server, all in one test.

  • Trusted events.
    Hover elements, interact with dynamic controls, produce trusted events. Playwright uses real browser input pipeline indistinguishable from the real user.

  • Test frames, pierce Shadow DOM.
    Playwright selectors pierce shadow DOM and allow entering frames seamlessly.

Full isolation • Fast execution

  • Browser contexts.
    Playwright creates a browser context for each test. Browser context is equivalent to a brand new browser profile. This delivers full test isolation with zero overhead. Creating a new browser context only takes a handful of milliseconds.

  • Log in once.
    Save the authentication state of the context and reuse it in all the tests. This bypasses repetitive log-in operations in each test, yet delivers full isolation of independent tests.

Powerful Tooling

  • Codegen.
    Generate tests by recording your actions. Save them into any language.

  • Playwright inspector.
    Inspect the page, generate selectors, step through the test execution, see click points, and explore execution logs.

  • Trace Viewer.
    Capture all the information to investigate the test failure. Playwright trace contains test execution screencast, live DOM snapshots, action explorer, test source, and many more.

I have not covered coding and architecture as it will confuse the new readers.
Thanks for the read let me know what things you are interested in about this tool and what you want to know more.

Official Playwright link: https://playwright.dev/docs/intro

Top comments (2)

Collapse
 
ccleary00 profile image
Corey Cleary • Edited

In my experience Playwright has worked much better and much more stable than Cypress (which seemed to be popular for awhile and maybe still is). Tests are easier to write, it's easier to use, and it's basically my default for E2E tests at this point.

Collapse
 
vibhanshujain profile image
Vibhanshu Jain

Cypress is mostly popular for single-page web apps.
I have also used it for some time but I often got confused by their chaining methods
like .then() ..etc
Playwright supports everything it's the ultimate tool for modern web