Table of Contents

Interface IBiDiModuleHost

Namespace
WebDriverBiDi
Assembly
WebDriverBiDi.dll

Interface for a driver that executes commands and registers events for use with the WebDriver BiDi protocol. This interface is implemented by BiDiDriver and can be used for testing, or to allow users to implement their own driver classes.

public interface IBiDiModuleHost

Remarks

This interface is not intended to be implemented by users of this library. It is exposed publicly to allow for testing and to allow users to implement their own driver classes if they choose. Normal usage of this library should involve using the BiDiDriver class, which provides a complete implementation. This interface should be used only by advanced users who are implementing custom driver behavior or for testing purposes.

Methods

ExecuteCommandAsync<T>(CommandParameters, TimeSpan?, CancellationToken)

Asynchronously sends a command to the remote end of the WebDriver BiDi protocol and waits for a response.

Task<T> ExecuteCommandAsync<T>(CommandParameters commandParameters, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default) where T : CommandResult

Parameters

commandParameters CommandParameters

The object containing settings for the command, including parameters.

commandTimeout TimeSpan?

The timeout to wait for the command to complete.

cancellationToken CancellationToken

A cancellation token used to propagate notification that the operation should be canceled. Defaults to None, if unspecified.

Returns

Task<T>

The task object representing the asynchronous operation.

Type Parameters

T

The expected type of the result of the command.

Exceptions

ArgumentNullException

Thrown when commandParameters is null.

ArgumentOutOfRangeException

Thrown when commandTimeout is negative (other than InfiniteTimeSpan) or exceeds the maximum supported timer duration.

WebDriverBiDiCommandException

Thrown when the remote end returns an error response for the command.

WebDriverBiDiSerializationException

Thrown when the command parameters cannot be serialized, or the response cannot be deserialized.

WebDriverBiDiTimeoutException

Thrown when the command does not complete within the timeout.

WebDriverBiDiConnectionException

Thrown when the driver is not connected to a remote end, or the connection is lost before the command completes.

WebDriverBiDiException

Thrown when the command is canceled, or its response carries no result or a result of the wrong type.

OperationCanceledException

Thrown when cancellationToken is canceled.

ObjectDisposedException

Thrown when the driver has been disposed.

ExecuteCommandAsync<T>(CommandParameters<T>, TimeSpan?, CancellationToken)

Asynchronously sends a command to the remote end of the WebDriver BiDi protocol and waits for a response. The result type is inferred from the command parameters.

Task<T> ExecuteCommandAsync<T>(CommandParameters<T> commandParameters, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default) where T : CommandResult

Parameters

commandParameters CommandParameters<T>

The object containing settings for the command, including parameters.

commandTimeout TimeSpan?

The timeout to wait for the command to complete.

cancellationToken CancellationToken

A cancellation token used to propagate notification that the operation should be canceled. Defaults to None, if unspecified.

Returns

Task<T>

The task object representing the asynchronous operation.

Type Parameters

T

The expected type of the result of the command.

Exceptions

ArgumentNullException

Thrown when commandParameters is null.

ArgumentOutOfRangeException

Thrown when commandTimeout is negative (other than InfiniteTimeSpan) or exceeds the maximum supported timer duration.

WebDriverBiDiCommandException

Thrown when the remote end returns an error response for the command.

WebDriverBiDiSerializationException

Thrown when the command parameters cannot be serialized, or the response cannot be deserialized.

WebDriverBiDiTimeoutException

Thrown when the command does not complete within the timeout.

WebDriverBiDiConnectionException

Thrown when the driver is not connected to a remote end, or the connection is lost before the command completes.

WebDriverBiDiException

Thrown when the command is canceled, or its response carries no result or a result of the wrong type.

OperationCanceledException

Thrown when cancellationToken is canceled.

ObjectDisposedException

Thrown when the driver has been disposed.

RegisterEvent<T>(string, Func<EventInfo<T>, Task>)

Registers an event to be raised by the remote end of the WebDriver BiDi protocol.

void RegisterEvent<T>(string eventName, Func<EventInfo<T>, Task> eventInvoker)

Parameters

eventName string

The name of the event to raise.

eventInvoker Func<EventInfo<T>, Task>

The delegate taking a single parameter of type T used to invoke the event.

Type Parameters

T

The type of data that will be raised by the event.