Cypress.io is the killer of Selenium?

Robin XUAN
4 min readJun 26, 2020

Before I answer the question, let’s take some time to compare them by a real case study, and then figure it out together. (It may take 2–3 minutes to read all)

Case study — the automation test requirements:

  • You are testing a Web app, which can be a React app, Angular app or others
  • You should test against Safari, Chrome, Firefox on Desktop, Mobile and Tablet.
  • You are asked to write End-to-End test in BDD format(Given / When / Then), and your test can be a part of product CI/CD pipeline, to provide an indicator for rest of team members

As Cypress.io only supports JavaScript, so I pick up Webdriver.io to represent Selenium for detailed comparison. You can also find why I also put Puppeteer in the chart at the end of this article.

figure 1: packages download statistics from npmjs.com

Requirement 1 — You are testing a Web app

Cypress.IO and Webdriver.IO both can test Web app. but there are following difference:

figure 2

To sum up:

Cypress.IO , Webdriver.IO & Puppeteer-Core both supports Web App testing. Seems Cypress.IO can replace Selenium at this stage.

Requirement 2 — Test against Safari, Chrome, Firefox on Desktop, Mobile and Tablet

So obviously Cypress cannot test Safari, also cannot test against real Android phone, iPhone and iPad.

But Cypress.IO at least covered the test for Chrome, Firefox and Edge, so it could be a good idea that we put Cypress.IO as a part of CI/CD pipeline to execute End-to-End test?

To sum up:

It’s NOT a good idea to choose Cypress as your unique End-to-end test framework. But Cypress.IO could help to run E2E test within CI/CD pipeline because it’s fast! Indeed Cypress is not a Killer of Selenium at this stage since it cannot cover your browser/device coverage.

Requirement 3 — E2E Test in CI/CD Pipeline

We’d like to run E2E test(with/without real back-end API) with mocked data against https://localhost to ensure the UI components are visible and put it in CI/CD pipeline. We’d prefer to give a “verdict” by test result as soon as possible once CI/CD pipeline is happened.

To sum up:

Cypress.io is faster then Webdriver.io! Cypress.IO is very suitable for running test in CI/CD pipeline.

But come back to our requirements 1 & 2, including the browser/device coverage and be part of CI/CD pipeline, we have to maintain 2 frameworks(Webdriver.io & Cypress.IO) simultaneously, and write tests 2 times in both framework maybe.

So to sum up all, Cypress.io is NOT the killer of Selenium, but however we still don’t have a solution to fit requirements 1 , 2 & 3 by only maintain one test framework and one test suite.

So I share a solution with Puppeteer-Core here for maintaining one framework only and one test suite only, to achieve WRITE TEST ONE TIME but support all device/browser coverage, with fast speed execution in CI/CD pipeline.

Solution for all requirements

Based on following facts:

Summary:

1. We use WebDriver.IO as unique test framework. It can cover Safari, Chrome, Firefox and Edge on Desktop, Mobile and Tablet.

2. We only write one time of BDD tests, and enable it for WebDriver Protocol and Puppeteer-Core by changing the webdrver.io config file for different purpose.

3. To run E2E test with Puppeteer-core through Webdriver-IO in CI/CD pipeline, which can provide same/similar execution speed, and achieve similar job like Cypress.IO did.

At the end

However, This article cannot tell you Cypress.IO is better then Selenium or on the other side, but it tells Cypress.IO is not the killer of Selenium. Even then that, we finally use the solution like Selenium+Puppeteer to resolve our problem. So based on your case, the combination of Selenium+Cypress, or Cypress+Puppeteer could be also good choices.

Cypress.IO and Selenium both are powerful automation test tools, but which is depends on your requirements. We always need to think more about test requirements before we start coding, which can be more flexible to fit changes of test requirements in the future.

I’d like to hear more from you! If you like this article, please don’t be hesitated to give me a 👏👏👏👏!

--

--