Playwright vs Selenium: A Comparison

What Is Playwright?

Playwright logo

Playwright by Microsoft is the newest addition to the Headless Browser Testing frameworks in popular use. Built by the same team which created Puppeteer (Headless Browser Testing Framework for Google Chrome), Playwright, too, is an open-source NodeJS based framework. 

However, it provides wider coverage for cross-browser testing by supporting Chrome, Firefox, and WebKit, while Puppeteer supports Chrome and Chromium browsers only. Playwright is compatible with Windows, Linux, and macOS, and can be integrated with major CI/CD servers such as Jenkins, CircleCI, Azure Pipeline, TravisCI, etc., in addition to the testing frameworks like Jest, Jasmine, Mocha. Besides JavaScript. 

In-memory Automated UI Testing ASP.NET Core

Introduction

In this article, we look at how to run in-memory automated UI tests for an ASP.NET Core web app using Playwright and NUnit. The article provides demo code and solutions to issues found along the way.

Automated UI Testing

Automated testing of any web application is essential to ensure it functions correctly.  On the top of the “testing pyramid” proudly sits UI testing or end-to-end testing, above integration and unit testing.  Automated UI testing involves launching and controlling a browser to drive through a set of interactions that a user would perform.  Assertions are made to see if the web app and browser behave as expected.  Browsers are controlled by testing tools such as Selenium,  Puppeteer, or the new kid on the block, Playwright.

How to Run Playwright Tests Sequentially in Same Browser Context

The Playwright is a new automation framework by Microsoft. The Playwright framework is distributed under MIT Open Source License. Playwright supports various programming languages such as Java, JavaScript, TypeScript, .Net, etc. 

Playwright Executes Each Scenario in Its Own New Browser Context

If you have worked with the Playwright framework you might have observed that if you write multiple tests inside the describe function, it gets executed one after another but each test runs in a separate browser context. That means that if you have performed a login in test1() it doesn't preserve those in test2(). The reason is that each time playwright executes the test, it creates a new context and executes the test. This feature also allows you to write independent tests and you can execute them parallelly with less execution time.