saveScreenshot
Overview
Use the saveScreenshot
command to save a screenshot of an element to a PNG file.
Usage
await browser.$(selector).saveScreenshot(filepath);
Command Parameters
Name | Type | Description |
filepath | String | The 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 }) => {
const elem = await browser.$("#someElem");
await elem.saveScreenshot("./some/path/elemScreenshot.png");
});
References
We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.