Network

Represents all commands and events of Network module. Described in https://w3c.github.io/webdriver-bidi/#module-network.

Constructor

new Network(driver, browsingContextIds)

Represents a Network object.

Parameters:
NameTypeDescription
driverDriver

The driver to fetch the BiDi connection.

browsingContextIdsArray

An array of browsing context IDs that the network events will be subscribed to.

Methods

(async) addIntercept(params) → {Promise.<string>}

Adds a network intercept.

Parameters:
NameTypeDescription
paramsAddInterceptParameters

The parameters for the network intercept.

Throws:
  • If params is not an instance of AddInterceptParameters.
Type
Error
Returns:
  • A promise that resolves to the added intercept's id.
Type: 
Promise.<string>

(async) authRequired(callback) → {Promise.<number>}

Subscribes to the 'network.authRequired' event and handles it with the provided callback.

Parameters:
NameTypeDescription
callbackfunction

The callback function to handle the event.

Returns:
  • A promise that resolves when the subscription is successful.
Type: 
Promise.<number>

(async) beforeRequestSent(callback) → {Promise.<void>}

Subscribes to the 'network.beforeRequestSent' event and handles it with the provided callback.

Parameters:
NameTypeDescription
callbackfunction

The callback function to handle the event.

Returns:
  • A promise that resolves when the subscription is successful.
Type: 
Promise.<void>

(async) cancelAuth(requestId) → {Promise.<void>}

Cancels the authentication for a specific request.

Parameters:
NameTypeDescription
requestIdstring

The ID of the request to cancel authentication for.

Returns:
  • A promise that resolves when the command is sent.
Type: 
Promise.<void>

(async) close() → {Promise.<void>}

Unsubscribes from network events for all browsing contexts.

Returns:

A promise that resolves when the network connection is closed.

Type: 
Promise.<void>

(async) continueRequest(params) → {Promise.<void>}

Continues the network request with the provided parameters.

Parameters:
NameTypeDescription
paramsContinueRequestParameters

The parameters for continuing the request.

Throws:

If params is not an instance of ContinueRequestParameters.

Type
Error
Returns:

A promise that resolves when the command is sent.

Type: 
Promise.<void>

(async) continueResponse(params) → {Promise.<void>}

Continues the network response with the given parameters.

Parameters:
NameTypeDescription
paramsContinueResponseParameters

The parameters for continuing the response.

Throws:

If params is not an instance of ContinueResponseParameters.

Type
Error
Returns:

A promise that resolves when the command is sent.

Type: 
Promise.<void>

(async) continueWithAuth(requestId, username, password) → {Promise.<void>}

Continues the network request with authentication credentials.

Parameters:
NameTypeDescription
requestIdstring

The ID of the request to continue.

usernamestring

The username for authentication.

passwordstring

The password for authentication.

Returns:
  • A promise that resolves when the command is sent.
Type: 
Promise.<void>

(async) continueWithAuthNoCredentials(requestId) → {Promise.<void>}

Continues the network request with authentication but without providing credentials.

Parameters:
NameTypeDescription
requestIdstring

The ID of the request to continue with authentication.

Returns:
  • A promise that resolves when the command is sent.
Type: 
Promise.<void>

(async) failRequest(requestId) → {Promise.<void>}

Fails a network request.

Parameters:
NameTypeDescription
requestIdnumber

The ID of the request to fail.

Returns:
  • A promise that resolves when the command is sent.
Type: 
Promise.<void>

(async) fetchError(callback) → {Promise.<void>}

Subscribes to the 'network.fetchError' event and handles it with the provided callback.

Parameters:
NameTypeDescription
callbackfunction

The callback function to handle the event.

Returns:
  • A promise that resolves when the subscription is successful.
Type: 
Promise.<void>

(async) provideResponse(params) → {Promise.<void>}

Provides a response for the network.

Parameters:
NameTypeDescription
paramsProvideResponseParameters

The parameters for providing the response.

Throws:

If params is not an instance of ProvideResponseParameters.

Type
Error
Returns:

A promise that resolves when the command is sent.

Type: 
Promise.<void>

(async) removeIntercept(interceptId) → {Promise.<void>}

Removes an intercept.

Parameters:
NameTypeDescription
interceptIdstring

The ID of the intercept to be removed.

Returns:
  • A promise that resolves when the intercept is successfully removed.
Type: 
Promise.<void>

(async) responseCompleted(callback) → {Promise.<void>}

Subscribes to the 'network.responseCompleted' event and handles it with the provided callback.

Parameters:
NameTypeDescription
callbackfunction

The callback function to handle the event.

Returns:
  • A promise that resolves when the subscription is successful.
Type: 
Promise.<void>

(async) responseStarted(callback) → {Promise.<void>}

Subscribes to the 'network.responseStarted' event and handles it with the provided callback.

Parameters:
NameTypeDescription
callbackfunction

The callback function to handle the event.

Returns:
  • A promise that resolves when the subscription is successful.
Type: 
Promise.<void>