Part 3: Usages Of Javascripts In Selenium: Problem You Might Face While Executing Javascript Commands In Selenium

Hello Folks,

In this post, I will explain a problem which beginner in selenium may encounter and you don’t know how to resolve it. I have also faced the same issue and after lot of googling , I found the solution.

When you try to execute any javascript command, you might see error message as shown below:

Second argument in executeScript and executeAsyncscript is optional but you can see error message stating that argument is missing.

How to solve above problem?

This problem occurs because you are using a old java compiler 1.3 or 1.4. Solution is to upgrade it to higher version greater than or equal to 1.6.

To change version of java compiler, follow below steps:

  1. Click on “Project” and click on “Properties”. OR Click on project folder name and press “ALT+ENTER”.
  2. Click on “Java Compiler”.
  3. You will see selected JDK version as 1.3 or 1.4.
  4. Now change the JDK version to 1.7 or 1.8 as per availability.

Project will be recompiled and error will be vanished. Now you can enjoy scripting.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappySelenium

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 4+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went throw so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning