What is JavaScriptExecutor and how it helps in Selenium automation?

0 votes
Jun 4 in Selenium by Rohan
50 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 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 in Selenium by Anvi
• 12,860 points
86 views
0 votes
1 answer
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 in Selenium by Abha
• 23,030 points
237 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 in Selenium by Pratibha
• 2,780 points
138 views
0 votes
1 answer

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,090 points
584 views
0 votes
1 answer
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,130 points
898 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
572 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 in Selenium by Abha
• 23,030 points
117 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
88 views