Select Page
Automation Testing

Selenium vs Cypress: Listing out the Key Differences

Look no place else for an in-depth Selenium vs Cypress comparison that lists the key differences between both on a point-to-point basis.

Selenium vs Cypress Listing out the Key Differences

Cypress has been gaining popularity in the testing community despite Selenium still being the favorite choice. During the initial days, Cypress had features only for Unit testing, and it was also supported only by a few browsers. However, Cypress has now extended its capabilities for End-to-end Testing, Integration Testing, and Unit Testing. So choosing between these two options isn’t as easy as it once was. So in this blog article, we will be pitting Selenium vs Cypress and list out the key differences between the two to find out which will be better for your needs.

Cypress

Cypress is not an open-source tool only its test runner is open-source. Many modern test automation frameworks are built on top of Selenium. Whereas Cypress has its own architecture to interact with browsers. Selenium performs the actions on a browser through the browser API. Cypress has a node process that runs behind the scenes and controls the web application to perform the set of scenarios we have listed below.

  • Stub the functions of your browser or application to force them to behave as per the requirements in your test case.
  • It enables us to programmatically alter the state of your application directly from your test code by exposing data stores (Like in Redux).
  • You can force your server to send empty responses and test edge cases like ‘empty views’.
  • You have the option to test how your application responds to errors on your server by modifying the response status codes to be 500.
  • Direct modification of DOM elements like forcing hidden elements to be shown can be done.
  • It is possible to prevent Google Analytics from loading before any of your application code is executed while testing.
  • Stay in the loop with the synchronous notifications you get whenever your application transitions to a new page or when it begins to unload.
  • Move forward or backward to control time and allow the timers or polls to automatically fire without having to wait for the required time in your tests.
  • You can also add your own event listeners for responding to your application. You could also update your application code so that it behaves differently when under tests in Cypress.

Source – Cypress Documentation

Selenium

Selenium WebDriver can be used to control your browser either locally or remotely.

Local – First up, the client binding sends the WebDriver commands to the driver. Following this, the driver sends the command to the browser. Once a command is executed on the browser, the outcome of the command execution will be sent back from the same channel.

Remote – Let’s say you have the automation codebase in Windows, but want to run your scripts on the Chrome & Linux combination. You can start the Selenium Remote WebDriver on the Linux machine. After which, the client binding from Windows will send the commands to the remote WebDriver. From there the remote WebDriver sends the commands to Chrome Driver, and finally, the commands reach the browser via the Chrome Driver.

Advantages of Selenium

As stated earlier, Selenium is the crowd favorite. So let’s take a look at the advantages that make Selenium so popular.

  • Selenium WebDriver supports multiple programming languages.
  • Selenium can be integrated into any test automation framework.
  • It supports multiple browsers.
  • In Selenium 4, you can get the DevTools instance using CDP.
  • Selenium also has a strong online community.

We have seen a glimpse of both Cypress and Selenium separately. Now let’s take the Selenium vs Cypress a notch higher and compare both on a point-to-point basis to see which one will be useful for you.

Selenium vs Cypress Comparison

S. No.FeatureSeleniumCypress
1Programming LanguagesSelenium has client bindings for following languages C#, Python, Ruby, Java, JavaScript and etc.JavaScript
2PricingFreeFree for up to 3 users & 75 USD per month for 10 users
3Browsers SupportedChrome Edge IE Firefox Safari Opera HeadlessEdge Chrome Firefox Electron
4Video RecordingSelenium is a web browser automation tool. You can bring execution recording using your test automation framework, but not using Selenium.Cypress has an in-built feature for video recording.
5ScreenshotsPage-level and element-level screenshots can be captured using the TakeScreenshot method.By default, screenshots are taken for failures and embedded into test results. If you want to take inside the script at any point, you can use cy.screenshot() command.
6Jira & Slack IntegrationNo. You need to write your own utilities to integrate Jira & Slack.Yes
7Testing LibrariesYou can use any testing libraries based on client bindings support.Cypress supports only the following JavaScript testing libraries - Mocha, Chai, Chai-jQuery, and Sinon-Chai.
8ReportingSelenium does not have in-built reporting libraries. You need to integrate some external reporting tools like ReportPortal or Allure Reporting.Cypress has a comprehensive reporting dashboard that can make the test results visible to the entire team.
9Open-source/Freeware/CommericalOpen-sourceCypress Dashboard is a commercial tool. Test Runner is open-source
10Load BalancingNoCypress will automatically balance your spec files across the available machines in your CI provider.

Conclusion

As a leading test automation company, we use Selenium extensively for delivering the best-in-class automation testing services. After a lot of R&D, we did try Cypress out in a couple of our projects. We found Cypress to be a good choice for web applications developed using only JavaScript technologies in both the client-side and server-side.

Written By

Submit a Comment

Your email address will not be published. Required fields are marked *


Cypress has been gaining popularity in the testing community despite Selenium still being the favorite choice. During the initial days, Cypress had features only for Unit testing, and it was also supported only by a few browsers. However, Cypress has now extended its capabilities for End-to-end Testing, Integration Testing, and Unit Testing. So choosing between these two options isn’t as easy as it once was. So in this blog article, we will be pitting Selenium vs Cypress and list out the key differences between the two to find out which will be better for your needs.

Cypress

Cypress is not an open-source tool only its test runner is open-source. Many modern test automation frameworks are built on top of Selenium. Whereas Cypress has its own architecture to interact with browsers. Selenium performs the actions on a browser through the browser API. Cypress has a node process that runs behind the scenes and controls the web application to perform the set of scenarios we have listed below.

  • Stub the functions of your browser or application to force them to behave as per the requirements in your test case.
  • It enables us to programmatically alter the state of your application directly from your test code by exposing data stores (Like in Redux).
  • You can force your server to send empty responses and test edge cases like ‘empty views’.
  • You have the option to test how your application responds to errors on your server by modifying the response status codes to be 500.
  • Direct modification of DOM elements like forcing hidden elements to be shown can be done.
  • It is possible to prevent Google Analytics from loading before any of your application code is executed while testing.
  • Stay in the loop with the synchronous notifications you get whenever your application transitions to a new page or when it begins to unload.
  • Move forward or backward to control time and allow the timers or polls to automatically fire without having to wait for the required time in your tests.
  • You can also add your own event listeners for responding to your application. You could also update your application code so that it behaves differently when under tests in Cypress.

Source – Cypress Documentation

Selenium

Selenium WebDriver can be used to control your browser either locally or remotely.

Local – First up, the client binding sends the WebDriver commands to the driver. Following this, the driver sends the command to the browser. Once a command is executed on the browser, the outcome of the command execution will be sent back from the same channel.

Remote – Let’s say you have the automation codebase in Windows, but want to run your scripts on the Chrome & Linux combination. You can start the Selenium Remote WebDriver on the Linux machine. After which, the client binding from Windows will send the commands to the remote WebDriver. From there the remote WebDriver sends the commands to Chrome Driver, and finally, the commands reach the browser via the Chrome Driver.

Advantages of Selenium

As stated earlier, Selenium is the crowd favorite. So let’s take a look at the advantages that make Selenium so popular.

  • Selenium WebDriver supports multiple programming languages.
  • Selenium can be integrated into any test automation framework.
  • It supports multiple browsers.
  • In Selenium 4, you can get the DevTools instance using CDP.
  • Selenium also has a strong online community.

We have seen a glimpse of both Cypress and Selenium separately. Now let’s take the Selenium vs Cypress a notch higher and compare both on a point-to-point basis to see which one will be useful for you.

Selenium vs Cypress Comparison

S. No.FeatureSeleniumCypress
1Programming LanguagesSelenium has client bindings for following languages C#, Python, Ruby, Java, JavaScript and etc.JavaScript
2PricingFreeFree for up to 3 users & 75 USD per month for 10 users
3Browsers SupportedChrome Edge IE Firefox Safari Opera HeadlessEdge Chrome Firefox Electron
4Video RecordingSelenium is a web browser automation tool. You can bring execution recording using your test automation framework, but not using Selenium.Cypress has an in-built feature for video recording.
5ScreenshotsPage-level and element-level screenshots can be captured using the TakeScreenshot method.By default, screenshots are taken for failures and embedded into test results. If you want to take inside the script at any point, you can use cy.screenshot() command.
6Jira & Slack IntegrationNo. You need to write your own utilities to integrate Jira & Slack.Yes
7Testing LibrariesYou can use any testing libraries based on client bindings support.Cypress supports only the following JavaScript testing libraries - Mocha, Chai, Chai-jQuery, and Sinon-Chai.
8ReportingSelenium does not have in-built reporting libraries. You need to integrate some external reporting tools like ReportPortal or Allure Reporting.Cypress has a comprehensive reporting dashboard that can make the test results visible to the entire team.
9Open-source/Freeware/CommericalOpen-sourceCypress Dashboard is a commercial tool. Test Runner is open-source
10Load BalancingNoCypress will automatically balance your spec files across the available machines in your CI provider.

Conclusion

As a leading test automation company, we use Selenium extensively for delivering the best-in-class automation testing services. After a lot of R&D, we did try Cypress out in a couple of our projects. We found Cypress to be a good choice for web applications developed using only JavaScript technologies in both the client-side and server-side.