Assembly: WebDriver (in WebDriver.dll) Version: 2.35.0.0 (2.35.0.0)
Parameters
- script
- Type:
System String
The JavaScript code to execute.
- args
- Type:
System Object
The arguments to the script.
Return Value
The value returned by the script.The ExecuteScript(String, Object )method executes JavaScript in the context of the currently selected frame or window. This means that "document" will refer to the current document. If the script has a return value, then the following steps will be taken:
- For an HTML element, this method returns a IWebElement
- For a number, a
Int64 is returned
- For a boolean, a
Boolean is returned
- For all other cases a
String is returned.
- For an array,we check the first element, and attempt to return a
List T of that type, following the rules above. Nested lists are not supported.
- If the value is null or there is no return value, is returned.
Arguments must be a number (which will be converted to a Int64),
a
Boolean, a
String or a IWebElement.
An exception will be thrown if the arguments do not meet these criteria.
The arguments will be made available to the JavaScript via the "arguments" magic
variable, as if the function were called via "Function.apply"