13

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` });
})();
hardkoded
  • 18,915
  • 3
  • 52
  • 64
Rajesh G
  • 473
  • 3
  • 6
  • 20
  • 1
    While this code is correct, Playwright depends on new changes to Chromium upstream, and for that reason I would recommend using Chrome Canary instead of Chrome stable. You can get Canary from here: https://www.google.com/chrome/canary/ Let me know if that works! – arjunattam Jun 09 '20 at 16:18
  • It works ! The issue is it should be always the latest version of chrome to be installed in the local machine / the version that matches to Playwright chromium – Rajesh G Jun 10 '20 at 18:51
  • +1 for the question. I had the same question on how to test with an specific version of chrome ,i.e. 79/80. – Vishal Aggarwal Jun 10 '20 at 20:26
  • Any luck with other browsers? – gman Jan 11 '23 at 20:01

3 Answers3

9

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.

Boris Verkhovskiy
  • 14,854
  • 11
  • 100
  • 103
hardkoded
  • 18,915
  • 3
  • 52
  • 64
5

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

Gaj Julije
  • 1,538
  • 15
  • 32
2

You can specify browser path in config option

////
use: {
    headless: true,
    viewport: { width: 1600, height: 1000},
    channel: 'chrome',
    launchOptions: {
        executablePath: '/path/to/the/browser',
    },
},
vitmalina
  • 1,829
  • 1
  • 14
  • 7