File size: 831 Bytes
8e04495
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import {test, expect} from '@playwright/test';

import * as fs from 'fs';
import * as path from 'path';

// Filter for Python files (.py extension)
const pythonDemoFiles = fs
  .readdirSync(__dirname)
  .filter((file) => path.extname(file) === '.py');

console.log(pythonDemoFiles);

// Remove the skip if you want to re-generate the screenshots.
test('screenshot each demo', async ({page}) => {
  // This will take a while.
  test.setTimeout(0);

  await page.setViewportSize({width: 400, height: 300});

  for (const demoFile of pythonDemoFiles) {
    const demo = demoFile.slice(0, -3);
    await page.goto('/' + demo);
    await new Promise((resolve) => setTimeout(resolve, 3000));
    // Take a full-page screenshot
    await page.screenshot({
      path: `demo/screenshots/${demo}.png`,
      fullPage: true,
    });
  }
});