Explain me how to execute JavaScript in Selenium?

Submitted by: Muhammad
JavaScriptExecuter is used for JavaScript execution in Selenium.

A simple example:

WebDriver driver = new FireFoxDriver();
if (driver instanceof JavascriptExecutor) {
((JavascriptExecutor)driver).executeScript("{JavaScript Code}");
}
Submitted by: Muhammad

Read Online Automation Job Interview Questions And Answers