Table of Contents

Class ScriptModule

Namespace
WebDriverBiDi.Script
Assembly
WebDriverBiDi.dll

The Script module contains commands and events relating to script realms and execution.

public sealed class ScriptModule : Module
Inheritance
ScriptModule
Inherited Members

Constructors

ScriptModule(IBiDiModuleHost)

Initializes a new instance of the ScriptModule class.

public ScriptModule(IBiDiModuleHost driver)

Parameters

driver IBiDiModuleHost

The IBiDiModuleHost used in the module commands and events.

Fields

ScriptModuleName

The name of the script module.

public const string ScriptModuleName = "script"

Field Value

string

Properties

ModuleName

Gets the module name.

public override string ModuleName { get; }

Property Value

string

OnMessage

Gets an observable event that notifies when a script sends data to the client over a channel.

[ObservableEventName("script.message")]
public ObservableEvent<MessageEventArgs> OnMessage { get; }

Property Value

ObservableEvent<MessageEventArgs>

OnRealmCreated

Gets an observable event that notifies when a new script realm is created.

[ObservableEventName("script.realmCreated")]
public ObservableEvent<RealmCreatedEventArgs> OnRealmCreated { get; }

Property Value

ObservableEvent<RealmCreatedEventArgs>

OnRealmDestroyed

Gets an observable event that notifies when a script realm is destroyed.

[ObservableEventName("script.realmDestroyed")]
public ObservableEvent<RealmDestroyedEventArgs> OnRealmDestroyed { get; }

Property Value

ObservableEvent<RealmDestroyedEventArgs>

Methods

AddPreloadScriptAsync(AddPreloadScriptCommandParameters, TimeSpan?, CancellationToken)

Adds a preload script to each page before execution of other JavaScript included in the page source.

public Task<AddPreloadScriptCommandResult> AddPreloadScriptAsync(AddPreloadScriptCommandParameters commandParameters, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

commandParameters AddPreloadScriptCommandParameters

The parameters for the command.

timeoutOverride TimeSpan?

The timeout override to use for the command. If omitted, the value of DefaultCommandTimeout is used.

cancellationToken CancellationToken

A cancellation token used to propagate notification that the operation should be canceled. Omitting this argument is the equivalent of using None.

Returns

Task<AddPreloadScriptCommandResult>

The result of the command containing the ID of the created preload script.

Exceptions

ArgumentNullException

Thrown when commandParameters is null.

ArgumentOutOfRangeException

Thrown when timeoutOverride 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.

CallFunctionAsync(CallFunctionCommandParameters, TimeSpan?, CancellationToken)

Calls a function in the specified script target.

public Task<EvaluateResult> CallFunctionAsync(CallFunctionCommandParameters commandParameters, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

commandParameters CallFunctionCommandParameters

The parameters for the command.

timeoutOverride TimeSpan?

The timeout override to use for the command. If omitted, the value of DefaultCommandTimeout is used.

cancellationToken CancellationToken

A cancellation token used to propagate notification that the operation should be canceled. Omitting this argument is the equivalent of using None.

Returns

Task<EvaluateResult>

The result of the command containing the result of the function execution.

Exceptions

ArgumentNullException

Thrown when commandParameters is null.

ArgumentOutOfRangeException

Thrown when timeoutOverride 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.

DisownAsync(DisownCommandParameters, TimeSpan?, CancellationToken)

Disowns the specified handles to allow the script engine to garbage collect objects.

public Task<DisownCommandResult> DisownAsync(DisownCommandParameters commandParameters, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

commandParameters DisownCommandParameters

The parameters for the command.

timeoutOverride TimeSpan?

The timeout override to use for the command. If omitted, the value of DefaultCommandTimeout is used.

cancellationToken CancellationToken

A cancellation token used to propagate notification that the operation should be canceled. Omitting this argument is the equivalent of using None.

Returns

Task<DisownCommandResult>

An empty command result.

Exceptions

ArgumentNullException

Thrown when commandParameters is null.

ArgumentOutOfRangeException

Thrown when timeoutOverride 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.

EvaluateAsync(EvaluateCommandParameters, TimeSpan?, CancellationToken)

Evaluates a piece of JavaScript in the specified script target.

public Task<EvaluateResult> EvaluateAsync(EvaluateCommandParameters commandParameters, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

commandParameters EvaluateCommandParameters

The parameters for the command.

timeoutOverride TimeSpan?

The timeout override to use for the command. If omitted, the value of DefaultCommandTimeout is used.

cancellationToken CancellationToken

A cancellation token used to propagate notification that the operation should be canceled. Omitting this argument is the equivalent of using None.

Returns

Task<EvaluateResult>

The result of the command containing the result of the script evaluation.

Exceptions

ArgumentNullException

Thrown when commandParameters is null.

ArgumentOutOfRangeException

Thrown when timeoutOverride 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.

GetRealmsAsync(GetRealmsCommandParameters?, TimeSpan?, CancellationToken)

Gets the realms associated with a given browsing context and realm type.

public Task<GetRealmsCommandResult> GetRealmsAsync(GetRealmsCommandParameters? commandParameters = null, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

commandParameters GetRealmsCommandParameters

The parameters for the command. If omitted, or if null, the command is sent with default parameters.

timeoutOverride TimeSpan?

The timeout override to use for the command. If omitted, the value of DefaultCommandTimeout is used.

cancellationToken CancellationToken

A cancellation token used to propagate notification that the operation should be canceled. Omitting this argument is the equivalent of using None.

Returns

Task<GetRealmsCommandResult>

The result of the command containing information about the realms.

Exceptions

ArgumentOutOfRangeException

Thrown when timeoutOverride 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.

RemovePreloadScriptAsync(RemovePreloadScriptCommandParameters, TimeSpan?, CancellationToken)

Removes a preload script from loading on each page before execution of other JavaScript included in the page source.

public Task<RemovePreloadScriptCommandResult> RemovePreloadScriptAsync(RemovePreloadScriptCommandParameters commandParameters, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

commandParameters RemovePreloadScriptCommandParameters

The parameters for the command.

timeoutOverride TimeSpan?

The timeout override to use for the command. If omitted, the value of DefaultCommandTimeout is used.

cancellationToken CancellationToken

A cancellation token used to propagate notification that the operation should be canceled. Omitting this argument is the equivalent of using None.

Returns

Task<RemovePreloadScriptCommandResult>

An empty command result.

Exceptions

ArgumentNullException

Thrown when commandParameters is null.

ArgumentOutOfRangeException

Thrown when timeoutOverride 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.