To run Puppeteer with Firefox instead of Chrome, you can follow these steps:
npm install puppeteer
puppeteer-firefox
package, which enables Puppeteer to work with Firefox. You can install it using the following command:npm install puppeteer-firefox
const puppeteer = require('puppeteer-firefox');
(async () => {
const browser = await puppeteer.launch({
executablePath: '/path/to/firefox-bin',
headless: false // Set to true for headless mode
});
const page = await browser.newPage();
await page.goto('https://example.com');
// Add your Puppeteer code here
await browser.close();
})();
In the puppeteer.launch()
method, you can specify the path to your Firefox binary using the executablePath
option. Make sure to replace /path/to/firefox-bin
with the correct path on your system.
node your-script.js
Your Puppeteer script should now be running with Firefox instead of Chrome.