Read the complete Blog - How to use JavaScriptExecutor in Selenium
In this article, you will learn about how JavaScriptExecutor works in selenium. Basically, JavaScriptExecutor is an Interface that allows you to execute JavaScript through the Selenium web driver. It is a medium that allows a web driver to interact with the HTML elements of a webpage. It provides two methods i.e. executeScript and executeAsyncScript, to execute JavaScript on a selected webPage.
- ExecuteAsyncScript
- ExecuteScript
This method executes an asynchronous piece of JavaScript on the current webpage. With the asynchronous script, web pages render very quickly, Instead of waiting for the script to download before the page renders which enhances the application performance.
This method executes JavaScript in the context of the currently selected webpage or window. The script in this method runs in the body of an anonymous function. This script can return WebElement, long, Boolean, list, or String.
git clone https://github.com/TestingWithSK/selenium-javascript-executor-example.git
- Right click on any java file inside
src/test/java/example
and select -Run '<FILE_NAME>'
Read the complete Blog - How to use JavaScriptExecutor in Selenium
Happy Testing!!!