createDriver~ thenableWebDriverProxy

new thenableWebDriverProxy(sessionnon-null, …rest)

Parameters:
NameTypeAttributesDescription
sessionIThenable.<!Session>
rest?<repeatable>

Extends

Members

catch

then

Methods

(async) addCredential(credential)

Injects a credential into the authenticator.

Parameters:
NameTypeDescription
credential

Credential to be added

(async) addVirtualAuthenticator(options)

Adds a virtual authenticator with the given options.

Parameters:
NameTypeDescription
options

VirtualAuthenticatorOptions object to set authenticator options.

(async) createCDPConnection() → (non-null) {Promise.<resolved>}

Creates a new WebSocket connection.

Returns:

A new CDP instance.

Type: 
Promise.<resolved>

(async) fireSessionEvent(eventType, payloadopt) → (non-null) {Promise.<Object>}

Fires a custom session event to the remote server event bus.

This allows test code to trigger server-side utilities that subscribe to the event bus.

Parameters:
NameTypeAttributesDefaultDescription
eventTypestring

The type of event (e.g., "test:failed", "log:collect").

payloadObject<optional>
null

Optional data to include with the event.

Returns:

A promise that resolves to the response containing success status, event type, and timestamp.

Type: 
Promise.<Object>
Examples
// Fire a simple event
await driver.fireSessionEvent('test:started');
// Fire an event with payload
await driver.fireSessionEvent('test:failed', {
  testName: 'LoginTest',
  error: 'Element not found'
});

getAccessibilitySnapshot(optionsopt) → (non-null) {Promise.<!AccessibilityNode>}

Snapshots the accessibility tree of the current browsing context.

The tree is computed in the page from the DOM, following WAI-ARIA, html-aam and accname; it is not the browser's own accessibility tree. It is rooted at the driver's current browsing context: the top-level document, or the frame the driver has switched into. Every child frame's tree is attached under its iframe node, and the driver's current browsing context is left as it was. Works in both WebDriver Classic and BiDi sessions. The snapshot is a copy taken at one point in time.

const tree = await driver.getAccessibilitySnapshot()
console.log(tree.toText())
await tree.children[0].element.click()
Parameters:
NameTypeAttributesDescription
optionsObject<optional>

With interestingOnly true, the default, elements of role generic, none or presentation with no name produce no node and their children take their place. With false every rendered element produces a node, as Puppeteer's accessibility.snapshot({ interestingOnly: false }) does.

Returns:

The root node, of role document, named from the title.

Type: 
Promise.<!AccessibilityNode>

getBidi()

Returns the WebDriver BiDi connection for this session.

Deprecated
  • BiDi is an internal implementation detail — this accessor hands back the raw transport directly, which is no longer supported public API. Use a composed BiDi module instead, e.g. `Network.create(driver)` or `require('selenium-webdriver/bidi/network')`.
Returns:

(async) getCredentials()

Returns:

The list of credentials owned by the authenticator.

(async) getWsUrl(debuggerAddress, target, caps) → {string}

Retrieves 'webSocketDebuggerUrl' by sending a http request using debugger address

Parameters:
NameTypeDescription
debuggerAddressstring
target
caps
Returns:

Returns parsed webSocketDebuggerUrl obtained from the http request

Type: 
string

(async) installWebExtension(extension, optionsopt) → (non-null) {Promise.<!webExtension.WebExtension>}

Installs a browser extension. Works with remote (Grid) sessions: a directory is uploaded to the remote end first, and an archive or base64 bytes are sent inline.

Requires BiDi (see options.enableBidi()). Chromium installs only unpacked directories (SeleniumHQ/selenium#16541); Firefox also installs without BiDi, see ../firefox.Driver#installWebExtension.

const extension = await driver.installWebExtension('/path/to/extension')
await driver.uninstallWebExtension(extension)
Parameters:
NameTypeAttributesDescription
extensionstring

an unpacked extension directory, a packed extension file (.xpi/.crx/.zip), or base64-encoded bytes of one.

optionsObject.<string, boolean><optional>

browser-specific install options. This browser supports none; see ../firefox.Driver#installWebExtension for Firefox's.

Throws:
  • if an option is given that this browser cannot honor.

    Type
    error.InvalidArgumentError
  • if the session was created without BiDi.

    Type
    error.UnsupportedOperationError
Returns:

the installed extension.

Type: 
Promise.<!webExtension.WebExtension>

(async) logMutationEvents(connection, callback) → {Promise.<void>}

Parameters:
NameTypeDescription
connection
callback
Returns:
Type: 
Promise.<void>

(async) normalize_(webElementPromisenon-null) → (non-null) {Promise.<!WebElement>}

Parameters:
NameTypeDescription
webElementPromisefunction

The webElement in unresolved state

Returns:

First single WebElement from array of resolved promises

Type: 
Promise.<!WebElement>

(async) onIntercept(connection, httpResponse, callback)

Handle Network interception requests

Parameters:
NameTypeDescription
connection

WebSocket connection to the browser

httpResponse

Object representing what we are intercepting as well as what should be returned.

callback

callback called when we intercept requests.

(async) onLogEvent(connection, callback) → {Promise.<void>}

Parameters:
NameTypeDescription
connection
callback
Returns:
Type: 
Promise.<void>

(async) onLogException(connection, callback) → {Promise.<void>}

Parameters:
NameTypeDescription
connection
callback
Returns:
Type: 
Promise.<void>

(async) register(username, password, connection)

Sets a listener for Fetch.authRequired event from CDP If event is triggered, it enters username and password and allows the test to move forward

Parameters:
NameTypeDescription
usernamestring
passwordstring
connection

CDP Connection

(async) removeAllCredentials()

Removes all the credentials from the authenticator.

(async) removeCredential(credential_id)

Removes a credential from the authenticator.

Parameters:
NameTypeDescription
credential_id

The ID of the credential to be removed.

(async) removeVirtualAuthenticator()

Removes a previously added virtual authenticator. The authenticator is no longer valid after removal, so no methods may be called.

(async) setUserVerified(verified)

Sets whether the authenticator will simulate success or fail on user verification.

Parameters:
NameTypeDescription
verified

true if the authenticator will pass user verification, false otherwise.

(async) uninstallWebExtension(extensionnon-null) → (non-null) {Promise.<void>}

Uninstalls a browser extension installed with #installWebExtension.

Parameters:
NameTypeDescription
extensionwebExtension.WebExtension

the extension returned by #installWebExtension.

Throws:
  • if extension is not a WebExtension.

    Type
    error.InvalidArgumentError
  • if the session was created without BiDi.

    Type
    error.UnsupportedOperationError
Returns:

A promise that resolves once the extension is removed.

Type: 
Promise.<void>

virtualAuthenticatorId()

Returns:

The value of authenticator ID added