What is JavaScriptExecutor and how it helps in Selenium automation?

0 votes
Jun 4, 2019 in Selenium by Rohan
775 views

1 answer to this question.

0 votes

@Rohan, JavaScript executor is an interface of Selenium WebDriver that has the functionality similar to that of Java Script and can interact with HTML DOM elements. Instead of using driver.findElement method of the Selenium WebDriver we can use JavaScriptExecutor Interface to perform similar action on the Page. It provides advantages over FindElement method while handling tricky XPath as well as finding element which are sometimes hidden.

Not only that, we can perform several other Java Script actions such as Browser Object Model (BOM), AJAX in addition to HTML DOM actions with the help of JavaScript Executor. Some scenarios we could handle using JavaScript Executor are:

  1. To type Text in Selenium WebDriver without using sendKeys() method

  2. To click a Button in Selenium WebDriver using JavaScript

  3. To handle Checkbox

  4. To generate Alert Pop window in selenium

  5. To refresh browser window using Javascript

  6. To get innertext of the entire webpage in Selenium

  7. To get the Title of our webpage

  8. To get the domain

  9. To get the URL of a webpage

  10. To perform Scroll on an application using  Selenium

  11. To click on a SubMenu which is only visible on mouse hover on Menu

  12. To navigate to different page using Javascript

answered Jun 4, 2019 by Pratibha

Related Questions In Selenium

0 votes
1 answer

What is Firebug and how it is useful in Selenium Automation testing?

Hello Amit, FireBug is a plugin which comes ...READ MORE

answered May 28, 2019 in Selenium by Anvi
• 14,090 points
227 views
0 votes
1 answer

What is IWebElement and how it is used in Selenium C#?

Hello Paul, IWebElement is an Interface in ...READ MORE

answered Jun 10, 2019 in Selenium by Esha
3,461 views
0 votes
1 answer

What is Apache POI in Selenium and what it is used for?

Hi Raj, Apache POI is the most commonly ...READ MORE

answered May 8, 2019 in Selenium by Abha
• 27,930 points
1,072 views
0 votes
1 answer

What is Xpath and what are the types of it in Selenium Webdriver?

Hi Piyush, XPath is defined as XML path. It is ...READ MORE

answered May 8, 2019 in Selenium by Pratibha
• 3,690 points
1,111 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
3,524 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,526 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,592 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
2,854 views
0 votes
1 answer

What is Base class in Selenium and how it works?

Hey Prashant, in Selenium Base class is the main ...READ MORE

answered Jul 18, 2019 in Selenium by Abha
• 27,930 points
3,777 views
0 votes
1 answer

What is TestNG and why it is used in selenium?

Hello @User, Talking about TestNG, it is an ...READ MORE

answered Dec 24, 2018 in Selenium by Shuvodip
296 views