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

Leave a Reply

Your email address will not be published. Required fields are marked *