Selenium and Cypress – Which one to choose?

As a Test Automation Consultant, I tend to play around with most of the latest test automation tools and frameworks that are available in the market to suggest the right toolset for my customers.

I have been using Selenium for more than eight years now, and I still agree that it’s a GREAT tool and it is being used for more than a decade by millions of testers. Many Selenium-based open source and commercial products are developed, and these tools leverage a couple of drawbacks which Selenium itself has like managing driver dependencies, Script-less record and playback etc.,

As rightly said in this “The era of Non-Selenium automation testing tools 2019” article, we can see many non-selenium based test frameworks started gaining attention in the industry. Some of them are Cypress, Puppeteer, TestCafe etc.,

In this article, I thought of publishing a couple of differences I have observed between Selenium and Cypress based on my personal experience. I have been using Cypress for over eight months now, and I must admit that the tool is amazing with frontend automation.

Please note that I am not taking any sides here on any tools and this comparison is entirely for the users to understand the pros and cons of various features which both the tools offer.

So, at the time of writing this article, the number of weekly downloads from npmjs is ā€“

Selenium WebDriver
Cypress

Key Differences:

Selenium and Cypress are built with a different architecture, purpose and audience in mind. Selenium mainly focuses on a Testers point of view, whereas Cypress focuses on both Front-end Developers & Testers.

Let’s now see the plus side of Selenium against Cypress ā€“

SeleniumCypress
TestNG, JUnit, nUnit, xUnit, Cucumber, Mocha etc. Mocha
Remote executionNo Remote Execution Supported
Support for multiple tabs and cross domain testingNo direct multiple tabs support and only supports running tests in 1 domain
Excellent support for Cross-browser testing tools like BrowserStack, SauceLabs etc.,No 3rd party cross-browser testing tools support 
Excellent support for mobile testing like AppiumMobile testing not possible
Excellent community supportEvolving community support

Now, let’s see the plus side of Cypress against Selenium –

CypressSelenium
Faster executionSlower
No Driver DependenciesDifferent WebDriver versions for different browser versions
Built-in Mock Server, Spies & ClocksNo Mocking support
XHR Validation SupportNo XHR support, but can be achieved using 3rd party tools
Cypress Test Runner with features like Selector Playground, integration with Developer ToolsSelenium IDE (record and playback) is great, but not as good as Cypress
API Testing Support – End to End Testing ToolNo API Testing Support as Selenium is just a browser automation tool
Automatic retriesImplicit & explicit waits
Automatic screenshots & VideosNo automatic screenshots or videos
Easy install with one commandInstallation of multiple components
Clear error messagesError messages sometimes confusing (long stack trace errors)
Excellent documentationAverage documentation

Which one to choose?

Well, it completely depends on your requirement.

You can see where these tools stands in the Automation Pyramid.

Automation Pyramid

In case if your application is a modern web-based and needs a common tool between Frontend Developers and Testers, Cypress is the best tool.

If your requirement is based on IE and needs access to external tools like SauceLabs, BrowserStack, then Selenium is better for you.

Want to start learning Cypress?

Here is the best course for you, created by Karthik KK

Conclusion:

I hope this article gave you a glimpse of the differences between Cypress and Selenium. Always consider a tool that fulfils your requirements and think from the latest and longer-run perspective.

Happy Testing!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: