-
Notifications
You must be signed in to change notification settings - Fork 0
/
blur.js
39 lines (35 loc) · 851 Bytes
/
blur.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
const {
analyze,
blur,
focus,
launch,
} = require('../src/puppeteer');
let browser;
let page;
const starting = 'https://hrobertking.github.io/thinking-about-web-accessibility/automated-test-example.html';
launch({
height: 1080,
quiet: true,
summary: true,
url: starting,
width: 1920,
})
.then((response) => {
({ browser, page } = response);
analyze({ action: 'load', target: starting });
return page.screenshot({ path: 'examples/screenshot/blur-loaded.png' });
})
.then(async () => {
await focus({
target: '#toggle-button'
});
return page.screenshot({ path: 'examples/screenshot/blur-focused.png' });
})
.then(async () => {
await blur({
target: '#toggle-button'
});
return page.screenshot({ path: 'examples/screenshot/blur-blurred.png' });
})
.then(() => browser.close())
.catch(() => browser.close());