mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
[api] add Puppeteer.executablePath() method (#771)
This patch adds Puppeteer.executablePath() method to query the path of bundled chromium. Fixes #745
This commit is contained in:
parent
89e923d5f0
commit
d7e673645a
@ -10,6 +10,7 @@
|
||||
* [Environment Variables](#environment-variables)
|
||||
* [class: Puppeteer](#class-puppeteer)
|
||||
+ [puppeteer.connect(options)](#puppeteerconnectoptions)
|
||||
+ [puppeteer.executablePath()](#puppeteerexecutablepath)
|
||||
+ [puppeteer.launch([options])](#puppeteerlaunchoptions)
|
||||
* [class: Browser](#class-browser)
|
||||
+ [browser.close()](#browserclose)
|
||||
@ -174,6 +175,9 @@ puppeteer.launch().then(async browser => {
|
||||
|
||||
This methods attaches Puppeteer to an existing Chromium instance.
|
||||
|
||||
#### puppeteer.executablePath()
|
||||
- returns: <[string]> A path where Puppeteer expects to find bundled Chromium. Chromium might not exist there if the download was skipped with [`PUPPETEER_SKIP_CHROMIUM_DOWNLOAD`](#environment-variables).
|
||||
|
||||
#### puppeteer.launch([options])
|
||||
- `options` <[Object]> Set of configurable options to set on the browser. Can have the following fields:
|
||||
- `ignoreHTTPSErrors` <[boolean]> Whether to ignore HTTPS errors during navigation. Defaults to `false`.
|
||||
|
@ -111,6 +111,14 @@ class Launcher {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
static executablePath() {
|
||||
const revisionInfo = Downloader.revisionInfo(Downloader.currentPlatform(), ChromiumRevision);
|
||||
return revisionInfo.executablePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} options
|
||||
* @return {!Promise<!Browser>}
|
||||
|
@ -32,6 +32,13 @@ class Puppeteer {
|
||||
static connect(options) {
|
||||
return Launcher.connect(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
static executablePath() {
|
||||
return Launcher.executablePath();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Puppeteer;
|
||||
|
@ -133,6 +133,12 @@ describe('Puppeteer', function() {
|
||||
originalBrowser.close();
|
||||
}));
|
||||
});
|
||||
describe('Puppeteer.executablePath', function() {
|
||||
it('should work', SX(async function() {
|
||||
const executablePath = puppeteer.executablePath();
|
||||
expect(fs.existsSync(executablePath)).toBe(true);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user