Quick guide to Cypress vs. Selenium
Cypress is one of the trending topic in test automation. Let’s have a look on some of the key features or say capabilities which may help you to evaluate & decide which one to use out of both. Honestly, there are many comparisons between Cypress and Selenium but it is important to look at all the aspects before deciding the one for your project.
Both are having different architecture. Cypress is very easy to configure or set up as against to Selenium.
Cypress is very famous in developer community as it uses its unique DOM techniques which help it to run directly in the browser as against to Selenium.
Selenium is a library and so we need to integrate it with other tools, like unit testing framework – JUnit or TestNG to have an assertions for verification and validations same is the case for test reporting, and so on to have a complete framework. Cypress on the other hand is a complete framework.
We all know about issues on handling element readiness/ not visible in Selenium and then using wait – not delay (sleep).
Cypress overcomes this with its retry on finding elements and mostly for all actions that do not change the state.
We should not see stale element problem in Cypress 😊
Cypress Test Runner is another nice feature. It automatically logs all of the actions and saves a snapshot of the DOM.
This helps for debugging the issues if any and investigates faster – We can use Chrome’s Dev Tools.
Automatic scrolling in Cypress is great feature to ensure an element is in view before performing any action on it.
In Cypress you can do Unit, Integration and System tests all in one place.
Cypress comes with a large set of APIs to perform browser-specific commands, say clear cookies and other browsing
commands which are not straightforward with Selenium.
Selenium supports all the major browsers so you could test on Chrome, Firefox, Safari, IE, and many more. Cypress does not support cross-browser testing but community is hoping to have this limitation soon covered.
Cypress has same-origin policy and so tests are restricted to one site, it has a limited support for iframes.
Cypress solution comes with a documentation and great collection of examples.
Also the framework is browser ready which will reduce setup time and things will be ready for execution by its own.