DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Modern Test Automation With AI (LLM) and Playwright MCP
  • AI-Driven Test Automation Techniques for Multimodal Systems
  • Debugging With Confidence in the Age of Observability-First Systems
  • Accelerating Debugging in Integration Testing: An Efficient Search-Based Workflow for Impact Localization

Trending

  • Cloud Security and Privacy: Best Practices to Mitigate the Risks
  • How to Build Real-Time BI Systems: Architecture, Code, and Best Practices
  • Endpoint Security Controls: Designing a Secure Endpoint Architecture, Part 2
  • Efficient API Communication With Spring WebClient
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. TestCafe: An e2e Testing Tool That Doesn’t Use Selenium

TestCafe: An e2e Testing Tool That Doesn’t Use Selenium

See how easy it is to run e2e testing written in JavaScript with TestCafe, an open source Node.js tool, and no need for Selenium.

By 
Alexander Moskovkin user avatar
Alexander Moskovkin
·
Sep. 29, 17 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
18.4K Views

Join the DZone community and get the full member experience.

Join For Free

Selenium WebDriver is one of the most well-known tools for e2e testing. And for a reason: a huge community, lots of frameworks, and supported languages. All these let one use Selenium in almost any project.

But there is a limitation: it takes a decent amount of time to set it up on a new project. Plus, you rarely use a “pure” Selenium. In most cases, a bunch of plugins and frameworks are required, so sometimes it’s too expensive timewise. This becomes even more noticeable when you need to scale the testing environment.

But what if you don’t want to invest a lot of time into the setup of an e2e testing environment?

Alternative Way

Many popular e2e testing solutions are Selenium-based, for lots of reasons. They extend its basic capabilities but also inherit the need to spend time on WebDriver setup.

We took a different path: we created TestCafe, a tool that does not use Selenium at all. We had to implement all functionality from scratch. But at the same time, it has untied our hands. Now TestCafe takes about a minute to set up and start testing.

How It Works

TestCafe uses a URL-rewriting proxy instead of WebDriver. This proxy injects the driver script that emulates user actions into the tested page. This way TestCafe can do everything required for the testing: it can emulate user actions, authentication, run its own scripts & etc. And for the tested page, it looks like there's a real user interacting with it. It doesn't experience any direct scripts interference. Here's a brief scheme of what the proxy does.

How URL-rewriting proxy works

Given that, you don’t need to install any additional tools. Run this command and you are ready to go:

npm install -g testcafe


Now you can write your first test and run it. Go to the Getting Started part of the documentation to see how.

Installing TestCafe and running a test

Main Features

TestCafe itself is an open source Node.js tool operated via command line or JavaScript API. Сomplete functionality for e2e testing is provided out of the box. 

As for the environment, it can run on Windows, MacOS, and Linux. Supports desktop, mobile, remote and cloud browsers (UI or headless).

Tests are written in JavaScript, supporting latest features including ES2017 (for example, async/await). And since v0.16.0 TestCafe supports TypeScript, for those who prefer a strongly typed language.

Then there are also various plugins for some extra spark. They provide framework-specific selectors, alternative reporters and etc. They're installed with a single command and don't require any further setup. For example, to add React selectors do this:

npm install -g testcafe-react-selectors


What Else Is There?

TestCafe also has some features that would be hard (or impossible) to implement on top of Selenium.

One of these features is an isolated test environment. Tests start with clean storage and cookies, and can use the User Roles mechanism. This allows you to run tests under different user accounts and isolate user authentication from the tests. Thus you can avoid a lot of boilerplate code and work in the same browser without the risk of state interference.

Another feature is an automatic waiting mechanism. It waits until the page and its elements are loaded and runs the test immediately after. This makes the tests less flaky and more reliable without any extra coding.

You can also run tests on remote devices, which don’t have an instance of TestCafe installed. It can be useful when you need to demonstrate a bug to a colleague or quickly run a test on a mobile device.

Conclusion

Sure, it would be much easier to use Selenium under the hood. But we decided to build a new tool without any legacy. If you’ve been looking for WebDriver alternatives, give TestCafe a try. And tweet us with #TestCafe tag, we’d love to hear what you think of it.

Follow us on Twitter or Facebook for product news and web dev related stuff. We post several times a week. And feel free to ask questions on our forum.

Testing

Opinions expressed by DZone contributors are their own.

Related

  • Modern Test Automation With AI (LLM) and Playwright MCP
  • AI-Driven Test Automation Techniques for Multimodal Systems
  • Debugging With Confidence in the Age of Observability-First Systems
  • Accelerating Debugging in Integration Testing: An Efficient Search-Based Workflow for Impact Localization

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!