WebDriverExtensionsExecuteJavaScript Method (IWebDriver, String, Object)WebDriver
Executes JavaScript in the context of the currently selected frame or window

Namespace: OpenQA.Selenium.Support.Extensions
Assembly: WebDriver.Support (in WebDriver.Support.dll) Version: 3.1.0
Syntax

public static void ExecuteJavaScript(
	this IWebDriver driver,
	string script,
	params Object[] args
)

Parameters

driver
Type: OpenQA.SeleniumIWebDriver
The driver instance to extend.
script
Type: SystemString
The JavaScript code to execute.
args
Type: SystemObject
The arguments to the script.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IWebDriver. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions

ExceptionCondition
WebDriverExceptionThrown if this IWebDriver instance does not implement IJavaScriptExecutor
See Also

Reference