Cypress vs Selenium

Mohamed Yaseen
Nerd For Tech
Published in
5 min readApr 20, 2021

I would contrast the two most exciting tools that are considered game-changers from the large list of automation research tools available on the market.

Here’s the million-dollar question: is Cypress more than a web automation platform or a replacement for Selenium?

This story would make a thorough comparison to illustrate how both methods work for automation tests and which method under various situations has the upper hand.

In a Nutshell
Cypress is a web-built test platform for the next generation. It was developed on Mocha and Chai and it is a JavaScript-based end-to-end Test Platform.
Selenium is an open-source testing platform used for web browser automation. Selenium WebDriver drives a browser locally or remotely and is used for UI automation checking. The other elements often have a particular role to play concerning the reliability and robustness of the product.

Architecture
Cypress runs on an application’s same run loop. The server method behind Cypress is Node.js. The Cypress process and the Node.js process interact, sync, and execute tasks with each other continuously. Also, Cypress works on the network layer by interpreting and modifying the web traffic. This allows Cypress not only to edit all of the browsers but also to update codes that can affect the browser automation.
In Selenium, when we run the Selenium automation script, the Selenium client library communicates with Selenium API, which sent a binding command to a browser driver with the assistance of the JSON wire protocol. The browser driver uses the HTTP registry to filter out all executive instructions of the HTTP request and the HTTP server. Then the commands on the browser run in the selenium script, and the HTTP server returns the reply to the automation test script.
Based on their internal operating architecture, Selenium performs remote commands on the network, while Cypress operates in the same run-off as your program.

Installation
There is no setup in Cypress, just install the.exe and automatically configure all the drivers and dependencies. Automation can be configured to run in minutes. One of Cypress’s design philosophies was to make the whole testing process a comfortable and convenient one for the developers, packaging and uniting.
You must install the language linking libraries for your preferred language to use Selenium in your automation project. Furthermore, for browsers you want to automatically run checks, you’ll need WebDriver binaries.
If we also take account of implementation time and difficulty, Cypress has the upper hand over Selenium.

Languages Supported
Only JavaScript is supported by Cypress. There is no support for other languages that sometimes force the user to learn a certain scripting language.
Selenium, however, supports a broad variety of Java, C#, Python, Ruby, R, Dar, Objective-C, Haskell, and PHP languages as well as JavaScript.
Since Selenium is supported by many languages, it is helpful for users to consider which language they would want to use to build an Automation Platform.

Cross-browser Support
Cypress supports Canary, Chrome, Chromium, Edge, Edge Beta, Edge Canary, Edge Dev, Electron, Firefox (Beta support), Firefox Developer Edition (Beta support), Firefox Nightly (Beta support).
Selenium supports almost all major browsers in the market, which is an added advantage for Selenium. Below is the list of supported browsers: Chrome(All versions), Firefox(54 and newer), Internet Explorer(6 and newer), Opera(10.5 and newer), Safari(10 and newer)
Selenium has better cross-browser support as compared to Cypress because Selenium gives support to almost all available browsers available in the market whereas Cypress you can’t test on Safari.

Parallel Execution of Test Automation Suite
In comparison with Selenium in parallel checking, cypress falls behind.
Selenium has many choices for parallel performance which for automation testing is very significant. The Grid is used commonly in the QA community with TestNG for parallel implementation. And Docker containerization can quickly be integrated.

Performance
As several architecture layers as Selenium do not have Cypress. It works in a browser in the same way. That’s why we see a significant improvement over selenium in the speed of test performance.
Selenium has multiple levels of code between the test and browsing, which is relatively sluggish compared with Cypress.

Integration of Automation with CI/CD
Cypress: Possible but restricted. There is only one alternative available for the command line and the npm library, Mocha. Mocha. The CI service must support npm and test recording for most recordings on the CI server is a paying choice.
Selenium: CI/CD incorporation possible. Selenium. Any test library, test notes, and execution patterns can be used and can be adapted to the requirements quickly.

Licensing
Cypress is also available under the MIT license as an open-source. However, if we compare it to Selenium, all Cypress functions are not free, for example, the Cypress dashboard is free for seed and pay for Sprout, Tree, and Forest. (https://www.cypress.io)
Selenium is authorized under the Apache 2.0 license, with the copyright holder Software Freedom Conservation.

OS Support
Cypress: Windows, Mac, Linux
Selenium: Windows, Linux, Mac, Android, iOS

Support for BDD & DataDrivenTesting
Selenium supports BDD and data-driven with the aid of external libraries, which is not feasible in Cypress from now on.

Locators for Object Identification
Only CSS and Xpath are supported by Cypress.
Supports all kinds of web applications such as ID, Name, XPath, CSS selectors, text links, text partial links, etc. Support.

Report on execution
Selenium: Extent, Allure, and any other dashboard can be implemented in automation suites.
Cypress: The native Dashboard is just Cypress.

The Final Verdict
Selenium focuses more on the test automation engineer and Cypress focuses more on developers to boost TDD production. Selenium was introduced in 2004, so it has more support for the ecosystem than Cypress, which was developed in 2015 and continues to expand. When we are using Selenium, several different choices such as Cookies, Local Save, Screen, Sizes, Extensions, Cypress control line options can be manipulated in the browser but the network option can only be handled if Cypress is used.

However, some of the selling points, which Cypress claims, are:
1. The program will take screenshots while the experiments are running. We can then float over each order as a test developer in the Test Runner panel to see what has happened at each stage.
2. No clear waiting or sleep is required for your testing with CYPRESS. Before continuing, it immediately waits for commands and statements.
3. similar to unit test cases, Cypress spies and cabinets can validate and check the actions of functions, server responses, or timepieces on time. You can stub network traffic with Cypress, and personalize your API calls according to your needs.

Hopefully, the above points will help determine which method to use and explore.

--

--

Mohamed Yaseen
Nerd For Tech

Experienced QA Automation Lead with expertise in test automation, frameworks, and tools. Ensures quality software with attention to detail and analytical skills