【问题标题】:How to load Chrome in Puppeteer on Mac?如何在 Mac 上的 Puppeteer 中加载 Chrome?
【发布时间】:2020-09-26 13:52:21
【问题描述】:

为什么我无法在浏览器中加载 Chrome? 我得到错误:

消息是启动浏览器进程失败!产卵 /Applications/GoogleChrome.app ENOENT 疑难解答: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

节点版本 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();

【问题讨论】:

    标签: node.js puppeteer


    【解决方案1】:

    如果要启动已安装 chronium 的 puppeteer,则需要设置 executablePath。所以请检查chronium的确切路径。

    1. 在您的 chrome 中浏览 chrome://version/
    2. 然后,您可以找到executablePath
    3. 确保您编写了正确的路径。

    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();

    【讨论】:

    • 在我最初的问题中,我将 Chrome 应用程序从 Applications 拖放到终端中,然后复制了路径。那么我的路径有什么问题?见截图:imgur.com/ZAojU8V
    猜你喜欢
    • 2012-08-31
    • 2021-10-31
    • 1970-01-01
    • 1970-01-01
    • 2022-08-24
    • 2017-04-24
    • 1970-01-01
    • 2019-08-09
    • 1970-01-01
    相关资源
    最近更新 更多