3

I might be missing something, but in every example I've inspected, JavascriptExecutor interface was imported simply by adding

import org.openqa.selenium.JavascriptExecutor

For some reason, it doesn't seem to work for me. When I try that, I receive this error:

ImportError: No module named org.openqa.selenium.JavascriptExecutor

Does anyone know how to solve it? I'd be profoundly thankful.

2 Answers 2

6

This is a Java import, not Python. Any way, you don't need any import as the WebDriver has built in function to run JavaScript

driver.execute_script('script')
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! I have read so many posts about different ways to import JavascriptExecutor, none of which worked as the OP said. And all along it wasn't even necessary... Probably why it can't be loaded anymore, it is built in.
-1

The error says it all :

ImportError: No module named org.openqa.selenium.JavascriptExecutor

Which essentially means the module org.openqa.selenium.JavascriptExecutor wasn't found in it's intended location.

Reason

The issue can arise if the Selenium Client encounters an error while transmission or storage.

Selenium Team is currently working on the issue SeleniumHQ/selenium/5378 to generate the binary checksum of the Downloaded Selenium Client which will help you to avoid encountering errors which may have been introduced during its transmission or storage.

Solution

Till then a solution will be to :

  • Remove the references of the error-prone JARs from your Project.
  • Clean the Project Workspace from your IDE & Rebuild All.
  • Download a frest set of JARs from Selenium Release Storage.
  • Run CCleaner tool to wipe off all the OS chores.
  • If your Web Browser (i.e. Chrome/Firefox/IE) base version is too old, uninstall the Web Browser through Revo Uninstaller and install a recent GA Release version of Web Browser.
  • Add the required JARs only.
  • Take a System Reboot.
  • Execute your Tests.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.