From the vast list of automation testing tools available in the market, we will contend the two most promising tools that are contemplated as game-changers.
So here’s the million-dollar question: Whether Cypress is better than or a substitute for the most preferred web automation tool – Selenium?
This article will do an in-depth comparison to show how both tools serve the purpose of automation testing and which tool has the upper hand in different circumstances.
Let’s look at a few points that will help you make the call:
Selenium (latest release 4.0.0 Alpha 5) is an open-source tool used for automating the tests on web browsers. The Selenium WebDriver drives a browser natively; either locally or on remote machines and it is used for UI automation testing. Similarly, all the other components have a specific role to perform in terms of making the product more reliable and robust.
Cypress executes in the same run loop as application. Behind Cypress is a Node.js server process. Cypress and the Node.js process constantly communicate, synchronize, and perform tasks for each other. Cypress also operates at the network layer by reading and altering web traffic during processing. This enables Cypress to not only modify everything that emerges from the browser but also to change code that may interfere with its ability to automate the browser.
In Selenium, once we run the automation script in Selenium then the Selenium client library will communicate with Selenium API that will send the command taken from language level binding to browser driver with the help of JSON wire protocol. The browser driver will use the HTTP server for getting the HTTP request and the HTTP Server filter out all the commands that require execution. After that, the commands in your Selenium script executes on the browser and HTTP server sends the response back to the automation test script.
Based on their internal working architecture, we can say that Selenium executes remote commands through the network whereas Cypress runs in the same run-loop as your application.
In Cypress there’s no configuration, just need to install the .exe and all the drivers and dependencies get automatically installed and configured. This allows automation to be set up to get running in minutes. One of the design principles of Cypress was to be able to package and bundle everything together to make the entire end-to-end testing experience pleasant and simple for developers.
To use Selenium in your automation project you need to install the language binding’s libraries for your language of choice. Besides, you will need WebDriver binaries for the browsers you want to automate and run tests on.
So if we take installation time and complexity into consideration then Cypress has the upper hand as compared to Selenium.
Due to the support of many languages, Selenium comes handy and gives users the privilege to decide the language they want to use to develop an automation framework.
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.
Cypress falls behind when compared to Selenium in parallel testing.
Selenium has many options to perform parallel execution which is quite important for automation testing. Selenium component Grid is used widely for parallel execution in the QA community with TestNG. And it can be easily integrated with Docker containerization.
Cypress doesn’t have as many layers of architecture as Selenium. It operates on the same process in the browser. That is why we see a remarkable improvement in the pace of test execution compared to Selenium.
Selenium is relatively slow compared to Cypress as it has several layers of code running between the test and the browser.
Cypress: Possible but with restrictions. Only one option is available and that is by using the command line and the npm library – Mocha. The CI service has to support npm and test recording on the CI server is a paid option for most of the recordings.
Selenium: Possible to perform integration of CI/CD. We can use any testing library, test reports, and execution patterns and can easily adjust it to the needs.
Cypress is also released as open-source under the MIT license. But if we compare it to Selenium then all the features provided by Cypress are not free, e.g. the dashboard in Cypress is free for Seed but paid for Sprout, Tree, and Forest. (https://www.cypress.io/pricing)
Selenium is licensed under the Apache 2.0 license, with the Software Freedom Conservancy as the copyright holder
Cypress: Windows, Mac, Linux
Selenium: Windows, Linux, Mac, Android, iOS
Selenium supports BDD and data-driven by using external libraries, but as of now which is quite not possible to do in Cypress.
Cypress supports only CSS and Xpath.
Support all types of locators for a normal web application like ID, Name, XPath, CSS selectors, link text, partial link text, etc.
Selenium: Allure, Extent, and all other dashboards can be integrated into automation suites.
Cypress: Only Cypress Native Dashboard.
Selenium targets more towards the test automation engineer while Cypress is more developer-centric and aims to improve TDD development.
Selenium was developed in 2004 so it has better community support then Cypress which was developed in 2015 and still in the growing phase. In-fact when we work with the browser using Selenium it is possible to manipulate many options like Cookie, Local Storage, Screen, Sizes, Extensions, Command-line options but Cypress can only help to manipulate Network options.
However, some of the selling points, which Cypress claims, are:
Hope the above points will help to decide which tool to use for automation testing and on that note keep exploring. If you have any questions or suggestions email us at email@example.com or visit the Cloud QA website.
Submitted 2 day(s) ago by zuzucodesinc
Submitted 3 day(s) ago by garminmapupdate
Submitted 3 day(s) ago by garminmapsupport
Submitted 4 day(s) ago by genicsolutions