GroTechMinds

comparison bw selenium & playwright

Comparison between Selenium and Playwright

Introduction

Automation testing has proven to be a more efficient way of testing software applications compared to manual testing owing to better test coverage resulting in customers getting a better quality of software application in a short period of time. Through Automation testing, testers are able to test even complex software applications which looked nearly impossible through manual testing. For many years Selenium has been one of the most efficient automation tools for automation testing of web applications as well as for browser automation and cross platform automation. 

Since a few years Playwright has also emerged as another automation tool for browser automation as well as for performing Web scraping. In this blog we are going to make a brief comparison between Selenium and Playwright.

Overview on Selenium

Selenium is one of the most famous open source, freely available automation tools used by automation testers and developers for browser automation as well as for cross platform automation.It is also used for web scraping which involves collecting the data from different websites for testing purposes. Selenium was launched in 2004 by Jason Huggins.

Testers write automation scripts using Selenium after configuring Selenium in programming languages like Java,PHP, Python and also by adding plugins like TestNG. Reports are generated through TestNG displaying the total number of test cases run, the time duration of each test run, the number of passed test cases and number of failed cases. Passed test cases refer to the action getting successfully performed on web application components through automation scripts and test cases failure refer to action not getting successfully performed on web application components. Selenium tool consists of various components like Selenium grid, Selenium IDE, Selenium WebDriver with the help of which Automation testing is performed effectively.

Advantages of Selenium
  • It is a free and open source tool easily available in the market.
  • It is an easily understandable tool.
  • It keeps on improving with every new update.
  • Selenium is compatible with different browsers like Chrome,FireFox,Edge etc.
  • Selenium is compatible with different operating systems like windows,linux,MacOS etc.
  • Using Selenium we can perform automation testing through automation scripts after configuration with different programming languages like Java,Python,PHP and Ruby on Rails.
  • Selenium consists of components like Selenium Grid, Selenium Webdriver and Selenium IDE which makes automation testing easier.
  • selenium ensures reusability of test scripts after configuring them with plugins like TestNG.
Disadvantages of Selenium
  • Using Selenium it is not possible to Automate Captcha.
  • Using Selenium we can only automate web based applications and we cannot automate mobile applications and standalone applications.
  • Selenium does not have an official document for determining status of test cases as a result testers have to depend on some third party tools for test reports like TestNg, Junit etc.
  • Selenium cannot be used  for performing API automation testing.
  • Not possible to perform image based testing like screenshot comparison using Selenium.
  • Using Selenium testers cannot perform OTP automation,scancode testing and barcode testing.
Overview on Playwright

Playwright is one of the newest and rapidly growing automation testing tools  for performing browser automation and web scraping. Since its inception in the year 2020 by Microsoft, playwright has become immensely popular among developers and automation testers. Using Playwright, Automation testers can perform testing through Automation scripts after configuring playwright with programming languages like Java,C#,Python and NodeJs,Java Script. Since its creation,Playwright has undergone numerous updates with addition of new features in each updates.

Playwright is also used for browser automation in different browsers like Chrome,Firefox, Edge etc. and in addition to these browsers it also supports browser automation in browsers like Chromium and Webkit. Playwright has  been developed  mostly  for performing  end to end testing. Playwright is also used for automation testing of web applications as well as mobile applications. With the help of Playwright testers can also perform API automation testing.

Advantages of Playwright
  • Using Playwright, testers can perform cross browser testing in different browsers like chrome,firefox, chromium etc. which involves running test scripts in different browsers one after another.
  • Playwright is helpful in automation testing of advanced web applications using React,NodeJs as well as in automation of more complex single page applications.
  • Playwright helps immensely in performing System testing which is also the end to end testing, involving navigation from the home page of the application to the last page of that application as well as interaction with different components of each page.
  • With the help of Playwright, testers can perform parallel testing using different browsers which involves running test scripts simultaneously in different browsers.
  • Using Playwright testers can keep a record of the test cases or scripts executed.
  • Playwright does not require the use of any wait command like explicit wait for running test scripts since it automatically performs wait actions. 
  • Testers can perform image based testing like screenshot comparison,visual comparison through playwright. 
  • Playwright can be used in performing automated regression testing by integrating with CI/CD pipeline to make sure that any code changes do not affect the existing functionality of the application.
  • Using Playwright automation scripts can be run in different operating systems like windows, Linux and MacOS.
  • Testers can also perform mobile testing effectively using Playwright
Disadvantages of Playwright
  • Playwright is not compatible with Safari Browser.
  • Since it is relatively new to the market, sometimes effective test execution may not happen.
  • Although Playwright supports mobile application testing,it still does not support automation testing of native mobile applications.
  • Playwright is difficult to learn for those people who have zero knowledge of coding.
  • Not suitable for performing unit testing.
  • Playwright does not support cloud based testing.
  • Whenever testers do not perform cross browser testing, use of playwright becomes unnecessary. 
  • For very small projects with limited budget usage of playwright is not justifiable.
When to use Playwright over Selenium

We use Playwright in following scenarios:

  1. For collection of excessive datas from websites through web scraping
  2. For  testing advanced and modern web applications through browsers like Chromium,Webkit etc.
  3. For Constant behaviour of Automation scripts across different browsers.
  4. For smooth and effective headless browser testing.
  5. For  simultaneous automation testing of multiple web pages or tabs.
  6. For interaction with  complex components of web applications and web pages.
  7. For performing API automation and mobile application testing.
  8. For performing parallel and cross browser testing of modern web applications.
When to use Selenium over Playwright

We use Selenium in following scenarios:

  1. For performing browser automation using different browsers like Chrome, Firefox, Edge, as well as browser automation with browsers like Safari which do not support Playwright.
  2. Whenever we need to perform browser automation in different programming languages we use Selenium.
  3. For projects which require larger community support, more documentation and high stability,selenium is used.
  4. If any existing project is done using Selenium,it is better to continue with the Selenium tool instead of doing that project with other tools.
Playwright and Selenium Comparison

Given below are some of the differences and similarities between Selenium and Playwright

Playwright Selenium
Supports cross browser automation in multiple browsers like chrome,firefox,chromium,webkit and does not require webdriver installations since drivers are in built. Supports cross browser automation in multiple browsers like chrome,firefox,edge,safari and requires webdriver installations.
It is an open source freely available tool licensed by Apache 2.0. It is an open source freely available tool licensed by Apache 2.0.
Playwright supports various programming languages like C#,Java,Python,NodeJS, JavaScript etc. Selenium supports various programming languages like PHP,Java,Python,Ruby on Rails etc.
Playwright supports running of test scripts through inbuilt test plugins as well as through third party tools like Mocha ,Jest ,Jasmine etc. Selenium does not support running of test scripts through inbuilt test plugins but rather it depends on third party tools likeTestNG,Junit, Mocha ,Jest ,Jasmine etc. for running test scripts.
Playwright supports various operating systems like windows,macOS and Linux for performing cross platform testing. Selenium supports various operating systems like windows,macOS,Ubuntu and Linux for performing cross platform testing.
It does not require browser specific drivers for performing parallel testing and cross browser testing. It requires browser specific drivers for performing parallel testing and cross browser testing.
The architecture of Playwright is that it follows Web Socket protocol. The architecture of Selenium is that it follows JSON wire/HTTP protocol.
It supports API Automation and mobile application testing. It does not support API Automation and mobile application testing.For mobile application testing a third party tool like Appium is required.
It can be used for visual and screenshot comparison. It cannot be used for visual and screenshot comparison.
Supports CI/CD integration. Supports CI/CD integration.
Conclusion

From the above information regarding Selenium and Playwright it is concluded that both Selenium and Playwright have their own advantages and disadvantages. Some limitations of Selenium are overcome by Playwright and some limitations of Playwright are being overcome by Selenium. Since Playwright is a relatively new automation tool it has a much better scope for improvement. On the other hand Selenium being the oldest automation tool it has better Community support across the globe. So both Selenium and Playwright are proving to be immensely advantageous for developers and testers for automation testing of complex applications in a short period of time.

 

Upskill Yourself
Consult Us