import NetworkManager from 'chrome-remote-interface-extra/lib/network/NetworkManager.js'
NetworkManager
Extends:
Constructor Summary
Public Constructor | ||
public |
constructor(client: Chrome | CRIConnection | CDPSession | Object, timeoutSettings: TimeoutSettings) |
Member Summary
Private Members | ||
private |
|
|
private |
|
|
private |
_client: Chrome | CRIConnection | CDPSession | Object |
|
private |
_credentials: {username: string, password: string} |
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
|
private |
|
Method Summary
Public Methods | ||
public |
async authenticate(credentials: {username: string, password: string}) |
|
public |
async bypassServiceWorker(bypass: boolean): Promise<void> Toggles ignoring of service worker for each request. |
since chrome-remote-interface-extra |
public |
async clearBrowserCache(): Promise<void> |
since chrome-remote-interface-extra |
public |
async clearBrowserCookies(): Promise<void> Clears browser cookies |
since chrome-remote-interface-extra |
public |
async deleteCookie(cookie: CDPCookie | CookieToBeDeleted | string | Cookie, forURL: string): Promise<void> Deletes the specified browser cookies with matching name and url or domain/path pair. |
since chrome-remote-interface-extra |
public |
async deleteCookies(cookies: ...(CDPCookie|CookieToBeDeleted|string|Cookie)): Promise<void> Deletes browser cookies with matching name and url or domain/path pair. |
since chrome-remote-interface-extra |
public |
async disableCache(): Promise<void> |
since chrome-remote-interface-extra |
public |
async emulateNetworkConditions(networkConditions: NetworkConditions): Promise<void> Activates emulation of network conditions |
since chrome-remote-interface-extra |
public |
async enableCache(): Promise<void> |
since chrome-remote-interface-extra |
public |
|
|
public |
async getAllCookies(): Promise<Array<Cookie>> Returns all browser cookies. |
since chrome-remote-interface-extra |
public |
async getCertificate(origin: string): Promise<Array<string>> Returns the DER-encoded certificate. |
since chrome-remote-interface-extra |
public |
Returns all browser cookies for the current URL. |
since chrome-remote-interface-extra |
public |
networkIdlePromise(options: NetIdleOptions): Promise<void> Returns a promise that resolves once the network has become idle. |
since chrome-remote-interface-extra |
public |
async setAcceptLanguage(acceptLanguage: string) |
since chrome-remote-interface-extra |
public |
async setBlockedURLs(urls: ...string): Promise<void> Blocks URLs from loading. |
since chrome-remote-interface-extra |
public |
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist |
since chrome-remote-interface-extra |
public |
async setCookies(cookies: ...(CDPCookie|CookieParam|string)): Promise<void> Sets given cookies |
since chrome-remote-interface-extra |
public |
async setExtraHTTPHeaders(extraHTTPHeaders: Object<string, string>) |
|
public |
setFrameManager(frameManager: FrameManager) |
|
public |
async setNavigatorPlatform(platform: string) |
since chrome-remote-interface-extra |
public |
async setOfflineMode(offline: boolean) |
|
public |
async setRequestInterception(value: boolean) |
|
public |
setTimeoutSettings(toSettings: TimeoutSettings) |
since chrome-remote-interface-extra |
public |
async setUserAgent(userAgent: string) |
|
public |
async setUserAgentOverride(overrides: UserAgentOverride): Promise<void> Allows overriding user agent with the given string. |
|
public |
toJSON(): {"extraHTTPHeaders": *, "ignoreHTTPSErrors": *, "defaultViewport": *, "offline": *, "cacheEnabledState": *, "credentials": *, "userRequestInterceptionEnabled": *, "protocolRequestInterceptionEnabled": *} |
|
public |
|
|
public |
|
Private Methods | ||
private |
_handleRequestRedirect(request: Request, event: Object) |
|
private |
_onLoadingFailed(event: Object) |
|
private |
_onLoadingFinished(event: Object) |
|
private |
_onRequest(event: Object, interceptionId: string) |
|
private |
_onRequestIntercepted(event: Object) |
|
private |
_onRequestServedFromCache(event: Object) |
|
private |
_onRequestWillBeSent(event: Object) |
|
private |
_onResponseReceived(event: Object) |
|
private |
_setCacheDisabled(cacheDisabled: boolean): Promise<*> |
|
private |
|
Public Constructors
public constructor(client: Chrome | CRIConnection | CDPSession | Object, timeoutSettings: TimeoutSettings) source
Params:
Name | Type | Attribute | Description |
client | Chrome | CRIConnection | CDPSession | Object | ||
timeoutSettings | TimeoutSettings |
|
Private Members
private _client: Chrome | CRIConnection | CDPSession | Object source
private _frameManager: FrameManager source
private _timeoutSettings: TimeoutSettings source
Public Methods
public async bypassServiceWorker(bypass: boolean): Promise<void> since chrome-remote-interface-extra source
Toggles ignoring of service worker for each request. EXPERIMENTAL
Params:
Name | Type | Attribute | Description |
bypass | boolean | Bypass service worker and load from network |
public async clearBrowserCookies(): Promise<void> since chrome-remote-interface-extra source
Clears browser cookies
public async deleteCookie(cookie: CDPCookie | CookieToBeDeleted | string | Cookie, forURL: string): Promise<void> since chrome-remote-interface-extra source
Deletes the specified browser cookies with matching name and url or domain/path pair.
Params:
Name | Type | Attribute | Description |
cookie | CDPCookie | CookieToBeDeleted | string | Cookie | The cookie to be deleted |
|
forURL | string |
|
public async deleteCookies(cookies: ...(CDPCookie|CookieToBeDeleted|string|Cookie)): Promise<void> since chrome-remote-interface-extra source
Deletes browser cookies with matching name and url or domain/path pair.
Params:
Name | Type | Attribute | Description |
cookies | ...(CDPCookie|CookieToBeDeleted|string|Cookie) | The cookies to be deleted |
public async emulateNetworkConditions(networkConditions: NetworkConditions): Promise<void> since chrome-remote-interface-extra source
Activates emulation of network conditions
Params:
Name | Type | Attribute | Description |
networkConditions | NetworkConditions | The new network conditions |
public async getAllCookies(): Promise<Array<Cookie>> since chrome-remote-interface-extra source
Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the cookies field.
public async getCertificate(origin: string): Promise<Array<string>> since chrome-remote-interface-extra source
Returns the DER-encoded certificate. EXPERIMENTAL
Params:
Name | Type | Attribute | Description |
origin | string | Origin to get certificate for |
public async getCookies(urls: Array<string>): Promise<Array<Cookie>> since chrome-remote-interface-extra source
Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the cookies field.
public networkIdlePromise(options: NetIdleOptions): Promise<void> since chrome-remote-interface-extra source
Returns a promise that resolves once the network has become idle. Detection of network idle considers only the number of in-flight HTTP requests for the Page connected to
Params:
Name | Type | Attribute | Description |
options | NetIdleOptions |
|
public async setAcceptLanguage(acceptLanguage: string) since chrome-remote-interface-extra source
Params:
Name | Type | Attribute | Description |
acceptLanguage | string | Browser langugage to emulate |
public async setBlockedURLs(urls: ...string): Promise<void> since chrome-remote-interface-extra source
Blocks URLs from loading. EXPERIMENTAL
Params:
Name | Type | Attribute | Description |
urls | ...string | URL patterns to block. Wildcards ('*') are allowed |
public async setCookie(cookie: CDPCookie | CookieParam | string): Promise<boolean> since chrome-remote-interface-extra source
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist
Params:
Name | Type | Attribute | Description |
cookie | CDPCookie | CookieParam | string | The new cookie to be set |
public async setCookies(cookies: ...(CDPCookie|CookieParam|string)): Promise<void> since chrome-remote-interface-extra source
Sets given cookies
Params:
Name | Type | Attribute | Description |
cookies | ...(CDPCookie|CookieParam|string) |
public setFrameManager(frameManager: FrameManager) source
Params:
Name | Type | Attribute | Description |
frameManager | FrameManager |
|
public async setNavigatorPlatform(platform: string) since chrome-remote-interface-extra source
Params:
Name | Type | Attribute | Description |
platform | string | The platform navigator.platform should return |
public async setOfflineMode(offline: boolean) source
Params:
Name | Type | Attribute | Description |
offline | boolean | T/F indicating offline status |
public async setRequestInterception(value: boolean) source
Params:
Name | Type | Attribute | Description |
value | boolean |
public setTimeoutSettings(toSettings: TimeoutSettings) since chrome-remote-interface-extra source
Params:
Name | Type | Attribute | Description |
toSettings | TimeoutSettings |
public async setUserAgent(userAgent: string) source
Params:
Name | Type | Attribute | Description |
userAgent | string | User agent to use |
public async setUserAgentOverride(overrides: UserAgentOverride): Promise<void> source
Allows overriding user agent with the given string.
Params:
Name | Type | Attribute | Description |
overrides | UserAgentOverride |
public toJSON(): {"extraHTTPHeaders": *, "ignoreHTTPSErrors": *, "defaultViewport": *, "offline": *, "cacheEnabledState": *, "credentials": *, "userRequestInterceptionEnabled": *, "protocolRequestInterceptionEnabled": *} source
Return:
{"extraHTTPHeaders": *, "ignoreHTTPSErrors": *, "defaultViewport": *, "offline": *, "cacheEnabledState": *, "credentials": *, "userRequestInterceptionEnabled": *, "protocolRequestInterceptionEnabled": *} |
public waitForRequest(urlOrPredicate: string | Function, options: {timeout?: number}): Promise<Request> source
public waitForResponse(urlOrPredicate: string | Function, options: {timeout?: number}): Promise<Response> source
Private Methods
private _onLoadingFailed(event: Object) source
Params:
Name | Type | Attribute | Description |
event | Object |
|
private _onLoadingFinished(event: Object) source
Params:
Name | Type | Attribute | Description |
event | Object |
|
private _onRequestIntercepted(event: Object) source
Params:
Name | Type | Attribute | Description |
event | Object |
|
private _onRequestServedFromCache(event: Object) source
Params:
Name | Type | Attribute | Description |
event | Object |
|
private _onRequestWillBeSent(event: Object) source
Params:
Name | Type | Attribute | Description |
event | Object |
|
private _onResponseReceived(event: Object) source
Params:
Name | Type | Attribute | Description |
event | Object |
|
private _setCacheDisabled(cacheDisabled: boolean): Promise<*> source
Params:
Name | Type | Attribute | Description |
cacheDisabled | boolean |