akwasiijunior
akwasiijunior

Reputation: 175

What devices are available using Playwright devices api?

Where can I find a full list of devices enabled to be used for emulation with Playwright testing

Upvotes: 1

Views: 11269

Answers (2)

akwasiijunior
akwasiijunior

Reputation: 175

Its not easy to find but here is the full list. The list is also obtainable by logging the devices variable.

Example :

const { chromium, devices } = require('playwright');
const iPhone11Pro = devices['iPhone 11 Pro'];

(async () => {
    const browser = await chromium.launch({
      headless: false, 
    });
    const context = await browser.newContext({
        viewport: iPhone11Pro.viewport,
        userAgent: iPhone11Pro.userAgent,
    });
    const page = await context.newPage();
    await page.goto('https://apple.com');
    
    console.log(devices); // Logs all devices

    await context.close();
    await browser.close();
})();

Upvotes: 6

Elias E. del Real
Elias E. del Real

Reputation: 69

An update of the answer by @akwasiijunior

You can view the current full list of devices here:

https://github.com/microsoft/playwright/blob/master/packages/playwright-core/src/server/deviceDescriptorsSource.json

You can also view it by installing Playwright, and printing it from a test, like so:

npm install -D @playwright/test

echo "const { devices } = require('@playwright/test'); console.log(devices)" > devices.spec.js

npx playwright test devices.spec.js

Upvotes: 3

Related Questions