bibscy
bibscy

Reputation: 2708

How to load Chrome in Puppeteer on Mac?

Why can I not load Chrome in the browser? I get error:

The message is Failed to launch the browser process! spawn /Applications/GoogleChrome.app ENOENT TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

Node version v13.12.0

 const browser = await puppeteer.launch({executablePath:'/Applications/Google\Chrome.app'});
 const page = await browser.newPage();
 await page.goto('https://my.gumtree.com/login', {waitUntil: 'networkidle2'});
 const myButton = await page.$('#google-sign-in-button');
 myButton.click();

enter image description here

Upvotes: 4

Views: 4161

Answers (2)

zulucoda
zulucoda

Reputation: 868

A more straightforward solution:

const browser = await puppeteer.launch({executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'});


executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'

Hope that helps

Upvotes: 1

hadoobidoop
hadoobidoop

Reputation: 85

If you want to launch puppeteer with already installed chronium, you need to set executablePath. So please check the exact path of chronium.

  1. browse chrome://version/ in your chrome.
  2. then, you can find executablePath.
  3. Make sure you wrote the correct path.

const browser = await puppeteer.launch({executablePath:'your executable Path'});
const page = await browser.newPage();
await page.goto('https://my.gumtree.com/login', {waitUntil: 'networkidle2'});
const myButton = await page.$('#google-sign-in-button');
myButton.click();

Upvotes: 7

Related Questions