Table of Contents

Class CommandParameters

Namespace
WebDriverBiDi
Assembly
WebDriverBiDi.dll

Abstract base class for a set of settings for a command.

public abstract class CommandParameters
Inheritance
CommandParameters
Derived
Inherited Members

Constructors

CommandParameters()

protected CommandParameters()

Properties

AdditionalData

Gets additional properties to be serialized with this command.

[JsonExtensionData]
public Dictionary<string, object?> AdditionalData { get; }

Property Value

Dictionary<string, object>

Remarks

The WebDriver BiDi protocol allows for additional command properties that are not defined in the specification. This dictionary allows users to include those additional properties while maintaining the strongly-typed nature of the CommandParameters class. The entries in this dictionary are intentionally mutable, so that users can add additional properties as needed.

Entries are serialized as additional properties inside the params object of the command message, alongside the typed parameter properties. They are not written at the envelope level next to id, method, and params; for envelope-level properties, override CreateCommand(CommandParameters) and populate AdditionalCommandProperties.

An entry may not reuse the name of a property this parameters type already serializes; doing so would write that name twice inside params, and a JSON object with a duplicate name has no defined meaning. Sending such a command throws WebDriverBiDiSerializationException rather than emitting the ambiguous payload. Set the typed property instead.

Though the values of this dictionary are typed as object, they will be serialized to JSON using the same rules as other properties of the command. This means that values can be of any type that is serializable to JSON, including complex objects, arrays, and primitive types. However, custom types should be designed with JSON serialization in mind to ensure they are serialized correctly, including use of the appropriate attributes for JSON serialization by JsonSerializer.

AOT / trimming note: because the entries are typed as object, serialization of their runtime types relies on reflection-based JsonSerializer overloads that are not compatible with trimming or native AOT. Consumers that publish with PublishAot=true and use this dictionary must ensure every value's runtime type is discoverable by a registered IJsonTypeInfoResolver (see RegisterTypeInfoResolverAsync(IJsonTypeInfoResolver, CancellationToken)), or the command will fail at send time with a WebDriverBiDiSerializationException wrapping the NotSupportedException that names the type.

MethodName

Gets the method name of the command.

[JsonIgnore]
public abstract string MethodName { get; }

Property Value

string

ResponseType

Gets the type of the response for this command.

[JsonIgnore]
public abstract Type ResponseType { get; }

Property Value

Type