Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't launch firefox #5376

Closed
meotimdihia opened this issue Feb 3, 2020 · 6 comments
Closed

Can't launch firefox #5376

meotimdihia opened this issue Feb 3, 2020 · 6 comments

Comments

@meotimdihia
Copy link

I tried with 2.1.0 but it doesn't work.

  const browser = await puppeteer.launch({'headless': false, 'product': 'firefox'})

From Puppeteer v2.1.0 onwards, as an experimental feature, you can specify puppeteer.launch({product: 'firefox'}) to run your Puppeteer scripts in Firefox, without any additional custom patches.

@meotimdihia meotimdihia changed the title How to launch firefox Can't launch firefox Feb 3, 2020
@meotimdihia
Copy link
Author

const puppeteer = require('puppeteer');
(async () => {
          const browser = await puppeteer.launch({
                 'headless': false, 'product': 'firefox',
                  'executablePath': "C:\\Program Files\\Mozilla Firefox\\firefox.exe
          });
          const page = await browser.newPage();
})();

(node:23104) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

at onClose (C:\sources\test2\New folder\node_modules\puppeteer\lib\Launcher.js:751:14)
at ChildProcess.<anonymous> (C:\sources\test2\New folder\node_modules\puppeteer\lib\Launcher.js:741:61)
at ChildProcess.emit (events.js:215:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)

(node:23104) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23104) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[Error: EBUSY: resource busy or locked, unlink 'C:\Users\meoti\AppData\Local\Temp\puppeteer_dev_firefox_profile-5ijv8F\key4.db'] {
errno: -4082,
code: 'EBUSY',
syscall: 'unlink',
path: 'C:\Users\meoti\AppData\Local\Temp\puppeteer_dev_firefox_profile-5ijv8F\key4.db'

@lfilho
Copy link

lfilho commented Feb 4, 2020

I also can't launch Firefox. But got different errors:

Using:
Puppeteer 2.1.0
Firefox 72.0.1
Node 13.5.0
MacOS 10.14.16

    const USER_DATA_DIR = `/Users/${CURRENT_USER}/Library/Application\ Support/Firefox/Profiles/my-profile.default`;
    const BROWSER_PATH = '/Applications/Firefox.app/Contents/MacOS/firefox';

    const browser = await puppeteer.launch({
        product: 'firefox',
        headless: false,
        args: [`-profile "${USER_DATA_DIR}"`],
        // executablePath: BROWSER_PATH
    });

    const page = await browser.newPage();

Error 1

If I leave the executablePath commented out as above, it actually opens Chromium (!!).

Error 2

If I leave the executablePath line not commented out, then it opens Firefox, I briefly see the tab getting created, but then it immediately fails with:

Error: Protocol error (Page.setInterceptFileChooserDialog): Page.setInterceptFileChooserDialog RemoteAgentError@chrome://remote/content/Error.jsm:25:5
UnknownMethodError@chrome://remote/content/Error.jsm:108:7
execute@chrome://remote/content/domains/Domains.jsm:96:13
receiveMessage@chrome://remote/content/sessions/ContentProcessSession.jsm:69:45

    at <my-project-path>/node_modules/puppeteer/lib/Connection.js:183:56
    at new Promise (<anonymous>)
    at CDPSession.send (<my-project-path>/node_modules/puppeteer/lib/Connection.js:182:12)
    at Page._initialize (<my-project-path>/node_modules/puppeteer/lib/Page.js:138:20)
    at Function.create (<my-project-path>/node_modules/puppeteer/lib/Page.js:47:16)
    at <my-project-path>/node_modules/puppeteer/lib/Target.js:74:32
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Browser._createPageInContext (<my-project-path>/node_modules/puppeteer/lib/Browser.js:177:18)
    at async file://<my-project-path>/myPuppeteerScript:68:22
  -- ASYNC --
    at Target.<anonymous> (<my-project-path>/node_modules/puppeteer/lib/helper.js:111:15)
    at Browser._createPageInContext (<my-project-path>/node_modules/puppeteer/lib/Browser.js:177:31)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async file://<my-project-path>/myPuppeteerScript:68:22
  -- ASYNC --
    at Browser.<anonymous> (<my-project-path>/node_modules/puppeteer/lib/helper.js:111:15)
    at file://<my-project-path>/myPuppeteerScript:68:36
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  message: 'Protocol error (Page.setInterceptFileChooserDialog): Page.setInterceptFileChooserDialog RemoteAgentError@chrome://remote/content/Error.jsm:25:5\n' +
    'UnknownMethodError@chrome://remote/content/Error.jsm:108:7\n' +
    'execute@chrome://remote/content/domains/Domains.jsm:96:13\n' +
    'receiveMessage@chrome://remote/content/sessions/ContentProcessSession.jsm:69:45\n'
}

Note the chrome:// protocol stuff.

@mjzffr
Copy link
Contributor

mjzffr commented Feb 4, 2020

Thanks for trying this out. You need to be using Firefox Nightly (74); and yes, the executablePath option is required for now.

@mjzffr mjzffr closed this as completed Feb 4, 2020
@meotimdihia
Copy link
Author

meotimdihia commented Feb 5, 2020

@mjzffr : I can do it now. Tried to page.screenshot() and page.$x does work too.
But goto return null instead of Response object.

@Sue9445
Copy link

Sue9445 commented Feb 11, 2020

const puppeteer = require('puppeteer');
(async () => {
          const browser = await puppeteer.launch({
                 'headless': false, 'product': 'firefox',
                  'executablePath': "C:\\Program Files\\Mozilla Firefox\\firefox.exe
          });
          const page = await browser.newPage();
})();

(node:23104) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

at onClose (C:\sources\test2\New folder\node_modules\puppeteer\lib\Launcher.js:751:14)
at ChildProcess.<anonymous> (C:\sources\test2\New folder\node_modules\puppeteer\lib\Launcher.js:741:61)
at ChildProcess.emit (events.js:215:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)

(node:23104) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23104) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[Error: EBUSY: resource busy or locked, unlink 'C:\Users\meoti\AppData\Local\Temp\puppeteer_dev_firefox_profile-5ijv8F\key4.db'] {
errno: -4082,
code: 'EBUSY',
syscall: 'unlink',
path: 'C:\Users\meoti\AppData\Local\Temp\puppeteer_dev_firefox_profile-5ijv8F\key4.db'

I solved this error by adding the "-wait-for-browser" arg.

@mjzffr
Copy link
Contributor

mjzffr commented Jun 11, 2020

wait-for-browser is a Firefox argument relevant to Windows. This might relevant to #5673

In the meantime, you can include wait-for-browser in the args option of Puppeteer.launch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants