There is a lot of talk in the software testing community about Cypress and Selenium. So, what are the key differences between Cypress and Selenium.
When it comes to automation testing tools, both Cypress and Selenium are powerful automation tools used by software testers. Both have their pros and cons, but which one is the best tool for your needs?
In this post, we will compare Cypress vs Selenium and explore which tool is better for your needs. So you can decide which one is best for your needs. Let’s get started!
What Is Cypress
Just like other we automation framework, Cypress automation also has these stages
Set up tests > Script the tests > Test Run > Debug the Tests.
Cypress is generally compared with Selenium, but their architecture is different. Cypress does not have lot of restriction as selenium has. It makes Cypress to create your automation web scripts in a faster and easier way
Using Cypress anything can be tested which is running on a Browser, following testing can be automated by Cypress
- Unit testing
- Integration testing
- End to end testing
Reasons to Use Cypress
- Cypress gives a fast and stable test execution as compare to other automation tools because of its Architectural design.
- Cypress has feature of screenshot capturing while test execution.it can also capture the video of test suite if it is running from the command line Interface.
- In Developer tools section, it gives debugging option which helps developers to debug fast and in easy way.
- Unlike other tools where wait and sleep are used to achieve synchronization in test runs, Cypress has inbuilt feature which waits by default until next actions and also waits before moving to next step.
- In Cypress we can see response time of an activity which is very useful for unit testing perspective.
- Cypress can be used with CI tools [Continues Integration tools-Jenkins].
- With the help of Viewport sizing feature, cypress can check responsiveness of a web page.
- Cypress provides test case status in a clear format, it displays count of test cases which are passed or failed.
- Cypress has good capability of error logging, which clearly describes the reason of any error or failure.
- Cypress has good documentation support, which helps developers and tester to write critical tests.
Advantages of Cypress
- Using Cypress API testing can be done, which is not possible in other open source web automation tools.
- Cypress works on real browser unlike other tools which simulates the browsers, due to this test are more reliable and fast.
- Cypress is a framework which can be used in Unit, Integration and end to end testing so it is choice of Developers and tester both.
- Writing code in Cypress is very easy, since it is completely in Java script, and its debugging capability is very strong.
Disadvantages of Cypress
- Cross browser testing is limited as compare to other tool like Selenium.
- Mobile browser testing or native applications cannot be automated by Cypress.
What Is Selenium
Selenium is open source testing framework, used for web application testing and supported by different platforms and browsers. Many programming Languages are supported by selenium like c#, java, python, ruby, Perl. Platform supported by selenium are Windows, Linux, Mac OS and Solaris.
Selenium 4 is the latest version of selenium. – Checkout Selenium 4 Tutorial here.
Selenium is made up of 4 following components
1. Selenium IDE [Integrated Development Environment]
To record and play the user actions and commands on the browser.
2. Selenium Web driver
To code the actions and commands to send to the browser.
3. Selenium Remote control
It’s a Server which helps interaction between selenium commands and browser.
4. Selenium Grid
Helps in distributed and parallel testing for example by using Selenium grid we can execute automation scripts on different physical or virtual machines simultaneously.
Don’t miss: Selenum 3 vs Selenium 4
Reasons to Use Selenium
- There are multiple reasons of using selenium the most significant reason of using this tool is it is an open source.
- It can be run on almost every browser and supported by maximum platforms.
- Using this tool we can write automation script in a language of our own choice
- We don’t need to be stick or dependent on a tool specific language.
Advantages of Selenium
- Selenium supports multiple programming languages like C#, Java, Python, Perl, Ruby etc.
- Selenium supports multiple platforms like Windows, Linux, iOS
- Selenium supports parallel or simultaneous execution of automation scripts.
- Selenium has record and play [IDE], which makes automation easy, user can export this recording script in to his own choice of language.
- Selenium is open source and huge community support.
- Selenium is helpful in DevOps and continues integration, it can easily integrated with Jenkins, Maven etc.
- Selenium with Appium helps in Mobile testing, which is very rare with other open testing tools.
- Selenium supports headless browser testing.
Limitations of Selenium
- It works only on web based application. Windows automation can’t done by Selenium.
- Reporting feature is not good in Selenium, it has dependency on TestNG or Cucumber
- Selenium is not very accurate in finding Dynamic web elements.
- Captcha and barcode cannot be automated by Selenium
- Selenium is not strong in handling page load and sync issues. Also it is not able to handle popup windows very accurately.
- Capturing of Screen is supported by selenium but still testing of Images, video and Audio cannot be done by Selenium
- Strong Programming knowledge is required to use this tool
- Selenium only helps in application UI testing, can’t help in Unit testing, Integration testing and database testing.
Detailed Post: Challenges and Limitations of Selenium
Compare Cypress and Selenium
Selenium and Cypress both are open source web test automation frame work, but both have some difference. Following are the key difference between the two.
|Architecture||Unlike other testing tool which works out side of the browser, Cypress is present inside the browser. With the help of Node.js server it interacts with both the front and back end of the applications.|
It’s very easy for Cypress to access Window objects, local storage, browser developer tools, Document object model which makes this tool very vast and easy for automation.
|Selenium has Webdriver API which interacts between Browser and Browser drivers. Selenium is consists of 4 layers
For every Browser different driver is needed.
|Target Audience||Cypress can be used by Developers and tester both.||Selenium is only used by Testing team.|
|Browser supported||Chrome, |
and Electron browsers
|Google Chrome 12+,
Internet Explorer 7,8,9,10,
|Open Source||Open Source / some features are paid||Open source|
|Operating systems||Windows 7 and above, MacOS, Linux, Fedora, |
|Windows, Mac, Linux/Unix).|
Perl, PHP, Java, Kotlin,
|Ease of Setup||Low as no dependency on any driver and all required files comes in a bundle||Medium- because selenium web driver and browser drivers needs to install separately|
|Dependencies||No dependency on any driver||Dependent on Drivers like different browsers|
|Mobile Testing Support||No||Yes – using Appium|
Who are the target audience for Cypress and Selenium
Target audience are based on the objective of the test automation, if the objective is to automate Unit, Integration and End to end testing then Cypress is the only choice, and both Developers are QA are the audience for Cypress.
But on the other hand if the objective is just to test the application UI and Functionality on the web browser then Selenium is the best choice.
Will Cypress replace Selenium
It is difficult to say if Cypress will replace Selenium or not, because selenium is a very old tool and very popular among the testing folks and continuously improving its feature.
Cypress is a great tool for API testing, which is not possible in Selenium.
When it comes for cross browser testing, Selenium is the best choice because it supports almost every browser whereas Cypress only Supports Chrome.
If we talk about the accuracy and speed of test automation then Cypress comes first because it is present inside the browser, Synchronization issue is very rare in Cypress, unlike the Selenium, where Scripts are running out side of the browser.
Both have their own pros and cons, and it’s certainly a choice of the entire team whether to use Cypress or Selenium.