Table of Contents

Interface IJavaScriptEngine

Namespace
OpenQA.Selenium
Assembly
WebDriver.dll

Defines an interface allowing the user to manage settings in the browser's JavaScript engine.

public interface IJavaScriptEngine : IDisposable
Inherited Members

Properties

InitializationScripts

Gets the read-only list of initialization scripts added for this JavaScript engine.

IReadOnlyList<InitializationScript> InitializationScripts { get; }

Property Value

IReadOnlyList<InitializationScript>

ScriptCallbackBindings

Gets the read-only list of binding callbacks added for this JavaScript engine.

IReadOnlyList<string> ScriptCallbackBindings { get; }

Property Value

IReadOnlyList<string>

Methods

AddInitializationScript(string, string)

Asynchronously adds JavaScript to be loaded on every document load.

Task<InitializationScript> AddInitializationScript(string scriptName, string script)

Parameters

scriptName string

The friendly name by which to refer to this initialization script.

script string

The JavaScript to be loaded on every page.

Returns

Task<InitializationScript>

A task containing an InitializationScript object representing the script to be loaded on each page.

Exceptions

ArgumentNullException

If scriptName is null.

AddScriptCallbackBinding(string)

Asynchronously adds a binding to a callback method that will raise an event when the named binding is called by JavaScript executing in the browser.

Task AddScriptCallbackBinding(string bindingName)

Parameters

bindingName string

The name of the callback that will trigger events when called by JavaScript executing in the browser.

Returns

Task

A task that represents the asynchronous operation.

ClearAll()

Asynchronously removes all bindings to JavaScript callbacks and all initialization scripts from being loaded for each document.

Task ClearAll()

Returns

Task

A task that represents the asynchronous operation.

ClearInitializationScripts()

Asynchronously removes all intialization scripts from being loaded on every document load.

Task ClearInitializationScripts()

Returns

Task

A task that represents the asynchronous operation.

ClearScriptCallbackBindings()

Asynchronously removes all bindings to JavaScript callbacks.

Task ClearScriptCallbackBindings()

Returns

Task

A task that represents the asynchronous operation.

DisableDomMutationMonitoring()

Disables monitoring for DOM changes.

Task DisableDomMutationMonitoring()

Returns

Task

A task that represents the asynchronous operation.

EnableDomMutationMonitoring()

Enables monitoring for DOM changes.

Task EnableDomMutationMonitoring()

Returns

Task

A task that represents the asynchronous operation.

PinScript(string)

Pins a JavaScript snippet for execution in the browser without transmitting the entire script across the wire for every execution.

Task<PinnedScript> PinScript(string script)

Parameters

script string

The JavaScript to pin

Returns

Task<PinnedScript>

A task containing a PinnedScript object to use to execute the script.

Exceptions

ArgumentNullException

If script is null.

RemoveInitializationScript(string)

Asynchronously removes JavaScript from being loaded on every document load.

Task RemoveInitializationScript(string scriptName)

Parameters

scriptName string

The friendly name of the initialization script to be removed.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

ArgumentNullException

If scriptName is null.

RemoveScriptCallbackBinding(string)

Asynchronously removes a binding to a JavaScript callback.

Task RemoveScriptCallbackBinding(string bindingName)

Parameters

bindingName string

The name of the callback to be removed.

Returns

Task

A task that represents the asynchronous operation.

Reset()

Asynchronously removes all bindings to JavaScript callbacks, all initialization scripts from being loaded for each document, and stops listening for events.

Task Reset()

Returns

Task

A task that represents the asynchronous operation.

StartEventMonitoring()

Asynchronously starts monitoring for events from the browser's JavaScript engine.

Task StartEventMonitoring()

Returns

Task

A task that represents the asynchronous operation.

StopEventMonitoring()

Stops monitoring for events from the browser's JavaScript engine.

void StopEventMonitoring()

UnpinScript(PinnedScript)

Unpins a previously pinned script from the browser.

Task UnpinScript(PinnedScript script)

Parameters

script PinnedScript

The PinnedScript object to unpin.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

ArgumentNullException

If script is null.

Events

DomMutated

Occurs when a value of an attribute in an element is being changed.

event EventHandler<DomMutatedEventArgs> DomMutated

Event Type

EventHandler<DomMutatedEventArgs>

JavaScriptCallbackExecuted

Occurs when a JavaScript callback with a named binding is executed.

event EventHandler<JavaScriptCallbackExecutedEventArgs> JavaScriptCallbackExecuted

Event Type

EventHandler<JavaScriptCallbackExecutedEventArgs>

JavaScriptConsoleApiCalled

Occurs when methods on the JavaScript console are called.

event EventHandler<JavaScriptConsoleApiCalledEventArgs> JavaScriptConsoleApiCalled

Event Type

EventHandler<JavaScriptConsoleApiCalledEventArgs>

JavaScriptExceptionThrown

Occurs when an exeception is thrown by JavaScript being executed in the browser.

event EventHandler<JavaScriptExceptionThrownEventArgs> JavaScriptExceptionThrown

Event Type

EventHandler<JavaScriptExceptionThrownEventArgs>