Browser
Extends:
Static Method Summary
Static Public Methods | ||
public static |
async connect(browserWSEndpoint: string, initOpts: BrowserInitOptions): Browser |
|
public static |
async create(connection: Chrome | CRIConnection | Object, initOpts: BrowserInitOptions): Browser |
Constructor Summary
Public Constructor | ||
public |
constructor(connection: Chrome | CRIConnection, initOpts: BrowserInitOptions) |
Member Summary
Private Members | ||
private |
|
|
private |
_closeCallback: * | dummyCloseCB |
|
private |
_connection: Chrome | CRIConnection |
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
Method Summary
Public Methods | ||
public |
Returns an array of all open browser contexts. |
|
public |
Closes all of its pages (if any were opened) and the Browser object itself is considered to be disposed and cannot be used anymore |
|
public |
closeTarget(targetId: string, throwOnError: boolean): Promise<boolean> Closes the target specified by the targetId. |
since chrome-remote-interface-extra |
public |
Creates a new incognito browser context. |
|
public |
Returns the default browser context. |
|
public |
Disconnect from the browser After calling disconnect, the Browser object is considered disposed and cannot be used anymore |
|
public |
getHistogram(name: string, delta: boolean): Promise<CDPHistogram> Get a Chrome histogram by name. |
since chrome-remote-interface-extra |
public |
getHistograms(options: BrowserHistogramQuery): Promise<Array<CDPHistogram>> Get Chrome histograms. |
since chrome-remote-interface-extra |
public |
getTargetById(targetId: string): Target Returns the target associated with the supplied target id if we know about it |
since chrome-remote-interface-extra |
public |
getWindowBounds(windowId: number): Promise<WindowBounds> Get position and size of the browser window. |
since chrome-remote-interface-extra |
public |
getWindowForTarget(targetId: string): Promise<{bounds: WindowBounds, windowId: number}>{bounds:> Get the browser window that contains the target. |
since chrome-remote-interface-extra |
public |
async grantPermissions(origin: string, permissions: Array<string>, browserContextId: string): Promise<void> Grant specific permissions to the given origin and reject all others. |
|
public |
async listBrowserContexts(): Promise<Array<string>> Returns all browser contexts created with Target.createBrowserContext method. |
since chrome-remote-interface-extra |
public |
async listTargets(): Promise<Array<CDPTargetInfo>> Retrieves a list of available targets |
since chrome-remote-interface-extra |
public |
Promise which resolves to a new Page object. |
|
public |
An array of all pages inside the Browser. |
|
public |
|
|
public |
async resetPermissions(browserContextId: string): Promise<void> Reset all permission management for all origins. |
|
public |
async setWindowBounds(windowId: number, bounds: WindowBounds): Promise<void> Set position and/or size of the browser window. |
since chrome-remote-interface-extra |
public |
Returns the target associated with the browser |
|
public |
Returns all known targets |
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
versionInfo(): Promise<{protocolversion: string, product: string, revision: string, userAgent: string, jsVersion: string}>{protocolversion:> Returns version information |
since chrome-remote-interface-extra |
public |
async waitForTarget(predicate: function(target: Target): boolean, options: {timeout?: number}): Promise<Target> This searches for a target in all browser contexts |
|
public |
wsEndpoint(): string |
Private Methods | ||
private |
async _createPageInContext(contextId: string): Promise<Page> |
|
private |
async _disposeContext(contextId: string) |
|
private |
async _targetCreated(event: Object) |
|
private |
async _targetDestroyed(event: {targetId: string}) |
|
private |
_targetInfoChanged(event: Object) |
Static Public Methods
public static async connect(browserWSEndpoint: string, initOpts: BrowserInitOptions): Browser source
Params:
Name | Type | Attribute | Description |
browserWSEndpoint | string | ||
initOpts | BrowserInitOptions |
|
public static async create(connection: Chrome | CRIConnection | Object, initOpts: BrowserInitOptions): Browser source
Params:
Name | Type | Attribute | Description |
connection | Chrome | CRIConnection | Object | ||
initOpts | BrowserInitOptions |
|
Public Constructors
public constructor(connection: Chrome | CRIConnection, initOpts: BrowserInitOptions) source
Params:
Name | Type | Attribute | Description |
connection | Chrome | CRIConnection |
|
|
initOpts | BrowserInitOptions |
Private Members
private _additionalDomains: EnabledExtras source
private _closeCallback: * | dummyCloseCB source
private _connection: Chrome | CRIConnection source
private _contexts: Map<string, BrowserContext> source
private _defaultContext: BrowserContext source
Public Methods
public browserContexts(): Array<BrowserContext> source
Returns an array of all open browser contexts. In a newly created browser, this will return a single instance of BrowserContext
public async close(): Promise<void> source
Closes all of its pages (if any were opened) and the Browser object itself is considered to be disposed and cannot be used anymore
public closeTarget(targetId: string, throwOnError: boolean): Promise<boolean> since chrome-remote-interface-extra source
Closes the target specified by the targetId. If the target is a page that gets closed too. Returns T/F to indicate if the command was successful
public async createIncognitoBrowserContext(): Promise<BrowserContext> source
Creates a new incognito browser context. This won't share cookies/cache with other browser contexts
public defaultBrowserContext(): BrowserContext source
Returns the default browser context. The default browser context can not be closed
public disconnect() source
Disconnect from the browser After calling disconnect, the Browser object is considered disposed and cannot be used anymore
public getHistogram(name: string, delta: boolean): Promise<CDPHistogram> since chrome-remote-interface-extra source
Get a Chrome histogram by name. EXPERIMENTAL
public getHistograms(options: BrowserHistogramQuery): Promise<Array<CDPHistogram>> since chrome-remote-interface-extra source
Get Chrome histograms. EXPERIMENTAL Optional options:
- query: Requested substring in name. Only histograms which have query as a substring in their name are extracted. An empty or absent query returns all histograms.
- delta: If true, retrieve delta since last call
Params:
Name | Type | Attribute | Description |
options | BrowserHistogramQuery |
|
public getTargetById(targetId: string): Target since chrome-remote-interface-extra source
Returns the target associated with the supplied target id if we know about it
Params:
Name | Type | Attribute | Description |
targetId | string |
public getWindowBounds(windowId: number): Promise<WindowBounds> since chrome-remote-interface-extra source
Get position and size of the browser window. EXPERIMENTAL
Params:
Name | Type | Attribute | Description |
windowId | number |
public getWindowForTarget(targetId: string): Promise<{bounds: WindowBounds, windowId: number}>{bounds:> since chrome-remote-interface-extra source
Get the browser window that contains the target. EXPERIMENTAL
Params:
Name | Type | Attribute | Description |
targetId | string |
|
Optional target id of the target to receive the window id and its bound for. If called as a part of the session, associated targetId is used. |
public async grantPermissions(origin: string, permissions: Array<string>, browserContextId: string): Promise<void> source
Grant specific permissions to the given origin and reject all others. EXPERIMENTAL
public async listBrowserContexts(): Promise<Array<string>> since chrome-remote-interface-extra source
Returns all browser contexts created with Target.createBrowserContext method. EXPERIMENTAL
public async listTargets(): Promise<Array<CDPTargetInfo>> since chrome-remote-interface-extra source
Retrieves a list of available targets
public async pages(): Promise<Array<Page>> source
An array of all pages inside the Browser. In case of multiple browser contexts, the method will return an array with all the pages in all browser contexts
public async resetPermissions(browserContextId: string): Promise<void> source
Reset all permission management for all origins. EXPERIMENTAL
Params:
Name | Type | Attribute | Description |
browserContextId | string |
|
BrowserContext to reset permissions. When omitted, default browser context is used. |
public async setWindowBounds(windowId: number, bounds: WindowBounds): Promise<void> since chrome-remote-interface-extra source
Set position and/or size of the browser window. EXPERIMENTAL
Params:
Name | Type | Attribute | Description |
windowId | number | An browser window id |
|
bounds | WindowBounds | New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged. |
public versionInfo(): Promise<{protocolversion: string, product: string, revision: string, userAgent: string, jsVersion: string}>{protocolversion:> since chrome-remote-interface-extra source
Returns version information
public async waitForTarget(predicate: function(target: Target): boolean, options: {timeout?: number}): Promise<Target> source
This searches for a target in all browser contexts
Example:
// finding a target for a page opened via window.open
await page.evaluate(() => window.open('https://www.example.com/'))
const newWindowTarget = await browser.waitForTarget(target => target.url() === 'https://www.example.com/')
Private Methods
private async _createPageInContext(contextId: string): Promise<Page> source
Params:
Name | Type | Attribute | Description |
contextId | string |
|
private async _disposeContext(contextId: string) source
Params:
Name | Type | Attribute | Description |
contextId | string |
|
private async _targetCreated(event: Object) source
Params:
Name | Type | Attribute | Description |
event | Object |
|