.takeScreenshot() Suggest edits
Since: 3.0.0Take a screenshot of the visible region encompassed by this element's bounding rectangle.
Usage
browser.element(selector).takeScreenshot()
Example
export default {
demoTest(browser: NightwatchAPI): void {
const screenshot = browser.element('#main').takeScreenshot();
screenshot.then((screenshotData) => {
require('fs/promises').writeFile('out.png', screenshotData, 'base64');
});
},
async demoTestAsync(browser: NightwatchAPI): Promise<void> {
const screenshotData = await browser.element('#main').takeScreenshot();
require('fs/promises').writeFile('out.png', screenshotData, 'base64');
}
}
Returns
Type | description |
---|---|
ScopedValue<string> |