Execute JavaScript using Selenium WebDriver in C#

Execute JavaScript using Selenium WebDriver in C#

The following script shows how to use IJavaScriptExecutor, C#'s version of Java's JavascriptExecutor class, to execute JavaScript code.

IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
string title = (string)js.ExecuteScript("return document.title");

Leave a reply

Your email address will not be published. Required fields are marked*

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.