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 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 –
|TestNG, JUnit, nUnit, xUnit, Cucumber, Mocha etc.||Mocha|
|Remote execution||No Remote Execution Supported|
|Support for multiple tabs and cross domain testing||No 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 Appium||Mobile testing not possible|
|Excellent community support||Evolving community support|
Now, let’s see the plus side of Cypress against Selenium –
|No Driver Dependencies||Different WebDriver versions for different browser versions|
|Built-in Mock Server, Spies & Clocks||No Mocking support|
|XHR Validation Support||No XHR support, but can be achieved using 3rd party tools|
|Cypress Test Runner with features like Selector Playground, integration with Developer Tools||Selenium IDE (record and playback) is great, but not as good as Cypress|
|API Testing Support – End to End Testing Tool||No API Testing Support as Selenium is just a browser automation tool|
|Automatic retries||Implicit & explicit waits|
|Automatic screenshots & Videos||No automatic screenshots or videos|
|Easy install with one command||Installation of multiple components|
|Clear error messages||Error messages sometimes confusing (long stack trace errors)|
|Excellent documentation||Average documentation|
Which one to choose?
Well, it completely depends on your requirement.
You can see where these tools stands in the 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?
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.