-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpuppeteer-flow.js
42 lines (37 loc) · 1.45 KB
/
puppeteer-flow.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
31
32
33
34
35
36
37
38
39
40
41
42
const puppeteer = require("puppeteer");
const microtime = require('microtime');
(async () => {
console.log(microtime.now()," Launching Browser");
const browser = await puppeteer.launch({
defaultViewport: {
width: 1920,
height: 1080,
},
headless: false,
executablePath: "/usr/bin/firefox",
product: "firefox"
});
const page = await browser.newPage();
const dimensions = await page.evaluate(() => {
return {
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight,
deviceScaleFactor: window.devicePixelRatio,
};
});
// console.log("Dimensions:", dimensions); // Only to double-check if the dimensions are as expected
console.log(microtime.now()," Home Page");
await page.goto("http://gcb-wordpress", { // for this example we are running on port 80
waitUntil: "load",
});
await page.waitForSelector("#language-continue");
const text = await page.$eval('.screen-reader-text', element => element.textContent)
console.log(microtime.now(),` Found text content: ${text}`);
// await page.screenshot({ path: "img/filled-form.png", fullPage: true });
// console.log(
// "Screenshot taken at ",
// process.hrtime()[0] * 1000000000 + process.hrtime()[1] / 1000
// );
console.log(microtime.now()," Closing Browser");
await browser.close();
})();