Home  Puppeteer   Which brows ...

which browser puppeteer opens by default

If both Google Chrome and Microsoft Edge (Chromium-based) are installed on your system, Puppeteer will typically open the Chrome browser by default unless you specify a different executable path for Edge. Here’s how it works:

  1. Default Behavior: Puppeteer uses a default Chromium executable that it can find in the system’s default installation paths. If both Chrome and Edge Chromium are installed, Puppeteer will likely prioritize Chrome unless you specifically configure it otherwise.

  2. Specifying Executable Path: You can explicitly tell Puppeteer to use a specific browser executable path by setting the executablePath option when launching Puppeteer:

    const puppeteer = require('puppeteer');
    
    (async () => {
      const browser = await puppeteer.launch({
        executablePath: '/path/to/edge/executable',
        // other options
      });
    
      // Further actions with `browser` and `page`
    
      await browser.close();
    })();
    

    Replace /path/to/edge/executable with the actual path to the Microsoft Edge Chromium executable on your system.

  3. Environment Variables: Puppeteer also respects environment variables that specify the browser executable path. For example, setting the PUPPETEER_EXECUTABLE_PATH environment variable to the path of the Edge Chromium executable will make Puppeteer use Edge instead of Chrome.

Published on: Jun 27, 2024, 11:28 PM  
 

Comments

Add your comment