Skip to content

Playwright Capture PDF

Lena edited this page Jun 15, 2021 · 1 revision

PDF Screenshots

For earlier versions of playwright, the healdess browser mode should be set to false

  • await page.pdf({path: 'fullpage.pdf'});

Setting local browser

const browser = await chromium.launch({ headless: false, executablePath: "/Applications/Google\ Chrome.app/Contents/.../Google\ CHrome"
});

Page Emulation

Emulation is set on the context level

const {devices} = require('playwright');

const iPhone = devices['iPhone 11 Pro Max landscape']
const browser = await chromium.launch({ headless: false});
const context = await browser.newContext({
    ...iPhone,
    viewport: {width: 1280, height: 2014}, //overrides iphone settings
    videoPath: 'videos/'

});

Clone this wiki locally