t.resizeWindow Method

Resizes a window to fit the parameters entered by user. Can be chained with other TestController methods.

t.resizeWindow(width, height) → this | Promise<any>
Parameter Type Description
width Number The new width, in pixels.
height Number The new height, in pixels.
important

t.resizeWindow requires .NET 4.0 or newer installed on Windows machines and an ICCCM/EWMH-compliant window manager on Linux.

The following example demonstrates how to use the t.resizeWindow action.

import { Selector } from 'testcafe';

const menu = Selector('#side-menu');

fixture `My fixture`
    .page `http://www.example.com/`;

test('Side menu disappears on small screens', async t => {
    await t
        .resizeWindow(200, 100)
        .expect(menu.getStyleProperty('display')).eql('none');
});

You can also resize window to fit a specified type of device with t.resizeWindowToFitDevice method and maximize window with t.maximizeWindow.