User Agents

Web browsers and everyday web tech, explained

Playwright: How to Use Installed Chrome or Edge Browsers

· 6 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To make Playwright use an installed version of Google Chrome or Microsoft Edge instead of the bundled Chromium binaries, you must use the launch method with the channel property. By specifying channel: 'chrome' or channel: 'msedge', Playwright bypasses its own downloaded browser versions and looks for the official branded installation on your local operating system. This is particularly useful for testing extensions, verifying brand-specific rendering issues, or avoiding the overhead of downloading multiple large browser binaries in environments where the browser is already present.

What You'll Need

  • Node.js installed on your system.
  • The Playwright library installed via npm (npm install @playwright/test).
  • A stable installation of Google Chrome or Microsoft Edge on the host machine.
  • Basic knowledge of JavaScript or TypeScript.

Step-by-Step

  1. Verify Browser Installation: Ensure that Google Chrome or Microsoft Edge is installed in the default system directory. Playwright searches for the browser in standard installation paths (such as C:\Program Files on Windows or /Applications on macOS). If you have installed the browser in a non-standard directory, the channel method may fail, and you will need to use the executablePath property instead.
  2. Initialize Your Project: If you haven't already, set up your Playwright project. Run npm init playwright@latest in your terminal to create the necessary configuration files and folder structure.
  3. Modify the Launch Configuration: In your test script or configuration file, locate the browser launch section. Instead of using the default chromium.launch() without arguments, pass an options object. For Google Chrome, use channel: 'chrome'. For Microsoft Edge, use channel: 'msedge'.
  4. Implement the Code: If you are writing a standalone script, your code should look like this:
    const { chromium } = require('@playwright/test');
    
    (async () => {
      const browser = await chromium.launch({
        channel: 'chrome', // Use 'msedge' for Edge
        headless: false    // Set to true for headless mode
      });
      const page = await browser.newPage();
      await page.goto('https://www.google.com');
      await browser.close();
    })();
        
  5. Configure via playwright.config.ts: For those using the Playwright Test runner, it is more efficient to set the channel globally in the configuration file. Navigate to playwright.config.ts and update the projects array:
    projects: [
      {
        name: 'Google Chrome',
        use: { ...devices['Desktop Chrome'], channel: 'chrome' },
      },
      {
        name: 'Microsoft Edge',
        use: { ...devices['Desktop Edge'], channel: 'msedge' },
      },
    ]
        
  6. Execute the Tests: Run your tests using the command line. If you configured the projects in the config file, you can target a specific browser using npx playwright test --project="Google Chrome".
  7. Verify the User Agent: To confirm that Playwright is indeed using the installed browser and not the generic Chromium build, you can log the user agent string during the test: console.log(await page.evaluate(() => navigator.userAgent));. You should see "Chrome" or "Edg" explicitly mentioned in the string.

Common Mistakes

One of the most frequent errors is confusing channel with executablePath. The channel property is a high-level abstraction that tells Playwright to find the browser using its internal logic for standard installation paths. The executablePath, however, requires a hardcoded absolute path to the .exe or binary file. Using executablePath is brittle because it breaks when the browser updates and changes its version-specific folder path, whereas channel handles these updates automatically.

Another common mistake is attempting to use channel: 'chrome' while launching via firefox.launch() or webkit.launch(). The channel option for Chrome and Edge only works when using the chromium engine. Since Chrome and Edge are both based on the Chromium project, they share the same underlying engine, but they cannot be launched through the Firefox or WebKit drivers.

Users also often forget that using a branded browser may introduce different default settings than the clean-slate Chromium binary. For example, installed browsers may have existing user profiles, cached data, or specific security plugins that can lead to non-deterministic test results if not managed correctly. It is always recommended to use browserContext` to ensure a clean session.

Tips

If you need to test a specific version of Chrome that is not the current stable release (such as Chrome Beta or Chrome Canary), Playwright supports these channels as well. You can use channel: 'chrome-beta' or channel: 'chrome-canary' to stay ahead of the release cycle and catch regressions before they hit the general public.

To speed up execution in CI/CD pipelines, consider whether you actually need the branded browser. The bundled Chromium binary is optimized for automation and typically starts faster. Only use the installed browser if you are testing features unique to Chrome (like specific proprietary codecs) or Edge (like corporate integration features).

When using the installed browser, you can leverage the launchPersistentContext method. This allows you to point Playwright to your actual browser user profile directory. This is incredibly powerful for testing scenarios where the user is already logged into a service, as it eliminates the need to automate the login flow for every single test run.

Troubleshooting

If you receive an error stating that the browser executable could not be found, first verify that the browser is actually installed for the current user. If the browser was installed as a "per-user" application rather than a "per-machine" application, Playwright might struggle to find it in the standard Program Files directory. In this case, try running your terminal as an administrator or check the installation path.

If the browser opens but crashes immediately, check for version mismatches. While Playwright is generally compatible with the latest stable versions of Chrome and Edge, a very recent browser update might occasionally introduce a breaking change in the DevTools Protocol. Ensure your Playwright version is up to date by running npm install @playwright/test@latest.

In cases where channel simply refuses to work despite the browser being installed, you can fall back to executablePath as a temporary diagnostic. Find the path to your browser (e.g., C:\Program Files\Google\Chrome\Application\chrome.exe) and pass it directly. If this works, it confirms that the issue is with Playwright's path-discovery logic rather than the browser installation itself.

If you encounter "SessionNotCreatedError," it usually means the version of the browser installed on your machine is too old or too new for the version of Playwright you are using. The solution is to either update the browser to the latest stable version or update the Playwright library to match the browser's version.

Frequently Asked Questions

Does using the installed browser slow down my tests?

Generally, no. The performance difference between the bundled Chromium and the installed Chrome/Edge is negligible. However, if you use a persistent context with a very large user profile, the initial startup time may increase slightly as the browser loads the profile data.

Can I use this method for headless testing?

Yes. Setting headless: true works perfectly with the channel option. Playwright will launch the installed branded browser in the background without a visible GUI.

Do I still need to run playwright install?

If you are only using the installed Chrome or Edge via the channel option, you do not need to download the Chromium binaries. However, if your test suite also includes Firefox or WebKit tests, you will still need to run npx playwright install firefox webkit.

Will this work on Linux servers?

Yes, provided that the browser is installed on the Linux distribution. You will need to ensure that all necessary system dependencies (libraries) for Chrome or Edge are installed on the server, as the branded installers do not always include every required Linux system library.

Is there a difference between 'chrome' and 'chromium' channels?

Yes. chromium refers to the open-source project and the specific binary Playwright downloads. chrome refers to the official Google Chrome browser, which includes proprietary codecs and Google-specific branding and features.