docs/api/puppeteer.page.emulatemediatype.md
class Page {
abstract emulateMediaType(type?: string): Promise<void>;
}
Parameter
</th><th>Type
</th><th>Description
</th></tr></thead> <tbody><tr><td>type
</td><td>string
</td><td>(Optional) Changes the CSS media type of the page. The only allowed values are screen, print and null. Passing null disables CSS media emulation.
Returns:
Promise<void>
await page.evaluate(() => matchMedia('screen').matches);
// → true
await page.evaluate(() => matchMedia('print').matches);
// → false
await page.emulateMediaType('print');
await page.evaluate(() => matchMedia('screen').matches);
// → false
await page.evaluate(() => matchMedia('print').matches);
// → true
await page.emulateMediaType(null);
await page.evaluate(() => matchMedia('screen').matches);
// → true
await page.evaluate(() => matchMedia('print').matches);
// → false