setViewportSize method

Class: EyesPlatform: PlaywrightLanguage: JavaScript SDK:

Set the default viewport size property. Eyes uses this if a subsequent call to open is done without a viewport size. This also changes the browser viewport size to the given size immediately, instead of when open is called.

This property will be displayed by the Test Manager along with the other test information. The value is also taken into consideration when finding a matching baseline.

Syntax

await Eyes.setViewportSize(driver, viewportSize_rectanglesize);
await Eyes.setViewportSize(viewportSize_rectanglesizeplain);

Note: This method has both static and non static overloads.

Parameters

driver
Type:Page
The driver returned from the call to open.
viewportSize_rectanglesize
Type:RectangleSize

The size of the viewport

The size of the viewport passed as an object.

The size of the viewport passed as an object {'width':, 'height':}

An object that defines the viewport size.

The size of the viewport

The size of the viewport passed as an object.

The size of the viewport passed as an object {'width':, 'height':}

viewportSize_rectanglesizeplain
Type:RectangleSizePlain

The size of the viewport

The size of the viewport passed as an object.

The size of the viewport passed as an object {'width':, 'height':}

A literal object that defines the viewport size.

The size of the viewport

The size of the viewport passed as an object.

The size of the viewport passed as an object {'width':, 'height':}

Return value

Type: Promise<void>

Remarks

  • Call this method before the call to Eyes.open. Then, when calling the open method, don't pass the viewportSize parameter. If the viewport size is set to be smaller than the actual content, then scrolling should typically be enabled by calling setForceFullPageScreenshot method or setForceFullPageScreenshot method so that the full page image is tested.
This method is a static method.