Playwright vs. Cypress vs. Selenium — Part 02
In Part 01, we looked at what Playwright is and what the main features of Playwright are. This article will be a comparison between two major automation frameworks, which are Cypress and Selenium.
What is Cypress?
Cypress is a pure JavaScript-based front-end testing tool designed for the modern web. It aims to solve the problems developers or QA engineers face when testing applications. Cypress is a more developer-friendly tool that uses a unique DOM manipulation technique and works directly in the browser.
What is Selenium?
Selenium is a free (open-source) framework for automated testing used to validate web applications in various browsers and platforms. It provides a single interface that allows you to write test scripts in programming languages such as Ruby, Java, NodeJS, PHP, Perl, Python, and C#.
Main requirements
The comparison will be gone through several key requirements for an automation framework. For each requirement, the support or availability of each framework is discussed.
Behavior Driven Framework support
Selenium: Yes
Cypress: Yes
Playwright: Yes
Data-Driven Framework support
Selenium: Yes
Cypress: Yes
Playwright: Yes
Supported Scripting languages
Selenium: Java, Python, C#, Ruby, JavaScript, Kotlin
Cypress: JavaScript
Playwright: JavaScript, TypeScript, Python, Java, .NET
Test data management
Selenium: Can use CSV, DB, Excel, Json, Properties, Config
Cypress: Can use CSV, DB, Excel, Json, Config, or Fixtures
Playwright: Can use CSV, DB, Excel, Json, Config
Runner solutions
Selenium: Need an external runner
Cypress: Has own runner solution (No way to configure external runners)
Playwright: Has own runner solution (Can configure external runners like JUnit or Jest)
Test execution
Selenium: Selenium Webdriver, Selenium Grid
Cypress: Can execute as a node module using npx commands
Playwright: Can be executed by official execution commands according to the language that uses
Cross-Domain Support
Selenium: Yes
Cypress: No
Playwright: Yes
Timeouts
Selenium: Configurable
Cypress: Configurable
Playwright: Configurable
Element Selectors
Selenium: Xpath, CSS, text, and custom selectors
Cypress: Xpath, CSS, text, and custom selectors
Playwright: Xpath, CSS, text, and custom selectors
Headless Execution
Selenium: Configurable
Cypress: Support by default
Playwright: Support by default
Parallel test execution
Selenium: Can achieve by using third-party plugins like TestNG
Cypress: Available in the pro version but you can use Sorry Cypress for parallelization
Playwright: Support and inbuilt available
Multi Tab Support
Selenium: Yes
Cypress: No
Playwright: Yes
Cross Browser Support
Selenium: Supports all webdriver-supported browsers
Cypress: Chrome, Edge, Firefox, Electron (Safari is yet to come)
Playwright: Chrome, Edge, Firefox, Opera, Safari
Cross-device Support
Selenium: Mobile (Native IOS, Android) Appium support and Web
Cypress: Supports web and mobile web
Playwright: Supports web and mobile web
CI Support
Selenium: Supported
Cypress: Supported
Playwright: Supported
Reporting Tool Integration
Selenium: Supports a lot of reporting tools
Cypress: Supports any reporting tool built on top of Mocha
Playwright: Has built-in reporters, and external reporters can be configured
Performance
Selenium: Good
Cypress: Good
Playwright: Best
This analysis is used to compare the performance of the frameworks
Drag & Drop Support
Selenium: Supported
Cypress: Supported but a bit complex when compared with others
Playwright: Supported and offers a simple function
Dynamic/fluent wait
Selenium: Configurable
Cypress: Designed around the fluent wait pattern
Playwright: Designed around the fluent wait pattern
Screenshots and video recording
Selenium: Can use extensions to configure
Cypress: Supports videos and screenshots
Playwright: Supports videos and screenshots
Technology stack
Selenium: Supports multiple languages
Cypress: Only works with JavaScript
Playwright: Supports multiple languages
iFrame and Shadow DOM support
Selenium: Supported, and there are external libraries as well
Cypress: Bit complex to handle in some situations
Playwright: Supports well
Conclusion
If you look into the above requirement factors, you will find that Playwright meets the requirements, although it is relatively new on the market. This is the second article of the Playwright series, and the goal is to create a hybrid test automation framework using Playwright. So stay tuned.