t.resizeWindowToFitDevice Method

Resizes the window to fit the screen of the specified mobile device. Can be chained with other TestController methods.

t.resizeWindowToFitDevice(deviceName [, options]) → this | Promise<any>
Parameter Type Description
deviceName String The name of the device. See the list of supported devices in this repository.
options (optional) Object Provide additional information about the device.

The options object can contain the following properties.

Property Type Description
portraitOrientation Boolean true for portrait screen orientation; false for landscape.

Important

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

The example below shows how to use the t.resizeWindowToFitDevice action.

import { Selector } from 'testcafe';

const header = Selector('#header');

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

test('Header is displayed on Xperia Z in portrait', async t => {
    await t
        .resizeWindowToFitDevice('Sony Xperia Z', {
            portraitOrientation: true
        })
        .expect(header.getStyleProperty('display')).notEql('none');
});

You can resize window to specified dimensions with t.resizeWindow method and maximize window with t.maximizeWindow method.