Exposing the JavascriptExecutor

As we can see in the preceding code, there is a new entry in our encyclopedia of Selenium concepts, which is JavascriptExecutor. It is one of the interfaces in Selenium that can be used to accomplish things that cannot be accomplished through regular locators. It lets us execute JavaScript code in Selenium. Let's study the following line from the code in the previous section:

isJqueryCallDone = (Boolean) ((JavascriptExecutor) driver).executeScript("return jQuery.active===0");

The isJqueryCallDone phrase is a Boolean variable that is assigned the value of return jQuery.active===0.

Here, we are invoking the executeScript function on the driver object after casting it to JavascriptExecutor. Only then will the driver able to execute the JavaScript commands.

We will see more of JavascriptExecutor in a later chapter, where we will do a thorough examination of JavascriptExecutor.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.212.99