-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdryrun.js
More file actions
25 lines (21 loc) · 765 Bytes
/
dryrun.js
File metadata and controls
25 lines (21 loc) · 765 Bytes
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
import WebPageTest from "webpagetest";
const wptServer = "https://www.webpagetest.org";
const wpt = new WebPageTest(wptServer, "YOUR_API_KEY");
let options = {
dryRun: true, // outputs the api endpoint
};
// multistep script
const script = wpt.scriptToString([
{ navigate: "https://timkadlec.com/" },
{ execAndWait: 'document.querySelector("#nav > ul > li:nth-child(2) > a").click();' },
{ execAndWait: 'document.querySelector("#nav > ul > li:nth-child(3) > a").click();' },
{ execAndWait: 'document.querySelector("#nav > ul > li:nth-child(4) > a").click();' },
]);
// fire up the runtest function with a script or a url
wpt.runTest(script, options, (err, result) => {
if (result) {
console.log(result);
} else {
console.log(err);
}
});