Javascript in Selenium Webdriver and Different usage

Hello, Welcome to Selenium Tutorials in this post we will see how we can introduce Javascript in Selenium Webdriver and what are the usage?

What is JavaScript

JavaScript is one of the programming languages of the Web.

All modern HTML pages are using JavaScript.

For more details, you can refer Wikipedia – JavaScript


Use of Javascript in Selenium Webdriver

We have used Java in our script and we implemented almost all feature but some features we can’t handle using Java so we need scripting language also which can control server side or client side scripting so we will use JavaScript in our Selenium script.
Javascript in Selenium Webdriver


Implement JavaScript in Selenium Webdriver

To execute JavaScript in our webdriver script we do not have to write the separate code we have one predefined interface available.

JavascriptExecutor is an Interface which is available in package org.openqa.selenium.JavascriptExecutor;

Inside this Interface we have some predefined method called executeScript()- so whatever script you will pass as a String  It will be executed by JavascriptExecutor.
Note- This is the most common question in the interview that how to type in Selenium without using the sendKeys method.


Let us implement Javascript in Selenium Webdriver

Program 1- How to type in Selenium without using sendKeys() method


Program 2- How to click in Selenium if button or radio button is disable


Program 3- How to uncheck checkbox in Selenium if checkbox is disable


 Please comment below if you are facing any issue. 

Thanks for visiting my blog. Keep in touch.

Happy Testing


  1. Gaurav Khurana
  2. Gaurav Khurana
  3. Ashley
  4. vijay
  5. hanumanthappa