-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathwindows.spec.js
30 lines (24 loc) · 940 Bytes
/
windows.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const {Builder} = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const assert = require("node:assert");
let opts = new chrome.Options();
opts.addArguments('--headless');
let startIndex = 0
let endIndex = 5
let pdfMagicNumber = 'JVBER'
let base64Code
describe('Interactions - Windows', function () {
let driver;
before(async function () {
driver = await new Builder().forBrowser('chrome').setChromeOptions(opts).build();
});
after(async () => await driver.quit());
it('Should be able to print page to pdf', async function () {
await driver.get('https://www.selenium.dev/selenium/web/alerts.html');
let base64 = await driver.printPage({pageRanges: ["1-2"]});
// page can be saved as a PDF as below
// await fs.writeFileSync('./test.pdf', base64, 'base64');
base64Code = base64.slice(startIndex, endIndex)
assert.strictEqual(base64Code, pdfMagicNumber)
});
});