Skip to main content

saveScreenshot

Overview

Use the saveScreenshot command to save a screenshot of the current browser context to a PNG file.

Keep in mind that some browser drivers capture screenshots of the entire document (e.g., the Gecko driver for Firefox), while others capture only the current viewport (e.g., Chromedriver for Chrome).

Usage

await browser.saveScreenshot(filepath);

Command Parameters

NameTypeDescription
filepathStringThe path to the screenshot relative to the execution directory (the .png extension is mandatory).

Usage Examples

it("should save a screenshot of the browser view", async ({ browser }) => {
await browser.saveScreenshot("./some/path/screenshot.png");
});

References

We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.