saveScreenshot
Save a screenshot as a base64 encoded PNG with the current state of the browser. Be aware that some Selenium driver
are taking screenshots of the whole document (e.g. phantomjs) and others only of the current viewport. If you want
to always be sure that the screenshot has the size of the whole document, use wdio-screenshot
to enhance this command with that functionality.
This command also doesn’t support the element screenshot
feature yet as it isn’t supported by most of the drivers. However the protocol command for it is available
to use (see elementIdScreenshot).
Usage
1
| browser.saveScreenshot([filename]);
|
Parameters
Param |
Type |
Details |
filename optional |
Function/String |
path to the generated image (relative to the execution directory) |
Example
saveScreenshot.js1 2 3 4 5 6 7 8 9 10 11
| it('should save a screenshot of the browser view', function () { var screenshot = browser.saveScreenshot(); fs.writeFileSync('./myShort.png', screenshot)
screenshot = browser.saveScreenshot('./snapshot.png');
browser.saveScreenshot('./snapshot.png'); });
|
Uses