forked from puppeteer/puppeteer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(agnostification): split up root Puppeteer class (puppeteer#6504)
The `Puppeteer` class had two concerns: * connect to an existing browser * launch a new browser The first of those concerns is needed in all environments, but the second is only needed in Node. puppeteer#6484 landing enabled us to pull the `Puppeteer` class apart into two: 1. `Puppeteer` which hosts the behaviour for connecting to existing browsers. 2. `PuppeteerNode`, which extends `Puppeteer` and also adds the ability to launch a new browser. This is a non-breaking change, because Node users will still get an instance of a class with all the methods they expect, but it'll be a `PuppeteerNode` rather than `Puppeteer`. I don't expect this to cause people any issues. We also now have new files that are effectively the entry points for Puppeteer: * `node.ts`: the main entry point for Puppeteer on Node. * `web.ts`: the main entry point for Puppeteer on the web. * `node-puppeteer-core.ts`: for those using puppeteer-core (which only exists in Node, not on the web).
- Loading branch information
1 parent
f3086d7
commit e655bb6
Showing
36 changed files
with
549 additions
and
281 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
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,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ConnectOptions](./puppeteer.connectoptions.md) > [browserURL](./puppeteer.connectoptions.browserurl.md) | ||
|
||
## ConnectOptions.browserURL property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
browserURL?: string; | ||
``` |
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,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ConnectOptions](./puppeteer.connectoptions.md) > [browserWSEndpoint](./puppeteer.connectoptions.browserwsendpoint.md) | ||
|
||
## ConnectOptions.browserWSEndpoint property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
browserWSEndpoint?: string; | ||
``` |
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,22 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ConnectOptions](./puppeteer.connectoptions.md) | ||
|
||
## ConnectOptions interface | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export interface ConnectOptions extends BrowserOptions | ||
``` | ||
<b>Extends:</b> [BrowserOptions](./puppeteer.browseroptions.md) | ||
## Properties | ||
| Property | Type | Description | | ||
| --- | --- | --- | | ||
| [browserURL](./puppeteer.connectoptions.browserurl.md) | string | | | ||
| [browserWSEndpoint](./puppeteer.connectoptions.browserwsendpoint.md) | string | | | ||
| [product](./puppeteer.connectoptions.product.md) | [Product](./puppeteer.product.md) | | | ||
| [transport](./puppeteer.connectoptions.transport.md) | ConnectionTransport | | | ||
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,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ConnectOptions](./puppeteer.connectoptions.md) > [product](./puppeteer.connectoptions.product.md) | ||
|
||
## ConnectOptions.product property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
product?: Product; | ||
``` |
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,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [ConnectOptions](./puppeteer.connectoptions.md) > [transport](./puppeteer.connectoptions.transport.md) | ||
|
||
## ConnectOptions.transport property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
transport?: ConnectionTransport; | ||
``` |
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,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [Puppeteer](./puppeteer.puppeteer.md) > [\_changedProduct](./puppeteer.puppeteer._changedproduct.md) | ||
|
||
## Puppeteer.\_changedProduct property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
protected _changedProduct: boolean; | ||
``` |
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,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [Puppeteer](./puppeteer.puppeteer.md) > [\_isPuppeteerCore](./puppeteer.puppeteer._ispuppeteercore.md) | ||
|
||
## Puppeteer.\_isPuppeteerCore property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
protected _isPuppeteerCore: boolean; | ||
``` |
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
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,29 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [PuppeteerNode](./puppeteer.puppeteernode.md) > [connect](./puppeteer.puppeteernode.connect.md) | ||
|
||
## PuppeteerNode.connect() method | ||
|
||
This method attaches Puppeteer to an existing browser instance. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
connect(options: ConnectOptions): Promise<Browser>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| options | [ConnectOptions](./puppeteer.connectoptions.md) | Set of configurable options to set on the browser. | | ||
|
||
<b>Returns:</b> | ||
|
||
Promise<[Browser](./puppeteer.browser.md)<!-- -->> | ||
|
||
Promise which resolves to browser instance. | ||
|
||
## Remarks | ||
|
||
|
4 changes: 2 additions & 2 deletions
4
...ppeteer.puppeteer.createbrowserfetcher.md → ...eer.puppeteernode.createbrowserfetcher.md
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
4 changes: 2 additions & 2 deletions
4
new-docs/puppeteer.puppeteer.defaultargs.md → ...cs/puppeteer.puppeteernode.defaultargs.md
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
4 changes: 2 additions & 2 deletions
4
...ocs/puppeteer.puppeteer.executablepath.md → ...puppeteer.puppeteernode.executablepath.md
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
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,59 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [puppeteer](./puppeteer.md) > [PuppeteerNode](./puppeteer.puppeteernode.md) | ||
|
||
## PuppeteerNode class | ||
|
||
Extends the main [Puppeteer](./puppeteer.puppeteer.md) class with Node specific behaviour for fetching and downloading browsers. | ||
|
||
If you're using Puppeteer in a Node environment, this is the class you'll get when you run `require('puppeteer')` (or the equivalent ES `import`<!-- -->). | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare class PuppeteerNode extends Puppeteer | ||
``` | ||
<b>Extends:</b> [Puppeteer](./puppeteer.puppeteer.md) | ||
## Remarks | ||
The most common method to use is [launch](./puppeteer.puppeteernode.launch.md)<!-- -->, which is used to launch and connect to a new browser instance. | ||
See [the main Puppeteer class](./puppeteer.puppeteer.md) for methods common to all environments, such as [Puppeteer.connect()](./puppeteer.puppeteer.connect.md)<!-- -->. | ||
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `PuppeteerNode` class. | ||
## Example | ||
The following is a typical example of using Puppeteer to drive automation: | ||
```js | ||
const puppeteer = require('puppeteer'); | ||
|
||
(async () => { | ||
const browser = await puppeteer.launch(); | ||
const page = await browser.newPage(); | ||
await page.goto('https://www.google.com'); | ||
// other actions... | ||
await browser.close(); | ||
})(); | ||
|
||
``` | ||
Once you have created a `page` you have access to a large API to interact with the page, navigate, or find certain elements in that page. The [\`page\` documentation](./puppeteer.page.md) lists all the available methods. | ||
## Properties | ||
| Property | Modifiers | Type | Description | | ||
| --- | --- | --- | --- | | ||
| [product](./puppeteer.puppeteernode.product.md) | | string | The name of the browser that is under automation (<code>"chrome"</code> or <code>"firefox"</code>) | | ||
## Methods | ||
| Method | Modifiers | Description | | ||
| --- | --- | --- | | ||
| [connect(options)](./puppeteer.puppeteernode.connect.md) | | This method attaches Puppeteer to an existing browser instance. | | ||
| [createBrowserFetcher(options)](./puppeteer.puppeteernode.createbrowserfetcher.md) | | | | ||
| [defaultArgs(options)](./puppeteer.puppeteernode.defaultargs.md) | | | | ||
| [executablePath()](./puppeteer.puppeteernode.executablepath.md) | | | | ||
| [launch(options)](./puppeteer.puppeteernode.launch.md) | | Launches puppeteer and launches a browser instance with given arguments and options when specified. | | ||
4 changes: 2 additions & 2 deletions
4
new-docs/puppeteer.puppeteer.product.md → new-docs/puppeteer.puppeteernode.product.md
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
Oops, something went wrong.