Cypress VC Selenium

I would like to compare two of the most interesting tools that are considered “game changers” from the large list of automation research tools available on the market.

Here’s a million dollar question for you: Is Cypress more than a web test automation platform and can it replace Selenium?

This article will do a thorough comparison to illustrate how both methods work to automate tests and which method is superior in different situations.

Short description

Cypress is the next generation web test platform. It was developed on the basis of Mocha and Chai and is a JavaScript-based end-to-end testing framework.

Selenium is an open source testing framework used for web browser automation. Selenium WebDriver controls the browser locally or remotely and is used to test UI automation. Other Selenium elements often play a special role in product reliability and durability.

Architecture

Cypress runs in one cycle of application execution. Node.js. is the server-side method at the heart of Cypress. Cypress and Node.js processes constantly interact, synchronize and perform tasks together. In addition, Cypress works at the network level, interpreting and modifying web traffic. This allows Cypress to not only edit all browsers, but also update codes that can affect browser automation.

In Selenium, when we run the Selenium automation script, the Selenium client library interacts with the Selenium API, which sends a bind command to the browser driver using a wired JSON protocol. The browser driver uses the HTTP registry to filter all HTTP request and HTTP server control commands. The browser commands are then executed in the selenium script and the HTTP server responds to the automated test script.

Based on the internal operating architecture, Selenium executes remote commands over the network, while Cypress runs in the same script as your program.

Installation

There is no preconfiguration in Cypress, just install the .exe file and automatically configure all drivers and dependencies. Automation can be done in minutes. One of Cypress’s design philosophies was to make the entire testing process convenient and comfortable for developers, packaging and bundling.

To use Selenium in an automation project, you need to install the language linking libraries to use your preferred language. Also, for the browsers for which you want to run checks automatically, you will need the binaries for WebDriver.

If we also take into account the time and complexity of the implementation, here Cypress has an edge over Selenium.

Supported languages

Cypress only supports JavaScript. There is no support for other languages, which sometimes forces the user to learn a specific scripting language.

Selenium, in turn, supports a wide range of Java, C #, Python, Ruby, R, Dar, Objective-C, Haskell and PHP languages, as well as JavaScript.

Since Selenium is supported in many languages, it is helpful for users to think about which language they would like to use to build their 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 on the market, which is an added benefit of Selenium. Below is a 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 than Cypress because Selenium provides support for almost all browsers available on the market, while in Cypress you cannot test on Safari.

Parallel execution of an automated test suite

Compared to Selenium in parallel checkout, cypress lags behind.

Selenium has many options for parallel execution, which is very important for test automation. Grid is widely used in the QA community with TestNG for parallel execution. And Docker containerization can be quickly integrated.

Performance

Since Cypress does not have multiple architectural layers, unlike, for example, Selenium, it works in the same way in the browser. That is why we are seeing its significant advantage over Selenium in the speed of test execution.

Selenium has several levels of code between the test and the browser, which, for example, Cypress loses.

Integration of automation processes with CI / CD

Cypress: Possible but limited. There is only one alternative for the command line and npm library – Mocha. The CI service must support npm, and there will be a fee for recording tests for most of the entries on the CI server.

Selenium: CI / CD can be used. Any library of tests, their recording and execution templates can be used and quickly adapted to the requirements.

Licensing

Cypress is also available under the MIT license as open source. However, if you compare it to Selenium, all Cypress features are not free, for example, the Cypress dashboard is free for seed and paid for Sprout, Tree and Forest. (https://www.cypress.io)

Selenium is licensed under the Apache 2.0 license, copyright holder of Software Freedom Conservation.

OS support

Cypress: Windows, Mac, Linux

Selenium: Windows, Linux, Mac, Android, iOS

BDD and DataDrivenTesting support

Selenium supports BDD and data-driven with external libraries, which is not possible in Cypress.

Locators for identifying objects

Cypress only supports CSS and Xpath.

Cypress supports all kinds of web locators like ID, Name, XPath, CSS selectors, text links, text partial links, etc.

Implementation report

Selenium: Extent, Allure and any other dashboards can be implemented in automation kits.

Cypress: A dashboard is just Cypress.

Final verdict

Selenium is geared more towards test automation professionals, while Cypress is more geared towards developers to make TDD more efficient. Selenium was introduced in 2004, so it has more ecosystem support than Cypress, which was developed in 2015 and continues to expand. When we use Selenium, several different options can be manipulated in the browser like Cookies, Local Save, Screen, Sizes, Extensions, Cypress control line options, but the network option can only be handled when using Cypress.

However, here are some of the benefits Cypress claims to be:

  1. The program will take screenshots during the experiments. We can then view each request as a test developer in the Test Runner panel to see what happened at each stage.

  2. No standby or sleep is required for testing with Cypress. It expects commands and approvals immediately before continuing.

  3. Like unit test situations, Cypress spies can validate and validate function actions, server responses, or timers. With Cypress, you can damp network traffic and personalize API calls to suit your needs.

Hopefully the points above will help you determine which method is best for you to use and learn.


On the eve of the start of the course “Java QA Engineer. Professional” We invite everyone to a free two-day intensive, in which we will look at CI and CD processes, study the main tools and key concepts (Server, agents, jobs. Fail fast, Scheduling, WebHooks). Let’s take a closer look at the Jenkins software system and learn how to integrate it with git and Docker.

Sign up for an intensive:

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *