Introduce Puppeteer.connect method (#264)

This patch:
- refactors Connection to use a single remote debugging URL instead of a
  pair of port and browserTargetId
- introduces Puppeteer.connect() method to attach to already running
  browser instance.

Fixes #238.
This commit is contained in:
Andrey Lushnikov
2017-08-15 14:29:42 -07:00
committed by GitHub
parent 96309a207c
commit a424f5613a
8 changed files with 82 additions and 29 deletions

View File

@@ -104,6 +104,15 @@ describe('Browser', function() {
await neverResolves;
expect(error.message).toContain('Protocol error');
}));
it('Puppeteer.connect', SX(async function() {
let originalBrowser = await puppeteer.launch(defaultBrowserOptions);
let browser = await puppeteer.connect({
remoteDebuggingURL: originalBrowser.remoteDebuggingURL()
});
let page = await browser.newPage();
expect(await page.evaluate(() => 7 * 8)).toBe(56);
originalBrowser.close();
}));
});
describe('Page', function() {