TestCafe v1.9.0 Released

We are happy to announce that multiple window support ships in a beta form with v1.9.0.


🌟 Multi Window Support (Beta)

TestCafe can now automate user actions in multiple windows. You can switch between open windows during the test. Make edits in one window and check that the other window’s content changes dynamically to reflect these modifications.

Testing in multiple windows

When the main window opens a child window, TestCafe automatically switches to this new window and continues test actions there:

import { Selector } from 'testcafe';

fixture `Login page`

const googleButton = Selector('div.login-panel-footer__login-with > button');

test('Login via Google', async t => {
    await t
        .typeText('input[type=email]', 'This text will be entered inside the pop-up');

You can use the t.openWindow method to open a child window in test code:

import { Selector, ClientFunction } from 'testcafe';

fixture `Test page`

test('Open a new window', async t => {
    await t.openWindow('http://example.com');

    const url = await t.eval(() => document.documentURI);

    await t.expect(url).eql('http://example.com');

The t.switchToWindow method enables you to switch between open windows. You can use a window descriptor or a predicate to specify the window that should be activated:

fixture `Example page`

test('Switch to a specific window', async t => {
    const initialWindow = await t.getCurrentWindow();
    const popUp1        = await t.openWindow('https://devexpress.com');
    const popUp2        = await t.openWindow('https://github.com');

    await t.switchToWindow(initialWindow);

    const url = t.eval(() => document.documentURI);

    await t.expect(url).eql('https://example.com/');

    await t
        .switchToWindow(w => w.url.host === 'github.com')

The t.switchToParentWindow and t.switchToPreviousWindow methods allow you to switch back to the parent window or the previously active window.

The t.closeWindow method closes the current window when called without arguments, or the specified window if you pass a descriptor or predicate:

fixture `Example page`

test('Close the current window', async t => {
    const window1 = await t.openWindow('http://devexpress.com');

    await t.closeWindow();

    const url = await t.eval(() => document.documentURI);

    await t.expect(url).eql('http://www.example.com/');

test('Close a specific window', async t => {
    const window1 = await t.openWindow('http://devexpress.com');

    await t.closeWindow(window1);

Detailed Diffs in Failed Assertions

Test run reports now show the differences between an assertion’s actual and expected values:

A report showing differences between asserted values

TestCafe can display difference between values, arrays, objects, and even functions.

Bug Fixes

  • TestCafe now throws a descriptive error when it attempts to start the browser UI on Linux without the X11 server (4461)
  • Exception no longer thrown when you use remote browsers on Linux without X11 or run Windows browsers from WSL2 (#4742)
  • Fixed a syntax error on pages whose code destructures empty function parameters
  • Fixed a bug when page titles were displayed incorrectly