Use Your Installed Chrome with Playwright
In this article
Yes—you can tell Playwright to launch the Chrome browser that is already installed on your machine instead of the bundled Chromium build, simply by pointing Playwright to the Chrome executable.
What You'll Need
- Node.js (v14 or later) installed and added to your system PATH.
- Playwright package installed in your project (npm i -D @playwright/test or npm i -D playwright).
- A stable, up‑to‑date installation of Google Chrome (the regular desktop version, not Chromium).
- Basic familiarity with a terminal or command prompt.
Step‑by‑Step
- Verify Chrome’s installation path. On Windows the default location is
C:\Program Files\Google\Chrome\Application\chrome.exe. On macOS it is/Applications/Google Chrome.app/Contents/MacOS/Google Chrome. On Linux it is usually/usr/bin/google-chromeor/opt/google/chrome/google-chrome. Open a terminal and run the path with--versionto confirm it works, e.g.,"C:\Program Files\Google\Chrome\Application\chrome.exe" --version. - Initialize a Playwright project (if you haven’t already). In an empty folder run:
npm init -y npm i -D playwright
This createspackage.jsonand adds Playwright as a dev dependency. - Create a test file that uses the installed Chrome. Example
example.spec.js:const { test, expect, chromium } = require('@playwright/test'); test('open Google with local Chrome', async ({ }) => { const chromePath = process.platform === 'win32' ? 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' : process.platform === 'darwin' ? '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' : '/usr/bin/google-chrome'; const browser = await chromium.launch({ executablePath: chromePath, headless: false // set true if you do not need UI }); const context = await browser.newContext(); const page = await context.newPage(); await page.goto('https://www.google.com'); await expect(page).toHaveTitle(/Google/); await browser.close(); });The key is theexecutablePathoption that tells Playwright which binary to start. - Run the test. Use the Playwright test runner or a simple node command:
npx playwright test example.spec.js
You should see Chrome launch, navigate to Google, and then close after the assertion passes. - Optional: Use the Playwright CLI with a custom executable. If you prefer not to write code, you can launch a browser directly:
npx playwright launch --browser=chromium --executable-path="C:\Program Files\Google\Chrome\Application\chrome.exe"
This opens an interactive session where you can type commands. - Configure a global shortcut for future projects. Add a helper to your
package.jsonscripts:{ "scripts": { "test:chrome": "PLAYWRIGHT_CHROME_PATH='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' npx playwright test" } }Then runnpm run test:chrome. On macOS/Linux you can export the variable in your shell profile. - Handle version mismatches. Playwright expects a recent Chrome version that supports the DevTools protocol. If Chrome updates and Playwright throws "Protocol error" messages, update Playwright (npm i -D playwright@latest) or pin Chrome to a compatible version.
Common Mistakes
- Using the Chromium path (
chrome.exefrom Playwright’s cache) instead of the real Chrome executable. TheexecutablePathmust point to the genuine Chrome binary. - Leaving
headless: truewhen you need UI debugging. Chrome’s headless mode behaves slightly differently; setheadless: falseif you want to see the UI. - Forgetting to escape backslashes on Windows. Use double backslashes (
\\) or surround the path in quotes. - Running the script on a platform where the path does not exist (e.g., macOS path on a Linux machine). Use
process.platformto select the correct path dynamically. - Not updating Playwright after a major Chrome upgrade. Compatibility is maintained, but a stale Playwright version may not understand newer DevTools messages.
Tips
- Store the Chrome path in an environment variable (e.g.,
PLAYWRIGHT_CHROME_PATH) and reference it in code withprocess.env.PLAYWRIGHT_CHROME_PATH. This keeps your source clean and works across CI pipelines. - When running tests in CI, install Chrome via the official package manager (apt, yum, brew) and point Playwright to
/usr/bin/google-chrome. Most CI images already provide Chrome. - Enable
slowMo(e.g.,slowMo: 100) to see actions happen more clearly during debugging. - If you need to test Chrome extensions, launch Chrome with the
--disable-extensions-exceptand--load-extensionflags via theargsarray inchromium.launch. - Use
browserContext.overridePermissionsto grant or revoke permissions for a specific site, mirroring how a real Chrome user would experience prompts.
Troubleshooting
If Chrome does not start or Playwright throws an error, follow these steps in order:
- Check the executable path. Run the path manually in a terminal with
--version. If the command fails, the path is wrong or Chrome is not installed. - Confirm Playwright can access the file. On Windows, ensure the user running the script has read & execute permissions for
chrome.exe. On macOS/Linux, verify the file is executable (chmod +x /usr/bin/google-chrome). - Update both Chrome and Playwright. Run
npm i -D playwright@latestand, if needed, reinstall Chrome from the official website. - Disable conflicting Chrome flags. Some corporate or security policies add
--disable-gpuor sandbox flags that interfere with Playwright. Try launching with a minimalargsarray:args: []. - Inspect the error message. Common messages include "Failed to launch the browser" (path issue) or "Protocol error" (version mismatch). Search the exact phrase on the Playwright GitHub issues page for known fixes.
- Run in headless mode as a test. If UI mode fails, try
headless: true. Some environments (e.g., Docker without a display server) require headless. - Check for multiple Chrome installations. On Windows, both 64‑bit and 32‑bit versions may exist. Ensure you reference the version you intend to test.
- Clear Playwright's caches. Delete the
node_modules/.cache/playwrightfolder and reinstall the package. This forces Playwright to rediscover the browser binaries.
If none of the above resolves the issue, consider filing a bug on the Playwright repository with the full console output, OS details, and Chrome version.
Frequently Asked Questions
Can I use Chrome Beta or Chrome Dev with Playwright?
Yes. Provide the path to the beta or dev executable (e.g., chrome-beta.exe) in executablePath. Playwright treats any Chrome binary that supports the DevTools protocol the same way.
Do I need to set chromium as the browser type?
Yes. Playwright’s chromium driver works for Chrome, Chromium, and Edge. The executablePath determines which exact binary runs.
Will Playwright automatically download Chrome if it isn’t installed?
No. Playwright only downloads its own bundled Chromium. To use the installed Chrome you must point to it manually.
Is it possible to run Chrome in incognito mode with Playwright?
Use a new browser context: await browser.newContext({ viewport: null }). Each context starts with a fresh profile, equivalent to incognito.
How do I run Chrome on a headless CI server without a display?
Set headless: true and ensure the CI image includes the google-chrome-stable package. No additional X server is required.
Can I capture a video of the Chrome session?
Yes. When creating a context, add recordVideo: { dir: 'videos/' }. Playwright will save an MP4 of the session using the installed Chrome binary.