Skip to content

Commit e9ce9a3

Browse files
author
Mick
committed
2 parents 2e9f3a5 + 2c219f7 commit e9ce9a3

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Headless chrome – testing WebGL using playwright
2+
3+
We have webgl animations that requires GPU hardware acceleration to achieve good performance. Smooth WebGL animation should run at 60 frames per second. Our e2e tests will visit website with webgl animation, take screenshot and save it as .png file. We will try with different playwright settings and check the results.
4+
5+
Testing canvas elements and WebGL animations is difficult task. To achieve smooth animations and good performance in end-to-end testing - framework Playwright is good choice. With proper configuration we can run parallel tests using hardware acceleration. Achieving 60 frames per seconds in WebGL animation is possible even in Headless Chrome.
6+
7+
#### Demo scenario
8+
Demo scenario is simple: visit three urls and take screenshots. First url: chrome://gpu/ to check if chrome having “Hardware accelerated” option enabled. Second url: https://www.soft8soft.com/webglreport to debug webgl browser settings and finally third url: https://webglsamples.org/aquarium/aquarium.html with animation.
9+
10+
Expected results: GPU hardware acceleration enabled and smooth animation with 60 frames per second.
11+
12+
#### One time initialization
13+
```
14+
npm install
15+
npx playwright install
16+
```
17+
18+
#### To run test
19+
```
20+
npx playwright test example1 --reporter=list
21+
Running 3 tests using 3 workers
22+
ok 1 [chromium] › example1.test.js:38:5 › Testing 123 › 3. aquarium (12s)
23+
ok 2 [chromium] › example1.test.js:31:5 › Testing 123 › 2. webgl report (5s)
24+
ok 3 [chromium] › example1.test.js:21:5 › Testing 123 › 1. GPU hardware acceleration (8s)
25+
3 passed (13s)
26+
```
27+
28+
#### Doing screenshots
29+
When writing Playwright tests you can decide to take full page screenshot at any time. Our script is executing :
30+
```
31+
await page.screenshot({ path: 'screens/screenshot' + currentTime + '_1.png', fullPage: true });
32+
```
33+
34+
Saved screenshots will be placed in /screens/ directory. Here are 3 screenshots saved after running headless Chrome with GPU support enabled (Hardware acceleration):
35+
36+
![](https://github.com/createit-dev/168-headless-chrome-get-60fps-in-windows/blob/master/images/playwright-headless-60-fps.jpg)
37+

0 commit comments

Comments
 (0)