Top Related Projects
Fast, easy and reliable testing for anything that runs in a browser.
JavaScript API for Chrome and Firefox
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Next-gen browser and mobile automation test framework for Node.js
A browser automation framework and ecosystem.
Supercharged End 2 End Testing Framework for NodeJS
Quick Overview
TestCafe is an end-to-end testing framework for browser automation and UI testing. It allows developers to write and run tests for web applications across multiple browsers, including mobile devices, without the need for additional browser drivers or plugins.
Pros
- Cross-Browser Testing: TestCafe supports a wide range of browsers, including desktop and mobile, making it easy to ensure your web application works consistently across different platforms.
- Scriptless Testing: TestCafe provides a user-friendly API that allows you to write tests using JavaScript or TypeScript, without the need for complex scripting.
- Parallel Test Execution: TestCafe can run tests in parallel, significantly reducing the time it takes to complete your test suite.
- Robust Reporting: TestCafe offers detailed test reports, including screenshots and videos, making it easier to debug and identify issues.
Cons
- Learning Curve: While the TestCafe API is relatively straightforward, there may be a learning curve for developers who are new to end-to-end testing.
- Limited Integrations: TestCafe may not have as many integrations with other testing tools and frameworks as some of its competitors.
- Performance Overhead: Running tests in multiple browsers can be resource-intensive, which may impact the performance of your development environment.
- Dependency on Browser Compatibility: TestCafe's functionality is dependent on the compatibility of the browsers it supports, which can be a concern as browsers are constantly evolving.
Code Examples
import { Selector } from 'testcafe';
fixture `Google Search`
.page `https://www.google.com`;
test('Search for "TestCafe"', async t => {
await t
.typeText('#q', 'TestCafe')
.pressKey('enter')
.expect(Selector('title').innerText).contains('TestCafe');
});
This example demonstrates how to write a simple test case using TestCafe. The test navigates to the Google homepage, types "TestCafe" into the search box, and then verifies that the page title contains "TestCafe".
import { Selector, ClientFunction } from 'testcafe';
fixture `GitHub Repository`
.page `https://github.com/DevExpress/testcafe`;
test('Verify repository information', async t => {
const getPageUrl = ClientFunction(() => window.location.href);
const repoName = await Selector('h1.h2.lh-condensed').innerText;
const repoDescription = await Selector('.color-fg-muted').innerText;
await t
.expect(getPageUrl()).contains('DevExpress/testcafe')
.expect(repoName).eql('DevExpress/testcafe')
.expect(repoDescription).contains('Browser Automation Framework');
});
This example demonstrates how to use TestCafe's Selector and ClientFunction APIs to interact with and verify the content of a GitHub repository page.
import { Selector, t } from 'testcafe';
fixture `Login Test`
.page `https://example.com/login`;
test('Login with valid credentials', async () => {
await t
.typeText('#username', 'testuser')
.typeText('#password', 'testpassword')
.click('#login-button')
.expect(Selector('#welcome-message').exists).ok();
});
This example shows how to write a test case in TypeScript to verify the login functionality of a web application.
Getting Started
To get started with TestCafe, follow these steps:
- Install TestCafe using npm:
npm install -g testcafe
- Create a new file (e.g.,
test.js
) and write your first test:
import { Selector } from 'testcafe';
fixture `Google Search`
.page `https://www.google.com`;
test('Search for "TestCafe"', async t => {
await t
.typeText('#q', 'TestCafe')
.pressKey('enter')
.expect(Selector('title').innerText).contains('TestCafe');
});
- Run the test using the
testcafe
comman
Competitor Comparisons
Fast, easy and reliable testing for anything that runs in a browser.
Pros of Cypress
- Built-in automatic waiting and retry mechanisms, reducing flaky tests
- Rich, interactive test runner with time-travel debugging
- Extensive documentation and active community support
Cons of Cypress
- Limited cross-browser support (primarily focused on Chrome-based browsers)
- Asynchronous nature can be challenging for developers new to JavaScript
- Cannot interact with multiple browser tabs or windows in a single test
Code Comparison
TestCafe example:
test('Login Test', async t => {
await t
.typeText('#username', 'testuser')
.typeText('#password', 'password123')
.click('#login-button')
.expect(Selector('.welcome-message').exists).ok();
});
Cypress example:
describe('Login Test', () => {
it('should log in successfully', () => {
cy.visit('/login')
cy.get('#username').type('testuser')
cy.get('#password').type('password123')
cy.get('#login-button').click()
cy.get('.welcome-message').should('exist')
})
})
Both frameworks offer intuitive syntax for writing tests, but Cypress uses a chainable API structure, while TestCafe uses async/await. Cypress automatically handles waiting for elements, while TestCafe requires explicit await statements.
JavaScript API for Chrome and Firefox
Pros of Puppeteer
- Direct control over Chrome/Chromium, allowing for more advanced browser automation
- Faster execution due to direct browser control and no additional abstraction layers
- Broader use cases beyond testing, including web scraping and performance analysis
Cons of Puppeteer
- Steeper learning curve, especially for those unfamiliar with browser internals
- Limited to Chromium-based browsers, lacking cross-browser testing capabilities
- Requires more setup and configuration for test automation compared to TestCafe
Code Comparison
TestCafe example:
test('My Test', async t => {
await t
.typeText('#username', 'myUser')
.typeText('#password', 'myPassword')
.click('#login-button');
});
Puppeteer example:
await page.type('#username', 'myUser');
await page.type('#password', 'myPassword');
await page.click('#login-button');
Both TestCafe and Puppeteer are powerful tools for web automation and testing. TestCafe offers a more user-friendly approach with built-in test structure and assertions, making it easier for beginners to get started. Puppeteer, on the other hand, provides lower-level control over the browser, making it more versatile for advanced use cases but requiring more setup for test automation.
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Pros of Playwright
- Cross-browser support for Chromium, Firefox, and WebKit, offering broader coverage
- Built-in auto-waiting mechanism, reducing the need for explicit waits
- Powerful API for handling modern web features like shadow DOM and iframes
Cons of Playwright
- Steeper learning curve due to more advanced features and concepts
- Larger package size and potentially higher resource usage
- Relatively newer project with a less mature ecosystem compared to TestCafe
Code Comparison
TestCafe example:
test('Login Test', async t => {
await t
.typeText('#username', 'testuser')
.typeText('#password', 'password123')
.click('#login-button')
.expect(Selector('.welcome-message').exists).ok();
});
Playwright example:
test('Login Test', async ({ page }) => {
await page.fill('#username', 'testuser');
await page.fill('#password', 'password123');
await page.click('#login-button');
await expect(page.locator('.welcome-message')).toBeVisible();
});
Both frameworks offer concise and readable syntax for writing tests. Playwright's API is more granular, allowing for finer control over actions and assertions. TestCafe's API is slightly more compact and may be easier for beginners to grasp quickly.
Next-gen browser and mobile automation test framework for Node.js
Pros of WebdriverIO
- More flexible and extensible, supporting various automation protocols
- Larger community and ecosystem with extensive third-party plugins
- Better suited for complex, multi-platform testing scenarios
Cons of WebdriverIO
- Steeper learning curve, especially for beginners
- Requires more setup and configuration compared to TestCafe
- Can be slower in execution due to its reliance on WebDriver protocol
Code Comparison
TestCafe example:
test('My Test', async t => {
await t
.typeText('#username', 'myUser')
.typeText('#password', 'myPassword')
.click('#login');
});
WebdriverIO example:
describe('My Test', () => {
it('should login', async () => {
await $('#username').setValue('myUser');
await $('#password').setValue('myPassword');
await $('#login').click();
});
});
Both frameworks offer concise and readable test scripts, but WebdriverIO's syntax is more aligned with traditional JavaScript testing frameworks. TestCafe's API is designed to be more user-friendly and requires less boilerplate code. WebdriverIO provides more granular control over element interactions, while TestCafe abstracts some of these details for simplicity.
A browser automation framework and ecosystem.
Pros of Selenium
- Wider language support (Java, Python, C#, Ruby, JavaScript)
- Larger community and ecosystem with extensive resources
- Native support for mobile testing (iOS and Android)
Cons of Selenium
- More complex setup and configuration
- Slower test execution compared to TestCafe
- Requires separate WebDriver installations for different browsers
Code Comparison
Selenium (Python):
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://example.com")
element = driver.find_element(By.ID, "myElement")
element.click()
driver.quit()
TestCafe (JavaScript):
import { Selector } from 'testcafe';
fixture('My Fixture').page('https://example.com');
test('My Test', async t => {
await t.click(Selector('#myElement'));
});
TestCafe offers a more straightforward syntax and doesn't require separate WebDriver setup. Selenium provides more flexibility in terms of language choice but requires more boilerplate code and explicit browser management.
Both tools are powerful for web testing, with Selenium offering broader language and platform support, while TestCafe provides a simpler setup and faster execution. The choice between them depends on specific project requirements and team preferences.
Supercharged End 2 End Testing Framework for NodeJS
Pros of CodeceptJS
- More flexible and supports multiple testing backends (Puppeteer, Selenium WebDriver, Playwright)
- Easier to write and read tests with a high-level, behavior-driven syntax
- Strong community support and active development
Cons of CodeceptJS
- Steeper learning curve due to its flexibility and multiple backend options
- May require more setup and configuration compared to TestCafe's out-of-the-box experience
- Performance can vary depending on the chosen backend
Code Comparison
TestCafe example:
test('Login test', async t => {
await t
.typeText('#username', 'myuser')
.typeText('#password', 'mypassword')
.click('#login-button')
.expect(Selector('.welcome-message').exists).ok();
});
CodeceptJS example:
Feature('Login');
Scenario('Login test', ({ I }) => {
I.amOnPage('/login');
I.fillField('username', 'myuser');
I.fillField('password', 'mypassword');
I.click('Login');
I.see('Welcome');
});
Both frameworks offer powerful testing capabilities, but CodeceptJS provides more flexibility and a higher-level syntax, while TestCafe offers a simpler setup and potentially better performance for web-specific testing.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Automate end-to-end web testing with TestCafe, a Node.js-based testing framework.
TestCafe is free and as easy to use as 1-2-3:
1. Write your tests in JS or TypeScript.
2. Execute your tests.
3. View test results.
Homepage ⢠Documentation ⢠FAQ ⢠Support
- Works on all popular environments: TestCafe runs on Windows, MacOS, and Linux. It supports desktop, mobile, remote and cloud browsers (UI or headless).
- 1 minute to set up: You do not need WebDriver or any other testing software. Install TestCafe with one command, and you are ready to test:
npm install -g testcafe
- Free and open source: TestCafe is free to use under the MIT license. Plugins provide custom reports, integration with other tools, launching tests from IDE, etc. You can use the plugins made by the GitHub community or create your own.
Running a sample test in Safari
Table of contents
- Features
- TestCafe Studio: IDE for End-to-End Web Testing
- Getting Started
- Documentation
- Get Help
- Issue Tracker
- Stay in Touch
- Contributing
- Plugins
- Different Versions of TestCafe
- Badge
- License
- Creators
Features
Stable tests and no manual timeouts
TestCafe automatically waits for page loads and XHRs before the test starts and after each action.
It also features smart test actions and assertions that wait for page elements to appear.
You can change the maximum wait time.
If elements load faster, tests skip the timeout and continue.
Rapid test development tool
When you enable live mode, changes to test code immediately restart the test, and you instantly see the results.
Latest JS and TypeScript support
TestCafe supports the most recent JavaScript-related features, including ES2017 (async/await). You can also use TypeScript if you prefer a strongly typed language instead.
Detects JS errors in your code
TestCafe reports JS errors that it locates on a given webpage. Tests automatically fail if TestCafe encounters such errors.
You can, however, disable this option.
Concurrent test launch
TestCafe can open multiple instances of the same browser and run parallel tests (to help decrease test execution time).
PageObject pattern support
The TestCafe's Test API includes a high-level selector library, assertions, etc.
You can combine them to implement readable tests with the PageObject pattern.
const macOSInput = Selector('.column').find('label').withText('MacOS').child('input');
Easy to include in a continuous integration system
You can run TestCafe from a console, and its reports can be viewed within CI systems (TeamCity, Jenkins, Travis & etc.)
Love TestCafe Open-source Edition? Want to Record Tests without Writing JavaScript or TypeScript Code?
TestCafe Studio: IDE for End-to-End Web Testing
TestCafe is the perfect choice for JavaScript developers and experienced Q&A teams. If youâd like to delegate testing to QA engineers and are looking for a code-free way to record and maintain tests compatible with your existing infrastructure, check out TestCafe Studio - a testing IDE built atop the open-source version of TestCafe.
Review the following article to learn how TestCafe Studio can fit into any workflow: What's Better than TestCafe? TestCafe Studio.
Record and Run a Test in TestCafe Studio
Getting Started
Installation
Ensure that you run Node.js version 16 or higher, and run the following command:
npm install -g testcafe
Creating the Test
For this simple example, we will test the following page: https://devexpress.github.io/testcafe/example
Create a .js or .ts file on your computer. Remember that a .js or .ts file must maintain a specific structure: tests must be organized into fixtures. You can paste the following code to see the test in action:
import { Selector } from 'testcafe'; // first import testcafe selectors
fixture `Getting Started`// declare the fixture
.page `https://devexpress.github.io/testcafe/example`; // specify the start page
//then create a test and place your code within it
test('My first test', async t => {
await t
.typeText('#developer-name', 'John Smith')
.click('#submit-button')
// Use the assertion to check if actual header text equals expected text
.expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');
});
Running the Test
Call the following command in a command shell. Specify the target browser and file path.
testcafe chrome test1.js
TestCafe opens the browser and begins test execution.
Important: Make certain the browser tab that runs tests stays active. Do not minimize the browser window. Inactive tabs and minimized browser windows switch to lower resource consumption mode. In low consumption mode, tests may not execute correctly.
Viewing the Results
TestCafe outputs results into a command shell by default. See Reporters for more information. You can also use plugins to customize reports.
Read the Getting Started page for additional assistance.
Documentation
Visit the following webpage to review our online help system: Documentation.
Get Help
Join the TestCafe community on Stack Overflow. Ask and answer questions using the TestCafe tag.
Issue Tracker
Use our GitHub issues page to report bugs and suggest enhancements.
Stay in Touch
Follow us on Twitter. We post TestCafe news and updates.
Contributing
Read our Contributing Guide to learn how to contribute to the project.
To create your own plugin for TestCafe, you can use these plugin generators:
- Build a browser provider to set up tests on your on-premises server farm, to use a cloud testing platform, or to start your local browsers in a special way. Use this Yeoman generator to write only a few lines of code.
- To build a custom reporter with your formatting and style, check out this generator.
If you want your plugin to be listed below, send us a note in a Github issue.
Thanks to all of our contributors â We appreciate your commitment to the TestCafe community.
aha-oretama | ai | aleks-pro | Aleksey28 | AlexanderMoiseev | AlexanderMoskovkin |
alexey-lin | AlexKamaev | alexphilin | AlexSkorkin | alexwybraniec | AnastasiaIvanova8 |
andrewbranch | AndreyBelym | AndyWendt | AnnaKondratova | anthophobiac | Artem-Babich |
Arthy000 | augustomezencio-hotmart | bdwain | benmonro | beyondcompute | bill-looby-i |
bsmithb2 | caseyWebb | cdrini | cgfarmer4 | Chris-Greaves | churkin |
dej611 | DIRECTcut | Dmitry-Ostashev | eignatyev | ericyd | Farfurix |
flora8984461 | GeoffreyBooth | helen-dikareva | honsq90 | infctr | inikulin |
Ivan-Katovich | jamesgeorge007 | jaypea | josephmalam | kanhaiya15 | karolnowinski |
kirovboris | kisrefod | LavrovArtem | link89 | lzxb | macdonaldr93 |
MargaritaLoseva | Marketionist | MatthewNielsen27 | mattkubej | mattmanske | mcjim |
miherlosev | morfey13 | mostlyfabulous | murajun1978 | NickCis | Nuarat |
Ogurecher | PayBas | pgorny | pietrovich | radarhere | raspo |
rbardini | renancouto | rob4629 | rueyaa332266 | sgrillon14 | smockle |
stefanschenk | superroma | sylbru | taiki-fw | testcafe-build-bot | theghostbel |
titerman | tobiasbueschel | varunkumar | VasilyStrelyaev | vitalics | Vla8islav |
wentwrong | b12031106 | danielroe | danieltroger | DevSide | intermike |
kirillsalikhov | michaelficarra | rr13k | tomashanacek | TrevorKarjanis |
Plugins
TestCafe developers and community members made these plugins:
-
Browser Providers
Use TestCafe with cloud browser providers and emulators.- SauceLabs provider (by @AndreyBelym)
- BrowserStack provider (by @AndreyBelym)
- CrossBrowserTesting provider (by @sijosyn)
- LambdaTest provider (by @kanhaiya15)
- Nightmare headless provider (by @ryx)
- Testingbot provider (by @testingbot)
- fbsimctl iOS emulator (by @ents24)
- Electron (by @AndreyBelym)
- Puppeteer (by @jdobosz)
- Puppeteer Chromium (by @stefanschenk)
-
Framework-Specific Selectors
Work with page elements in a way that is native to your framework.- React (by @kirovboris)
- Angular (by @miherlosev)
- Vue (by @miherlosev)
- Aurelia (by @miherlosev)
-
Plugins for Task Runners
Integrate TestCafe into your project's workflow. -
Custom Reporters
View test results in different formats.- TeamCity (by @nirsky)
- Slack (by @Shafied)
- NUnit (by @AndreyBelym)
- TimeCafe (by @jimthedev)
- Tesults (by @Tesults)
-
GitHub Action
Run TestCafe tests in GitHub Actions workflows. -
Test Accessibility
Find accessibility issues in your web app. -
IDE Plugins
Run tests and view results from your favorite IDE.- TestCafe Test Runner for Visual Studio Code (by @romanresh)
- TestLatte for Visual Studio Code (by @Selminha)
- TestCafe runner for Webstorm (by @lilbaek)
- Code snippets for TestCafe (by @hdorgeval)
- SublimeText (by @churkin)
-
ESLint
Use ESLint when writing and editing TestCafe tests.- ESLint plugin (by @miherlosev)
-
Cucumber Support
Create and run tests that use the Cucumber syntax.- gherkin-testcafe (by @kiwigrid, now maintained by @Arthy000) - run your Cucumber tests with TestCafe as a backend. Requires CucumberJS.
- testcafe-cucumber-steps (by @Marketionist) - provides predefined Cucumber steps for gherkin-testcafe.
Different Versions of TestCafe
TestCafe | TestCafe Studio | |
---|---|---|
No need for WebDriver, browser plugins or other tools | ✓ | ✓ |
Cross-platform and cross-browser out of the box | ✓ | ✓ |
Write tests in the latest JavaScript or TypeScript | ✓ | ✓ |
Clear and flexible API supports ES6 and PageModel pattern | ✓ | ✓ |
Stable tests due to the Smart Assertion Query Mechanism | ✓ | ✓ |
Tests run fast due to intelligent Automatic Waiting Mechanism and Concurrent Test Execution | ✓ | ✓ |
Custom reporter plugins | ✓ | ✓ |
Use third-party Node.js modules in test scripts | ✓ | ✓ |
Integration with popular CI systems | ✓ | ✓* |
Free and open-source | ✓ | |
Visual Test Recorder | ✓ | |
Interactive Test Editor | ✓ | |
Automatic Selector Generation | ✓ | |
Run Configuration Manager | ✓ | |
IDE-like GUI | ✓ |
* You can use open-source TestCafe to run TestCafe Studio tests in CI systems.
Badge
Show everyone you are using TestCafe:
To display this badge, add the following code to your repository readme:
<a href="https://github.com/DevExpress/testcafe">
<img alt="Tested with TestCafe" src="https://img.shields.io/badge/tested%20with-TestCafe-2fa4cf.svg">
</a>
Thanks to BrowserStack
We are grateful to BrowserStack for providing the infrastructure that we use to test code in this repository.
License
Code released under the MIT license.
Creators
Developer Express Inc. (https://devexpress.com)
Top Related Projects
Fast, easy and reliable testing for anything that runs in a browser.
JavaScript API for Chrome and Firefox
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Next-gen browser and mobile automation test framework for Node.js
A browser automation framework and ecosystem.
Supercharged End 2 End Testing Framework for NodeJS
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot