How to use installed version of chrome in Playwright?

Viewed 12274

I want to use chrome instead of chromium. I can achieve the same in puppeteer by providing executable path. In playwright it doesn't work as browser type argument supports only 'chromium, webkit, firefox'

const { chromium } = require('playwright');
(async () => {
    const browser = await chromium.launch({
        headless: false,
        executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
    });
    const context = await browser.newContext();
    const page = await context.newPage();
    await page.goto('http://whatsmyuseragent.org/');
    await page.screenshot({ path: `example-${browserType}.png` });
})();

3 Answers

You need to pick one of those flavors. But once you pick the browser type Chromium, you will still be able to pass an executablePath to the launch function.

In 1.19 you can use chrome.

browser = playwright.chromium.launch(channel="chrome")

or you can simply put it in your playwright configuration file like:

////
    use: {
        headless: true,
        viewport: { width: 1600, height: 1000},
        ignoreHTTPSErrors: true,
        trace: 'on',
        screenshot: 'on',
        channel: "chrome",
        video: 'on'
    },
    ////

More on https://playwright.dev/python/docs/browsers

You can specify browser path in config option

////
use: {
    headless: true,
    viewport: { width: 1600, height: 1000},
    channel: 'chrome',
    launchOptions: {
        executablePath: '/path/to/the/browser',
    },
},
Related