Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update preferred revision after Launcher is created (#5640)
Fixes an edge case where Puppeteer looked for a Chromium revision when launching Firefox. Allow appropriate Launcher to be instantiated when calling `Puppeteer.connect`. Add an example of running Firefox.
- Loading branch information
Showing
3 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const puppeteer = require('puppeteer'); | ||
|
||
/** | ||
* To have Puppeteer fetch a Firefox binary for you, first run: | ||
* | ||
* PUPPETEER_PRODUCT=firefox npm install | ||
* | ||
* To get additional logging about which browser binary is executed, | ||
* run this example as: | ||
* | ||
* DEBUG=puppeteer:launcher NODE_PATH=../ node examples/cross-browser.js | ||
* | ||
* You can set a custom binary with the `executablePath` launcher option. | ||
* | ||
* | ||
*/ | ||
|
||
const firefoxOptions = { | ||
product: 'firefox', | ||
extraPrefsFirefox: { | ||
// Enable additional Firefox logging from its protocol implementation | ||
// 'remote.log.level': 'Trace', | ||
}, | ||
// Make browser logs visible | ||
dumpio: true, | ||
}; | ||
|
||
(async() => { | ||
const browser = await puppeteer.launch(firefoxOptions); | ||
|
||
const page = await browser.newPage(); | ||
console.log(await browser.version()); | ||
|
||
await page.goto('https://news.ycombinator.com/'); | ||
|
||
// Extract articles from the page. | ||
const resultsSelector = '.storylink'; | ||
const links = await page.evaluate(resultsSelector => { | ||
const anchors = Array.from(document.querySelectorAll(resultsSelector)); | ||
return anchors.map(anchor => { | ||
const title = anchor.textContent.trim(); | ||
return `${title} - ${anchor.href}`; | ||
}); | ||
}, resultsSelector); | ||
console.log(links.join('\n')); | ||
|
||
await browser.close(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters