Skip to content

Commit c047319

Browse files
committed
[JS] Add code sample for takeScreesnhot
1 parent 769699a commit c047319

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

examples/javascript/test/interactions/windows.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,15 @@ describe('Interactions - Windows', function () {
4949
base64Code = encodedString.slice(startIndex, endIndex)
5050
assert.strictEqual(base64Code, imgMagicNumber)
5151
});
52+
53+
it('Should be able to takeScreenshot', async function () {
54+
await driver.get('https://www.selenium.dev/selenium/web/javascriptPage.html');
55+
56+
// Captures the screenshot
57+
let encodedString = await driver.takeScreenshot();
58+
// save screenshot as below
59+
// await fs.writeFileSync('./image.png', encodedString, 'base64');
60+
base64Code = encodedString.slice(startIndex, endIndex)
61+
assert.strictEqual(base64Code, imgMagicNumber)
62+
});
5263
});

0 commit comments

Comments
 (0)