Run Tests

Select a Run Configuration

TestCafe Studio can run tests in desktop, headless, and mobile browsers. It determines which browsers are installed on the local computer and automatically creates run configurations for them. You can view available configurations and switch between them in the Run Configuration drop-down menu.

Run Congiruation Menu

To modify configurations or create a new one, click Settings button next to the Run Configuration drop-down menu and use the Run Configurations dialog. You can select one or more browsers and specify options that affect test execution for each configuration.

Run Configurations Dialog

Start and Stop Tests

Note

Before running tests, select a desired run configuration from the Run Configuration list.

You can run a test directory/subdirectory, a file with tests, a specific fixture, or an individual test.

To run an entire test directory or subdirectory, click Run all tests button Run all tests next to the directory in the Explorer panel.

To run a recorded test file or a specific fixture from the Explorer panel, click Run all tests button Run all tests next to the corresponding node. You can also run a specific fixture from the Fixture Editor by clicking Run all tests button on the toolbar.

To run an individual test, choose one of the following:

  • Click Run test button Run test on the Test Editor's toolbar.
  • Click Run test button Run test next to the test in the Fixture Editor or Explorer panel.

To run a test script file, click Run test button Run test next to the file in the Explorer panel. You can also click Run test button to run test fixtures and individual tests from the Code Editor.

To run several tests from different fixtures and directories, select the tests in the Explorer panel using Shift-click, Ctrl-click, or Command-click, then select Run tests from the context menu or click The Run tests button Run Tests next to any selected item.

Run multiple items

After starting a test, TestCafe Studio launches the specified browsers and executes tests in them simultaneously. The Reports panel displays the tests' progress.

Click Stop recording button in the Reports panel to stop the test run.

Note

If the run configuration's Pause the test when it fails option is enabled and a test fails, TestCafe Studio pauses the test and you can debug it. To finish the test, click Finish in the status panel. Debug panel

Run Tests in Headless Browsers

TestCafe Studio allows you to run tests in browsers without a user interface - in headless mode. It automatically creates separate run configurations for local browsers that can be run headless.

Headless browsers configurations

You can also create your own run configuration and select desired headless browsers in run configuration settings.

All headless browsers

You can run tests in headless browsers in the same way as you do for browsers with a user interface: select a desired run configuration, then start tests. TestCafe Studio runs tests in the background, however you can view test progress in the Reports panel.

Run Tests on Remote Computers and Mobile Devices

TestCafe Studio allows you to run tests on any device that has network access to the machine where TestCafe Studio is installed.

Follow the steps below to run a test in remote browsers:

  1. Create a run configuration for remote testing. In run configuration settings, select the Remote browser checkbox and specify the number of browser instances you are going to use for testing.

    Remote Browser Configuration

  2. Select this configuration in the Run Configuration list.

  3. Click Run test button Run test to start the test. TestCafe Studio provides URLs to open in remote browsers.

    Run tests in remote browsers

Launch the desired browsers on a remote device and open the provided URLs in them, or use your device to scan QR-codes that represent the same URLs. The browsers connect to the TestCafe Studio server and start testing.

Concurrent Test Execution

TestCafe Studio allows you to execute tests concurrently. You can use the Concurrency mode to invoke multiple browser instances. Each test runs in the first available instance.

To enable this mode and specify the number of browser instances, use the run configuration's Concurrency option available in Advanced Options).

Note

TestCafe Studio cannot run concurrent tests in Microsoft Edge, because there is no known way to start Edge in a new window and make it open a URL.

You can also use the Concurrency option when testing a webpage in multiple browsers.

Concurrency in multiple browsers

In this case, the same tests run in four Safari and four Firefox instances.

When you run tests in a remote browser, the number of browser instances should be divisible by the concurrency parameter's n value. Otherwise, an exception is thrown.

If you test against multiple remote browsers, open and connect one browser's instances before you connect the next browser.

Built-in Wait Mechanisms

Wait for an Action's Target Element

Before starting an on-page action, the test waits for the action's target element to appear in the webpage's DOM and become visible during the specified timeout. The status panel displays the Waiting for element to appear... status at this moment.

Wait for action targets

The test fails if the element cannot be found.

If a test contains the Switch to Iframe action, TestCafe Studio waits until the target iframe is loaded completely or the predefined timeout (5000 milliseconds) is reached before performing test actions in the iframe.

Note

The Set Files to Upload and Clear Upload actions do not require that the target element is visible.

Wait for an Assertion to Pass

When a test executes an assertion, it recalculates the assertion until it matches the expected result or the assertion timeout is reached. Refer to Assertion Options for more information about assertion timeouts.

The status panel displays the blue Waiting for assertion execution... status at this moment.

Note

If an assertion's target is an element property, the assertion waits for the element to become visible before checking its property. The same mechanism is used in waiting for an on-page action's target element.

Example

The following assertion waits for the search results to become visible on the page and checks if the hotel count is 5 (the 5 HOTELS text should appear):

Deep Equal assertion

If the checked element does not appear within the timeout, the assertion fails (the Waiting for assertion execution... status color changes to red).

Failed assertion

If the element appears within the timeout and the textContent property's value is 5 HOTELS, the assertion passes (the status color changes to green).

Passed assertion

Wait for Webpages to Load

TestCafe Studio waits until a webpage is loaded in the following cases:

  • when you start a test run;
  • when a test action triggers a redirect to another page.

While the browser is waiting for the server's response, the status panel shows the Loading web page... status.

Loading web page

The maximum wait time is 3000 milliseconds. When the timeout is over, the test starts or continues the execution even if the page is not completely loaded.

If the page requires extra time to load, you can add an assertion that verifies if page content is loaded.