Table of Contents

Class JavaScript

Namespace
OpenQA.Selenium.DevTools
Assembly
WebDriver.dll

Class representing the browser's JavaScript execution as referenced by the DevTools Protocol.

public abstract class JavaScript
Inheritance
JavaScript
Derived
Inherited Members

Methods

AddBinding(string)

Adds a binding to a specific JavaScript name.

public abstract Task AddBinding(string name)

Parameters

name string

The name to which to bind to.

Returns

Task

A task that represents the asynchronous operation.

AddScriptToEvaluateOnNewDocument(string)

Adds a JavaScript snippet to evaluate when a new document is opened.

public abstract Task<string> AddScriptToEvaluateOnNewDocument(string script)

Parameters

script string

The script to add to be evaluated when a new document is opened.

Returns

Task<string>

A task that represents the asynchronous operation. The task result contains the internal ID of the script.

DisablePage()

Asynchronously disables the Page domain in the DevTools Protocol.

public abstract Task DisablePage()

Returns

Task

A task that represents the asynchronous operation.

DisableRuntime()

Asynchronously disables the Runtime domain in the DevTools Protocol.

public abstract Task DisableRuntime()

Returns

Task

A task that represents the asynchronous operation.

EnablePage()

Asynchronously enables the Page domain in the DevTools Protocol.

public abstract Task EnablePage()

Returns

Task

A task that represents the asynchronous operation.

EnableRuntime()

Asynchronously enables the Runtime domain in the DevTools Protocol.

public abstract Task EnableRuntime()

Returns

Task

A task that represents the asynchronous operation.

OnBindingCalled(BindingCalledEventArgs)

Raises the BindingCalled event.

protected virtual void OnBindingCalled(BindingCalledEventArgs e)

Parameters

e BindingCalledEventArgs

An BindingCalledEventArgs that contains the event data.

OnConsoleApiCalled(ConsoleApiCalledEventArgs)

Raises the ConsoleApiCalled event.

protected virtual void OnConsoleApiCalled(ConsoleApiCalledEventArgs e)

Parameters

e ConsoleApiCalledEventArgs

An ConsoleApiCalledEventArgs that contains the event data.

OnExceptionThrown(ExceptionThrownEventArgs)

Raises the ExceptionThrown event.

protected virtual void OnExceptionThrown(ExceptionThrownEventArgs e)

Parameters

e ExceptionThrownEventArgs

An ExceptionThrownEventArgs that contains the event data.

RemoveBinding(string)

Removes a binding from a specific JavaScript name.

public abstract Task RemoveBinding(string name)

Parameters

name string

The name to which to remove the bind from.

Returns

Task

A task that represents the asynchronous operation.

RemoveScriptToEvaluateOnNewDocument(string)

Removes a JavaScript snippet from evaluate when a new document is opened.

public abstract Task RemoveScriptToEvaluateOnNewDocument(string scriptId)

Parameters

scriptId string

The ID of the script to be removed.

Returns

Task

A task that represents the asynchronous operation.

Events

BindingCalled

Occurs when a JavaScript script binding is called.

public event EventHandler<BindingCalledEventArgs> BindingCalled

Event Type

EventHandler<BindingCalledEventArgs>

ConsoleApiCalled

Occurs when the browser's JavaScript console API is called.

public event EventHandler<ConsoleApiCalledEventArgs> ConsoleApiCalled

Event Type

EventHandler<ConsoleApiCalledEventArgs>

ExceptionThrown

Occurs when a JavaScript exception is thrown.

public event EventHandler<ExceptionThrownEventArgs> ExceptionThrown

Event Type

EventHandler<ExceptionThrownEventArgs>