t.resizeWindowToFitDevice Method

Important

Make sure that your testing environment meets the necessary requirements before you add this method to your test suite.

Resizes the window to fit the screen of the specified mobile device. The method is chainable.

Note

Browser windows retain their size between tests and fixtures. Reset window size at the beginning of tests if necessary.

t.resizeWindowToFitDevice(deviceName [, options]) → this | Promise<any>
Parameter Type Description
deviceName String The name of the device. See the list of compatible devices for more information.
options (optional) Object Additional options.

The options object can contain the following properties:

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

See the Resize Windows section of the Test Actions guide to learn about other methods that resize windows:

Example

import { Selector } from 'testcafe';

const menu = Selector('.sidebar');

fixture`TestController.resizeWindowToFitDevice`
    .page`https://devexpress.github.io/testcafe/documentation/reference`;

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