Using Puppeteer with existing Chrome installation and custom window dimensions

I’m having trouble with two specific Puppeteer issues on my Mac and could really use some guidance.

First problem: I want to use Puppeteer with the Chrome browser that’s already installed on my system instead of the bundled Chromium. When I try to specify the path to my existing Chrome installation, the script fails to execute properly.

Second problem: I need to launch Chrome with a specific window size (not just viewport). I’ve attempted using various command line arguments but haven’t found the right approach yet.

Here’s my current attempt:

const puppeteer = require('puppeteer');

(async() => {
    const browserInstance = await puppeteer.launch({
        headless: false,
        executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
        args: ["--window-size=1920,1080"]
    });
    
    const newPage = await browserInstance.newPage();
    await newPage.goto('http://localhost:3000/dashboard', {
        waitUntil: 'networkidle0'
    });
    
    await newPage.screenshot({path: './output/test-screenshot.png'});
    
    // await browserInstance.close();
})();

Any suggestions on how to resolve these issues would be greatly appreciated!

I experienced similar challenges when using Puppeteer with the system-installed Chrome on macOS. Your executable path appears to be correct, but ensure there are no permission issues and that Chrome isn’t already open while running your script to avoid conflicts.

For setting the window size, consider adding --window-size=1920,1080 in conjunction with other flags like --disable-web-security and --no-first-run. Including --start-maximized can help maintain the desired window size; just note it may override your specified dimensions.

Additionally, introducing a brief delay after launching the browser can allow sufficient time for Chrome to initialize before you create a new page. I’ve found it more effective to use puppeteer.launch({channel: 'chrome'}) instead of providing a direct path—this method tends to be more reliable.

I’ve had this exact setup running on my MacBook Pro for months. Your path looks right, but you need to handle viewport separately from window size. After creating the page, add await newPage.setViewport({width: 1920, height: 1080}); to control rendering dimensions.

For the Chrome executable issue, try adding --no-sandbox and --disable-setuid-sandbox to your args array. These flags usually fix permission conflicts that stop system Chrome from launching through Puppeteer.

Also check if you’ve got multiple Chrome installations - stable sometimes conflicts with Beta or Canary builds. Running which google-chrome-stable in terminal helped me verify the exact path Puppeteer expects, though your current path should work fine for standard installs.

Switch to puppeteer-core instead of regular puppeteer if you’re using an existing Chrome install - it doesn’t bundle Chromium so it plays nicer with system browsers. And kill all Chrome processes before running your script. Even background Chrome stuff can mess things up on Mac.