mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Rename 'remoteDebuggingURL' into 'browserWSEndpoint' (#272)
This commit is contained in:
parent
44c15220f9
commit
0a190ebec9
17
docs/api.md
17
docs/api.md
@ -11,8 +11,8 @@
|
||||
* [class: Browser](#class-browser)
|
||||
+ [browser.close()](#browserclose)
|
||||
+ [browser.newPage()](#browsernewpage)
|
||||
+ [browser.remoteDebuggingURL()](#browserremotedebuggingurl)
|
||||
+ [browser.version()](#browserversion)
|
||||
+ [browser.wsEndpoint()](#browserwsendpoint)
|
||||
* [class: Page](#class-page)
|
||||
+ [event: 'console'](#event-console)
|
||||
+ [event: 'dialog'](#event-dialog)
|
||||
@ -143,7 +143,7 @@ puppeteer.launch().then(async browser => {
|
||||
|
||||
#### puppeteer.connect(options)
|
||||
- `options` <[Object]>
|
||||
- `remoteDebuggingURL` <[string]> a [remote debugging URL](#browserremotedebuggingurl) to connect to.
|
||||
- `browserWSEndpoint` <[string]> a [browser websocket endpoint](#browserwsendpoint) to connect to.
|
||||
- `ignoreHTTPSErrors` <[boolean]> Whether to ignore HTTPS errors during navigation. Defaults to `false`.
|
||||
- returns: <[Promise]<[Browser]>>
|
||||
|
||||
@ -185,16 +185,17 @@ Closes browser with all the pages (if any were opened). The browser object itsel
|
||||
#### browser.newPage()
|
||||
- returns: <[Promise]<[Page]>> Promise which resolves to a new [Page] object.
|
||||
|
||||
#### browser.remoteDebuggingURL()
|
||||
- returns: <[string]> A URL for debugging this browser instance.
|
||||
|
||||
Remote debugging url is as an argument to the [puppeteer.connect](#puppeteerconnect).
|
||||
|
||||
#### browser.version()
|
||||
- returns: <[Promise]<[string]>> For headless Chromium, this is similar to `HeadlessChrome/61.0.3153.0`. For non-headless, this is similar to `Chrome/61.0.3153.0`.
|
||||
|
||||
> **NOTE** the format of browser.version() might change with future releases of Chromium.
|
||||
|
||||
#### browser.wsEndpoint()
|
||||
- returns: <[string]> Browser websocket url.
|
||||
|
||||
Browser websocket endpoint which could be used as an argument to
|
||||
[puppeteer.connect](#puppeteerconnect).
|
||||
|
||||
### class: Page
|
||||
|
||||
Page provides methods to interact with a single tab in Chromium. One [Browser] instance might have multiple [Page] instances.
|
||||
@ -1240,4 +1241,4 @@ Contains the URL of the response.
|
||||
[selector]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors "selector"
|
||||
[Tracing]: #class-tracing "Tracing"
|
||||
[ElementHandle]: #class-element "ElementHandle"
|
||||
[UIEvent.detail]: https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail "UIEvent.detail"
|
||||
[UIEvent.detail]: https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail "UIEvent.detail"
|
||||
|
@ -33,7 +33,7 @@ class Browser {
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
remoteDebuggingURL() {
|
||||
wsEndpoint() {
|
||||
return this._connection.url();
|
||||
}
|
||||
|
||||
|
@ -87,17 +87,17 @@ class Launcher {
|
||||
removeRecursive(userDataDir);
|
||||
});
|
||||
|
||||
let remoteDebuggingURL = await waitForRemoteDebuggingURL(chromeProcess);
|
||||
let browserWSEndpoint = await waitForWSEndpoint(chromeProcess);
|
||||
if (terminated)
|
||||
throw new Error('Failed to launch chrome! ' + stderr);
|
||||
// Failed to connect to browser.
|
||||
if (!remoteDebuggingURL) {
|
||||
if (!browserWSEndpoint) {
|
||||
chromeProcess.kill();
|
||||
throw new Error('Failed to connect to chrome!');
|
||||
}
|
||||
|
||||
let connectionDelay = options.slowMo || 0;
|
||||
let connection = await Connection.create(remoteDebuggingURL, connectionDelay);
|
||||
let connection = await Connection.create(browserWSEndpoint, connectionDelay);
|
||||
return new Browser(connection, !!options.ignoreHTTPSErrors, () => chromeProcess.kill());
|
||||
}
|
||||
|
||||
@ -105,8 +105,8 @@ class Launcher {
|
||||
* @param {string} options
|
||||
* @return {!Promise<!Browser>}
|
||||
*/
|
||||
static async connect({remoteDebuggingURL, ignoreHTTPSErrors = false}) {
|
||||
let connection = await Connection.create(remoteDebuggingURL);
|
||||
static async connect({browserWSEndpoint, ignoreHTTPSErrors = false}) {
|
||||
let connection = await Connection.create(browserWSEndpoint);
|
||||
return new Browser(connection, !!ignoreHTTPSErrors);
|
||||
}
|
||||
}
|
||||
@ -115,7 +115,7 @@ class Launcher {
|
||||
* @param {!ChildProcess} chromeProcess
|
||||
* @return {!Promise<string>}
|
||||
*/
|
||||
function waitForRemoteDebuggingURL(chromeProcess) {
|
||||
function waitForWSEndpoint(chromeProcess) {
|
||||
return new Promise(fulfill => {
|
||||
const rl = readline.createInterface({ input: chromeProcess.stderr });
|
||||
rl.on('line', onLine);
|
||||
|
@ -107,7 +107,7 @@ describe('Browser', function() {
|
||||
it('Puppeteer.connect', SX(async function() {
|
||||
let originalBrowser = await puppeteer.launch(defaultBrowserOptions);
|
||||
let browser = await puppeteer.connect({
|
||||
remoteDebuggingURL: originalBrowser.remoteDebuggingURL()
|
||||
browserWSEndpoint: originalBrowser.wsEndpoint()
|
||||
});
|
||||
let page = await browser.newPage();
|
||||
expect(await page.evaluate(() => 7 * 8)).toBe(56);
|
||||
|
Loading…
Reference in New Issue
Block a user