Table of Contents

Class BrowsingContextModuleExtensions

Namespace
WebDriverBiDi.BrowsingContext
Assembly
WebDriverBiDi.Extensions.dll

Provides extension methods for the BrowsingContext module.

public static class BrowsingContextModuleExtensions
Inheritance
BrowsingContextModuleExtensions
Inherited Members

Methods

CaptureScreenshotAsync(BrowsingContextModule, string, ScreenshotOrigin, TimeSpan?, CancellationToken)

Captures a PNG screenshot of a browsing context.

public static Task<byte[]> CaptureScreenshotAsync(this BrowsingContextModule module, string browsingContextId, ScreenshotOrigin origin = ScreenshotOrigin.Viewport, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

module BrowsingContextModule

The BrowsingContextModule to extend.

browsingContextId string

The ID of the browsing context.

origin ScreenshotOrigin

Whether to capture the viewport or the whole document.

timeoutOverride TimeSpan?

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

cancellationToken CancellationToken

A token that cancels waiting for the command's response.

Returns

Task<byte[]>

The PNG image.

CloseAsync(BrowsingContextModule, string, TimeSpan?, CancellationToken)

Closes a browsing context.

public static Task CloseAsync(this BrowsingContextModule module, string browsingContextId, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

module BrowsingContextModule

The BrowsingContextModule to extend.

browsingContextId string

The ID of the browsing context.

timeoutOverride TimeSpan?

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

cancellationToken CancellationToken

A token that cancels waiting for the command's response.

Returns

Task

A task representing the asynchronous operation.

GetTopLevelBrowsingContextsAsync(BrowsingContextModule, TimeSpan?, CancellationToken)

Gets the top-level browsing contexts (tabs and windows), without their child frames.

public static Task<IReadOnlyList<BrowsingContextInfo>> GetTopLevelBrowsingContextsAsync(this BrowsingContextModule module, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

module BrowsingContextModule

The BrowsingContextModule to extend.

timeoutOverride TimeSpan?

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

cancellationToken CancellationToken

A token that cancels waiting for the command's response.

Returns

Task<IReadOnlyList<BrowsingContextInfo>>

The top-level browsing contexts.

LocateNodesByAccessibleRoleAsync(BrowsingContextModule, string, string, string?, IEnumerable<SharedReference>?, TimeSpan?, CancellationToken)

Finds the nodes with an accessible role and, optionally, an accessible name.

public static Task<IReadOnlyList<SharedReference>> LocateNodesByAccessibleRoleAsync(this BrowsingContextModule module, string browsingContextId, string accessibleRole, string? accessibleName = null, IEnumerable<SharedReference>? parentNodes = null, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

module BrowsingContextModule

The BrowsingContextModule to extend.

browsingContextId string

The ID of the browsing context.

accessibleRole string

The accessible role, such as "button".

accessibleName string

The accessible name, or null to match any.

parentNodes IEnumerable<SharedReference>

The nodes within which to search, or null for the whole document.

timeoutOverride TimeSpan?

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

cancellationToken CancellationToken

A token that cancels waiting for the command's response.

Returns

Task<IReadOnlyList<SharedReference>>

References to the matching nodes.

LocateNodesByCssSelectorAsync(BrowsingContextModule, string, string, IEnumerable<SharedReference>?, TimeSpan?, CancellationToken)

Finds the nodes matching a CSS selector.

public static Task<IReadOnlyList<SharedReference>> LocateNodesByCssSelectorAsync(this BrowsingContextModule module, string browsingContextId, string cssSelector, IEnumerable<SharedReference>? parentNodes = null, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

module BrowsingContextModule

The BrowsingContextModule to extend.

browsingContextId string

The ID of the browsing context.

cssSelector string

The CSS selector.

parentNodes IEnumerable<SharedReference>

The nodes within which to search, or null for the whole document.

timeoutOverride TimeSpan?

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

cancellationToken CancellationToken

A token that cancels waiting for the command's response.

Returns

Task<IReadOnlyList<SharedReference>>

References to the matching nodes.

LocateNodesByVisibleTextAsync(BrowsingContextModule, string, string, bool, bool, IEnumerable<SharedReference>?, TimeSpan?, CancellationToken)

Finds the nodes whose rendered text matches.

public static Task<IReadOnlyList<SharedReference>> LocateNodesByVisibleTextAsync(this BrowsingContextModule module, string browsingContextId, string text, bool isPartialMatch = true, bool matchCase = false, IEnumerable<SharedReference>? parentNodes = null, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

module BrowsingContextModule

The BrowsingContextModule to extend.

browsingContextId string

The ID of the browsing context.

text string

The text.

isPartialMatch bool

true to match nodes whose text contains text; false to match only nodes whose text is exactly it.

matchCase bool

true to match case.

parentNodes IEnumerable<SharedReference>

The nodes within which to search, or null for the whole document.

timeoutOverride TimeSpan?

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

cancellationToken CancellationToken

A token that cancels waiting for the command's response.

Returns

Task<IReadOnlyList<SharedReference>>

References to the matching nodes.

LocateNodesByXPathAsync(BrowsingContextModule, string, string, IEnumerable<SharedReference>?, TimeSpan?, CancellationToken)

Finds the nodes matching an XPath expression.

public static Task<IReadOnlyList<SharedReference>> LocateNodesByXPathAsync(this BrowsingContextModule module, string browsingContextId, string xpath, IEnumerable<SharedReference>? parentNodes = null, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

module BrowsingContextModule

The BrowsingContextModule to extend.

browsingContextId string

The ID of the browsing context.

xpath string

The XPath expression.

parentNodes IEnumerable<SharedReference>

The nodes within which to search, or null for the whole document.

timeoutOverride TimeSpan?

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

cancellationToken CancellationToken

A token that cancels waiting for the command's response.

Returns

Task<IReadOnlyList<SharedReference>>

References to the matching nodes.

NavigateAsync(BrowsingContextModule, string, string, ReadinessState?, TimeSpan?, CancellationToken)

Navigates a browsing context to a URL.

public static Task<string> NavigateAsync(this BrowsingContextModule module, string browsingContextId, string url, ReadinessState? wait = null, TimeSpan? timeoutOverride = null, CancellationToken cancellationToken = default)

Parameters

module BrowsingContextModule

The BrowsingContextModule to extend.

browsingContextId string

The ID of the browsing context.

url string

The URL.

wait ReadinessState?

How far the new document must have loaded before the command completes, or null for the remote end's default.

timeoutOverride TimeSpan?

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

cancellationToken CancellationToken

A token that cancels waiting for the command's response.

Returns

Task<string>

The URL navigated to.