Skip to content

takeScreenshot

Philipp Stracker edited this page Aug 12, 2021 · 2 revisions
takeScreenshot(imageName[, which[, element]])

Takes a screenshot of the current viewport and saves it as a PNG image in the defined path (usually tests/output or tests/screenshots/base)

Parameters

imageName

Filename of the generated screenshot. If a file with the given name exists, it will be overwritten. The .png extension is optional.

which

Optional. Define the type of the screenshot. Possible values are actual and expected.

Default is "actual"

element

Optional. Take a screenshot of a single element on the page, instead of the entire viewport.

Default is null, which clips the entire viewport.

Samples

// Take a screenshot of the entire viewport and 
// save it as output/dashboard.png.
await I.takeScreenshot("dashboard");

// Take a screenshot of the entire viewport and 
// save it as screenshots/base/dashboard.png.
await I.takeScreenshot("dashboard", "expected");

// Take a screenshot of the #menu element and 
// save it as output/dashboard-menu.png.
await I.takeScreenshot("dashboard-menu.png", "", "#menu");

← Method: getVisualDifferences() | Comparison Options →