Skip to content

UI.resize()

Resizes the browser window or viewport during test execution.

The viewport is the visible area of the page, excluing the browser chrome such as the address bar, tabs, and window border.

By default, UI.resize() resizes the entire browser window unless target: "viewport" is specified.

Usage

js
// Resize the browser window
UI.resize(resolution: string) 
UI.resize(width: number, height: number)

// Pass { target: "viewport" } to resize the viewport
UI.resize(resolution: string, { target : "viewport" }) 
UI.resize(width: number, height: number, { target : "viewport" })

Parameters

ParameterTypeDescription
resolutionstringResolution in "<width>x<height>" format, e.g. 1920x1200.
widthnumberWidth in pixels.
heightnumberHeight in pixels.
options.targetstringSet to "viewport" to resize the viewport.
Set to "window" to resize the entire window (default).

Example

js
UI.resize("764x600", {target: "viewport"})
I.see(".mobile-menu")

In this example, the test resizes the browser viewport to a resolution of 764 × 600 pixels and verifies that the mobile menu is visible.