saveScreenshot
Save a screenshot of an element to a PNG file on your OS.
Usage
$(selector).saveScreenshot(filename)
Parameters
Name | Type | Details |
---|---|---|
filename | String | path to the generated image (.png suffix is required) relative to the execution directory |
Example
- Asynchronous Mode
- Synchronous Mode
saveScreenshot.js
it('should save a screenshot of the browser view', async () => {
const elem = await $('#someElem');
await elem.saveScreenshot('./some/path/elemScreenshot.png');
});
saveScreenshot.js
it('should save a screenshot of the browser view', () => {
const elem = $('#someElem');
elem.saveScreenshot('./some/path/elemScreenshot.png');
});
caution
Synchronous Mode will depcrecated with Node.js v16. With an update to the underlying Chromium version it became technically impossible to provide the same synchronous behavior. We recommend to start transition to asynchronous command execution. For more information, see our RFC.