Cypress vs Selenium

Profile picture for user devraj

Cypress and Selenium are test automation tools used for functional testing of web applications by automating browser actions. Selenium has been a widely-used tool for years, whereas Cypress is a recently introduced tool in the test community.

In spite of Cypress being recently introduced, it has gained significant traction, With such a significant growth in the adoption of Cypress, it’s natural for testers to compare the two before choosing the ideal tool for test automation.

So, the question is, how does Cypress compare to Selenium? Is Cypress a better alternative to Selenium? Like Selenium, Cypress is also an open-source test automation framework for testing web applications. And that’s where the big Cypress vs Selenium fight begins! 

Point of DifferenceSeleniumCypress
Language SupportedSupports all popular languages like JavaScript, Java, Python, Ruby, C#, Php, etc.Support JavaScript Only
Browsers SupportedChrome, IE, Safari, Edge, Firefox, OperaChrome, Edge, Firefox, Electron, Brave. In Version 10.8.0 Safari browser support is added using Playwright-Webkit.
Framework SupportedPyUnit, JUnit, TestNG, JBehave, Behave, Gauge, Specflow, NUnit, Robot, Mocha and more.Supports only Mocha JS
Setup ComplexitySetup is a bit challenging as it requires downloading browser-specific drivers and setting up the test environment. Selenium Grid Server and browser drivers have to be installed in the test machine. Even, setup is different for a cloud-based Selenium Grid where only browser drivers have to be installed on the test machine.Setup is simple. No dependencies or additional downloads required. Node JS, Mocha JS, and Cypress have to be installed on the test machine.
Integration with Other toolsWide range of integration options – CI/CD tools, reporting tools, and more.Limited integration support with CI/CD tools when compared to Selenium.
Driver DependenciesAppropriate browser driver has to be installed so that the test script can talk to the corresponding web browser.No driver dependency
Multiple TabsSupportedNot Supported - Workaround present
Multiple Browser Instances or DomainsSupportedNot Supported - Workaround present
iFrameSupportedNot Supported - workaround present
Execution SpeedSlowFast
Automatic WaitingNot SupportedNo requirement to add waits or sleep in the tests. Cypress automatically waits for commands and assertions before moving to the next instruction.
Default Screenshots and VideosNot Supported, write code for supportSupported by default
Network traffic ControlNot Supported - Workaround presentNo network lag as tests are executed within the browser. You can control, stub, and test edge cases without any involvement of the server.
Access to elements outside the DOMAccess only to the elements in the DOMA unique DOM manipulation technique helps Cypress in getting access DOM elements, timers, service workers, and more.
Documentation & Community SupportWell established documentation and firm community support from users across the globeVery intuitive documentation along with  rapidly growing community
Remote ExecutionSupported. Cloud-based Selenium Grid from LambdaTest can be used to expedite cross browser testing and automation testing.Not Supported
Mock Server, Spies, stubs, and clocksNot AvailableCypress has built-in facilities for mocking server responses, facilities that are crucial for their target audience: frontend developers. Cypress lets you control the behavior of functions, timers, and server responses with ease.
Mobile TestingMobile Testing with AppiumNot Supported
Test FlakinessTests can be flakyWith Cypress, tests are expected to be non-flaky. Because the tests on it are executed frontend only, with a mocking of all server responses, the test runs very fast. And the faster a browser test runs, the less flaky it is.
Time TravelNot SupportedSupported. Once the test ends, you can click on each command in the side panel, and you can see a screenshot of how the page looked like when the command was executing. This is called Time traveling.
Real Time reloadsNot supportedTests are reloaded when any change is made in the test implementation.
AsynchronousNoYes, cypress commands are asynchronous

Although Selenium and Cypress are both designed to automate browsers for testing purposes, they differ considerably in terms of architecture and performance. 

If your web application is built using modern JavaScript frameworks like React or Angular or any other JavaScript framework. and cross browser testing is not of high priority, Cypress might suit the best. When it comes to cross browser testing, Selenium is still the de-facto framework used by many users.

There is no clear winner in the Cypress vs Selenium debate. A better approach would be evaluating both the tools and seeing how Selenium and Cypress can be used to improve test coverage for your project.

Needless to say, prior to choosing an automation tool, one must weigh the pros and cons of every option.