Skip to content

Instantly share code, notes, and snippets.

@bdelacretaz
Created January 24, 2020 14:04
Show Gist options
  • Save bdelacretaz/64ae25126932702c9d78e93871d6c86a to your computer and use it in GitHub Desktop.
Save bdelacretaz/64ae25126932702c9d78e93871d6c86a to your computer and use it in GitHub Desktop.
// Example capturing a 1200 x 6000 pixels screenshot
// from a website using https://github.com/microsoft/playwright
const pw = require('playwright');
(async () => {
const browser = await pw.firefox.launch(); // or 'chromium', 'firefox'
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://lecourrier.ch/');
const watchDog = page.mainFrame().waitForFunction('window.innerWidth > 1000');
page.setViewport({width: 1200, height: 6000});
await watchDog;
await page.screenshot({ path: 'lecourrier.png' });
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment