2022-08-06 14:49:20 +00:00
---
sidebar_label: Page.emulateMediaFeatures
---
# Page.emulateMediaFeatures() method
2022-10-24 14:31:12 +00:00
#### Signature:
2022-08-06 14:49:20 +00:00
```typescript
class Page {
2023-11-15 10:48:54 +00:00
abstract emulateMediaFeatures(features?: MediaFeature[]): Promise< void > ;
2022-08-06 14:49:20 +00:00
}
```
## Parameters
2023-03-06 13:53:56 +00:00
| Parameter | Type | Description |
| --------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| features | [MediaFeature ](./puppeteer.mediafeature.md )\[\] | _(Optional)_ < code > < ?Array< Object>> </ code > Given an array of media feature objects, emulates CSS media features on the page. Each media feature object must have the following properties: |
2022-08-06 14:49:20 +00:00
**Returns:**
Promise< void>
## Example
```ts
await page.emulateMediaFeatures([
{name: 'prefers-color-scheme', value: 'dark'},
]);
await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches);
// → true
await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
// → false
await page.emulateMediaFeatures([
{name: 'prefers-reduced-motion', value: 'reduce'},
]);
await page.evaluate(
() => matchMedia('(prefers-reduced-motion: reduce)').matches
);
// → true
await page.evaluate(
() => matchMedia('(prefers-reduced-motion: no-preference)').matches
);
// → false
await page.emulateMediaFeatures([
{name: 'prefers-color-scheme', value: 'dark'},
{name: 'prefers-reduced-motion', value: 'reduce'},
]);
await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches);
// → true
await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
// → false
await page.evaluate(
() => matchMedia('(prefers-reduced-motion: reduce)').matches
);
// → true
await page.evaluate(
() => matchMedia('(prefers-reduced-motion: no-preference)').matches
);
// → false
await page.emulateMediaFeatures([{name: 'color-gamut', value: 'p3'}]);
await page.evaluate(() => matchMedia('(color-gamut: srgb)').matches);
// → true
await page.evaluate(() => matchMedia('(color-gamut: p3)').matches);
// → true
await page.evaluate(() => matchMedia('(color-gamut: rec2020)').matches);
// → false
```