JavascriptExecutor is is an interface in Selenium, which indicates that a WebDriver instance can execute raw JavaScript, providing access to the mechanism for doing that.
It has two methods:
- The executeScript(String,Object...) object: Executes JavaScript code in the context of the currently selected frame or window. The script fragment provided will be executed as an anonymous function.
- The executeAsyncScript(String, Object...) object: Executes an asynchronous JavaScript in the context of the currently selected frame or window. In contrast to executing synchronous JavaScript, scripts executed with this method must specifically send a signal when they are complete by invoking the associated callback function. This callback function is injected into the executed function as the last argument.