TestCafe — Running our tests in parallel

Adrian Benko
Published in
4 min readJan 12, 2022


In our previous post, we took a look at and implemented our very first simple test to verify that the entered name is displayed correctly on the page. In that post, we learned how to install and configure TestCafe and how to run our e2e tests. Today we’ll dig a little deeper into the framework’s capabilities. To optimize the effort and reduce the execution time of our tests, we’ll run our tests in parallel in two different browsers! Ready? Let’s start!

Running our tests in parallel

There’s no doubt that running tests in parallel can save a lot of time and resources. Since has only one test at the moment, we will add a second test to demonstrate the efficiency of parallel execution via TestCafe.

Select your Operating System

In our first test, we used the input box and verified that the typed in name appears correctly on the second page. This time we’ll use the radio buttons from the second column of the TestCafe Example page .

The simplified test scenario

  1. Open the TestCafe Example page
  2. Select our Operating system (MacOS) from the available radio buttons
  3. To make sure that TestCafe performed the methods correctly, place an assertion on the selected radio button at the end of the test

Easy, right? Let’s do it then.

Let’s implement the actual test

First of all, we need to check the locator of the macos radio button and add it to our pageObject class, so we’ll be able to use it in our tests.

this.osOptions = Selector('#macos');

Once this is ready, we implement our second test so that the parallel execution can be demonstrated.

Before we execute our tests in parallel, we should make sure that they are still ok so let’s run them in a single browser window via the testcafe chrome test.js command.

Single execution output

Great! So far we’re good.

Running our tests in parallel using Chrome

The template command, to execute the tests in parallel looks like this:


Since we have two tests only, it doesn’t make any sense to set the _NUMBER_OF_BROWSER_ value to more than 2. You can still set it to 3, 4 or any bigger number, the 3rd, 4th, etc. browsers will still open, but they will end up with an empty page because they’re no tests left for those browsers. You’ll consume more system resources without any benefit. We are going to use the following command to run our two tests in parallel:

> testcafe -c 2 chrome test.js

Parallel execution in Chrome

As you can see from the report, even though we have only two tests executed, we could still save a whole second in test execution time.

Obviously, the more tests you have, the more time you can save, just don’t overcomplicate it. If you’re an experienced tester, you’re already familiar with this. If not, let me share a big secret with you: there’s no need to execute each test in a new browser window! Opening and closing of the browser windows consumes system resources, takes time so that it can backfire on you quickly. Be wise enough to divide your tests into different test suites and run those test suites in parallel, instead of running every test in a new window.

Running our tests in parallel in Chrome and Firefox

I know what you’re thinking. What if my app/webpage has to support both Chrome and Firefox and I need to run my tests in both browsers? Besides that, you may also want to run these tests in parallel so that you can save some time. Since the customer is king, let me make you happy quickly (wow, that sounds weird 🙂 ).

Before executing the tests in parallel, make sure that the single execution via Firefox works fine:

> testcafe firefox test.js

If you read carefully, you should already know how to run our two tests in parallel in Chrome and Firefox. Yes, the correct command for this is:

testcafe -c 2 chrome,firefox test.js

This command will open two instances of Google Chrome and two instances of Mozilla Firefox and will execute the tests in them. Pretty awesome, right?


As you can see even from this post, running our tests in parallel via TestCafe is easy, no additional configuration is required. Running your tests parallel in two different browsers is also not an issue, so why do you still hesitate to give it a try and give a chance to this excellent framework? 🙂

In our next post, we’ll take a look at the headless mode, stay tuned!

Originally published at https://testautonation.com.



Adrian Benko

Adrian spent 10+ years as a QA, he's passionate about education, and he used to teach at universities in Budapest about Test Automation.