AQA ProcessTest Automation Tools

Selenium vs. Cypress: Which Tool Is More Useful in Test Automation

7 min read

Published 20 June 2023. Updated with a short answer, a comparison table and a FAQ; the article text is unchanged. Published by Zapple.Tech, founded by the founders of CodeceptJS and Codeception, open-source testing frameworks.

Selenium vs. Cypress: Which Tool Is More Useful in Test Automation
Short answer

Selenium and Cypress both automate end-to-end tests of web apps, and neither is the better choice for every project. The post says Cypress is easier to install and runs inside the browser but supports only JavaScript, while Selenium supports more languages, browsers and test types. The right pick depends on project needs and engineer skills.

For almost 20 years, testers have had the Selenium automated testing framework at their disposal. Since then, QA engineers have fully appreciated all the disadvantages of conducting manual tests and focused on minimizing the time spent while leaving the quality of the processes at the proper level. Since its inception, this tool has been the most widely used product in the automatic testing of web programs for a decade. But in 2015, it had an alternative – the new Cypress tool.

Why do QA engineers compare these frameworks before starting to write tests? Can they interchange each other, or are they still used in different cases? In this article, we will try to clarify these matters.

Selenium and Cypress as compared in the post
AspectSeleniumCypress
ArchitectureWorks outside the browser through WebDriver and browser driversRuns inside the browser
LanguagesC#, PHP, Python, Ruby, Java and JavaScriptJavaScript only with the Mocha platform
BrowsersAll popular browsers and mobile platformsNo IE or Safari; one browser at a time and no multiple tabs
SetupJava SDK, Eclipse IDE, WebDriver and browser driversInstall through npm; no extra drivers
Reports and waitsNo built-in test reports; additional tools neededAutomatic waits and a step-by-step command log with screenshots
Test typesCompatibility, performance, integration, system, end-to-end, regression, smoke and sanityEnd-to-end, unit and integration

Cypress and Selenium: A Brief Overview

Both of the frameworks we are talking about today are tools used to automate the functional testing of web apps. Why did we decide to compare them, since there are other products? The thing is that many of them, e.g., Protractor, WebDriverIO, or Katalon Studio, are implemented based on Selenium; therefore, they have similar characteristics and disadvantages. And Cypress tool is an entirely independent, new solution with its pros and cons.

What they have in common is that both tools are used for end-to-end testing. And differences are in the supported languages, additional functionality, and features. But let’s talk about everything in order.

Selenium Advantages and Disadvantages

In addition to the fact that this AT has earned testers’ trust, it has other advantages that make you choose it:

  1. It has open-source, i. e. it can be freely distributed free of charge, and developers can add their own unique extensions to improve the quality and speed of work.
  2. Sustains popular operating systems Unix, Windows, Mac, and Linux.
  3. It holds a Selenium WebDriver component which allows you to automate web browser actions both on local PCs and remotely.
  4. It is a multilingual AT environment – among the supported programming languages ​​are .net (c#), PHP, Python, Ruby, Java, and JS.
  5. Supports many AT environments, including the current Behavior-driven development environments: JUnit, Behave, SpecFlow and others.
  6. It is a multi-browser tool; it supports all popular web browsers and mobile platforms.
  7. Uses the interactive JSON protocol, which allows you to execute a test case in 3 stages:
    1. test commands are transformed into a URL;
    2. the webserver passes them to browser drivers;
    3. URLs are redirected as a request to the actual browser; all test script commands are executed automatically.
  8. The latest version of Selenium 4 offers QA engineers additional components that greatly expand the list of available features:
    1. Grid is a proxy server that makes parallel testing on multiple machines more accessible and also makes it possible to manage various modifications of web browsers centrally.
    2. IDE is a plugin for Firefox and Chrome that performs several functions: recording, playback, debugging, and running tests.
  9. Provides extensive user support thanks to a rich user experience – numerous official sources, forums, and other communities of QA specialists are available for information to testers.
  10. Able to integrate with third-party resources to improve the testing quality.
  11. Selenium 4 version is fully aligned with the World Wide Web Consortium (W3C).

But still, Selenium has some shortcomings that make testers look for an alternative to this test automation tool:

  1. To start automating test processes, QA engineers must install the right software (drivers) on their PCs:
    1. ChromeDriver;
    2. GeckoDriver for Mozilla Firefox
    3. Microsoft Edge WebDriver
    4. OperaDriver;
    5. Internet Explorer Driver;
    6. SafariDriver;
    7. Selenium language drivers.
  2. Automatic creation of test results is not available due to the lack of a built-in command – you need to use additional tools (e.g., JUnit) to build reports.
  3. Long duration of test case creation. So, in Selenium WebDriver, QA specialists have to write each task step by step.
  4. Open-source code makes it impossible to maintain the product reliably. No one can guarantee the correct operation of new functions.

As you can see, despite the years of use, Selenium is not an ideal tool for writing test scripts and testing in general. And although it is quite common (according to the Selenium.dev, 61% of respondents use the framework), there are still other worthy AT tools.

Selenium Alternatives: Should Cypress be Considered?

Although Cypress is relatively new to the automated testing market, it has already managed to gain enviable popularity, having received 38.5k stars on GitHub. Such prevalence, broad functionality, and an extensive list of advantages attract the attention of more and more testers and encourage them to conduct a comparative analysis of tools.

Above, we have already talked about the benefits of Selenium, forcing QA engineers to choose favor of it. Now it’s time to talk about the advantages of Cypress:

  1. Allows you to track the testing history step by step – the program creates screenshots. Subsequently, with just one click on a specific line in the command log, testers can call up an image and find out what happened at that particular moment.
  2. Supports quick-launch capability.
  3. Allows you to test the API.
  4. Able to check software compatibility with different browsers.
  5. Has wide integration capabilities, including GitLab, Circle CI, Bamboo, and other tools.
  6. Contains commands used to control function behavior, server responses, and timers:
  • Stubs cy.stub() – used to change the functionality and pass it to the developer for verification. As a rule, you have to mute functions whose side effects prevent them from being controlled.
  • Spies cy.spy() – allow you to “spy” on a particular function to ensure it was called the right number of times, with the correct arguments, or in the proper context.
  • Clock cy.clock() – used to control the program, predict its operation, and speed up testing.

Speaking directly about Cypress Advantages over Selenium, there are also a few points here:

  1. The tool executes commands online as the tester writes them, providing full reporting documentation.
  2. To work with Cypress, no additional drivers installation is required; test cases run inside the browser.
  3. With Cypress, the results obtained are more stable due to better control. So, this tool supports the Stubbing DOM APIs.
  4. No need for protocols – this AT tool functions within the program.
  5. There is no need to add explicit or implicit waits; Cypress automatically waits for commands and confirmations.

However, having so many apparent advantages doesn’t make Cypress the only framework of choice for automated testing. The reason is that, along with the benefits, it also has its flaws:

  1. Not being able to manage multiple browsers in parallel.
  2. Only JavaScript is supported. As a result, only the Mocha JS platform is available.
  3. Small list of compatible browsers – does not support IE and Safari.

Cypress’ open-source code creates the same conveniences and challenges as Selenium, and the growing community provides decent user support despite the product’s relatively short history on the market.

Want to get high quality testing services?

Click the button below for more information about automated testing

Learn More: QA Automation Testing Services

Cypress vs. Selenium: Which is Better

To make it easier to choose between the two frameworks under consideration, we will compare them in several ways: ease of setup and installation, architecture, app areas, and supported features.

Ease of setup and installation.

The Cypress installation process is easier than Selenium. The recommended way is simply to download the framework through the npm package manager. As for Selenium, its installation consists of 3 stages:

  • installing the Java SDK (Software Development Kit for Java);
  • installing the Eclipse IDE;
  • installing Selenium WebDriver itself.

Before testing, in the case of Selenium, you will have to take care of downloading and configuring the necessary drivers as well. Cypress does not require additional installations.

Architecture.

To compare the architecture of the two tools, look at the way they interact with a web browser. Selenium works outside the browser. It uses the WebDriver component to communicate with its driver, which then interacts with the actual browser and provides the execution of commands.

Cypress works inside the browser online. On the one hand, this gives the tool access to all program objects and outside of it (e.g., it allows you to take screenshots during testing). On the other hand, this fact limits the ability to run tests in two browsers simultaneously and does not allow the use of multiple tabs.

Opportunities.

Cypress is limited to using only one JS programming language and the Mocha JS platform based on it. Selenium has more features — it supports all popular languages ​​and platforms based on them.

Areas of use.

What is Cypress Used for:

  • end-to-end testing;
  • unit tests;
  • integration tests.

The list of apps for Selenium is somewhat longer. It is used for:

  • compatibility check;
  • performance testing;
  • integration testing;
  • system testing;
  • end-to-end testing;
  • regression testing;
  • Smoke and Sanity tests.

Summarizing

Cypress is the go-to solution for built-in drivers, easy installation, and in-browser functionality for JavaScript developers. On the other hand, Selenium provides more opportunities for automating different types of tests and supports more programming languages ​​and other related features.

The choice of one of the leading frameworks for automation is up to users and depends on the needs of a particular project and QA engineer skills. For more detailed advice, please contact zapple.tech managers — we specialize in automated testing and will help you solve a problem of any complexity.

Questions about this article

What is the main difference between Selenium and Cypress?

The post compares them on setup, architecture, languages and test types; architecturally, Selenium works outside the browser through WebDriver, while Cypress runs inside it. Running inside the browser gives Cypress access to app objects and screenshots but limits it to one browser at a time and no multiple tabs. Selenium also supports more languages.

What are the advantages of Selenium?

The post lists open-source licensing, support for Unix, Windows, Mac and Linux, WebDriver for local and remote browsers, many languages (C#, PHP, Python, Ruby, Java, JavaScript), multi-browser and mobile support, Selenium 4 Grid and IDE, and a large community. Its drawbacks include driver installation, no built-in reports and slower test writing.

What are the advantages and limits of Cypress?

The post credits Cypress with simple npm installation, no extra drivers, automatic waits, step-by-step screenshots in the command log, API testing and stubs, spies and clock commands. Its limits are JavaScript only (with the Mocha platform), no parallel multi-browser control, and no support for IE or Safari.

Which tool is easier to set up, Selenium or Cypress?

Cypress, according to the post. It is installed through the npm package manager and needs no additional drivers. Selenium installation takes three stages (the Java SDK, the Eclipse IDE and Selenium WebDriver itself), and you must also download and configure browser drivers before testing.

What kinds of testing does each tool cover?

The post says Cypress is used for end-to-end, unit and integration tests. Selenium has a longer list: compatibility, performance, integration, system, end-to-end and regression testing, plus smoke and sanity tests. The post also says the choice depends on project needs and QA engineer skills.

Request a QA audit quote

Tell us what you ship and what worries you.

What happens after you send this

  1. You send the form: your situation and what you need tested, then your name and work email.
  2. Within one business day, we reply with a suggested first step, its scope, timeline and a quote.
  • Fixed scope
  • You decide after each step
  • The tests live in your repository
  • An NDA signed before access

“They helped us to close the positions and consult our team how to proceed further. High-quality quick feedbacks with the deep checking of the required tasks, professional approach, great understanding of the company's technologies and product, detailed reports.”

Kristina Lavrentieva, Manager at keepgo.com, Israel
  • Rated 4.9 out of 5 on Clutch, from 7 client reviews
  • 42 completed test automation and infrastructure projects
  • Founded by the founders of CodeceptJS and Codeception, open-source testing frameworks

Request a QA audit quote

    What is closest to your situation?
    Optional. The product, the platforms, how often you release, what broke last.

    You decide after our reply whether to go ahead.

    Prefer to talk first? Book a call

    One-week QA audit · written report

    Request a QA audit quote