-
Notifications
You must be signed in to change notification settings - Fork 14
/
fps.js
50 lines (45 loc) · 1.11 KB
/
fps.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
43
44
45
46
47
48
49
50
const { chromium } = require('playwright');
const path = require('path');
(async () => {
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
const client = await context.newCDPSession(page);
await client.send('Overlay.setShowFPSCounter', { show: true });
await page.goto('https://fireship.io/');
await page.screenshot({
path: 'screenshots/fps-before.jpeg',
type: 'jpeg',
clip: {
x: 0,
y: 0,
width: 370,
height: 370,
},
});
// Do graphical regressions here by interacting with the page
await client.send('Input.synthesizeScrollGesture', {
x: 100,
y: 100,
yDistance: -400, // negative to scroll down
repeatCount: 3,
});
await page.screenshot({
path: 'screenshots/fps-after.jpeg',
type: 'jpeg',
clip: {
x: 0,
y: 0,
width: 370,
height: 370,
},
});
console.log(
`Check the screenshots at: ${path.join(
__dirname,
'screenshots',
)} fps-before.jpeg / fps-after.jpeg`,
);
await page.close();
await browser.close();
})();