I been working for quite some time with Selenium and Cypress, and I strongly believe those two frameworks are the leaders of the Web UI testing.
So here is my comparison table for those two.
|Cross browser support||Chrome, Firefox, Edge, IE||Chrome, Firefox, Edge|
|Cross domain origin support||Yes||No (Could be painful if you use 3rd party services, ex Stripe payment)|
|API testing out of the box||No||Yes (Cypress can intercept and stub responses, which is quite handy if front-end development ahead of backend)|
|XPath support||Yes||Yes (but requires extra plugin)|
|Debugging||Yes (but not obvious what went wrong have to setup breakpoints)||Yes ( Cypress takes snapshots of each step and keeps it in memory which helps faster identify the problem)|
|Reporting||Yes (Supports multiple reporting tools which outputs results in XML, HTML, JSON)||Yes (same as Selenium, plus easy integration with Cypress dashboard, which helps to record video of the tests and tracks down flaky tests)|
|Test Runner||Supports any test runner of your choice, which is very convenient||Cypress using their own runner which has limitations like tests tagging|
|Memory usage||Heavy, but never seen Selenium crashes because of the memory problems||Super heavy and requires optimization, I have seen the situations where Cypress fails after typing long strings (to be fair it can be optimized by minimizing number of tests in memory)|
|Documentation||Yes||Yes (Cypress goes far and beyond with their documentation, you can find example for pretty much anything)|
Here is my overall feeling about both of those tools. If I had to pick universal tool which can do almost everything I would go with Selenium. If I want follow the trends and write UI tests faster and less flaky I would go with Cypress. I’m big fan of Cypress and there is a lots of things I really enjoy about it, but it have some cons:
- Cross-domain testing (in one of my projects I had to drop Cypress, just because it was not supporting payment on Stripe domain)
- Test runner support, not much to choose from (I really like Python Selenium and how it supports Pytest with all the features Pytest have to offer including tests tagging with markers)
- Heavy on memory
But with cons you get pros:
- Cypress intercept allows you to use fixtures and stub the responses
- Nice and clean UI test runner, saves lots of time to debug tests
Each project is different so you have to weigh in and select the right tool for the job. Hope with this blog you will have more insights on which tool to pick.