Class: Response

Response(messageID, respHandler)

Represents the response returned from the remote end after execution of its corresponding command.

The response is a mutable object passed to each command for modification through the available setters. To send data in a response, you modify the body property on the response. The body property can also be replaced completely.

The response is sent implicitly by when a command has finished executing, and any modifications made subsequent to that will have no effect.

Methods

(static) fromPacket(data) → {Response

Converts a data packet into Response.

Parameters:
Name Type Description
data Array.<number, number, ?, ?>

A four element array where the elements, in sequence, signifies message type, message ID, error, and result.

Source:
Throws:

If the message type is not recognised.

Type
TypeError
Returns:

Representation of packet.

Type
Response

send()

Sends response using the response handler provided on construction.

Source:
Throws:

If the response has already been sent.

Type
RangeError

sendConditionally(predicate)

Sends response conditionally, given a predicate.

Parameters:
Name Type Description
predicate function

A predicate taking a Response object and returning a boolean.

Source:

sendError(err)

Send error to client.

Turns the response into an error response, clears any previously set body data, and sends it using the response handler provided on construction.

Parameters:
Name Type Description
err Error

The Error instance to send.

Source:
Throws:

If err is not a WebDriverError, the error is propagated, i.e. rethrown.

Type
Error

toPacket() → {Array}

Encodes the response to a packet.

Source:
Returns:

Packet.

Type
Array