0

This question already has an answer here:

I am trying to run a test program to confirm my selenium installation. I have a 64 bit windows desktop and have downloaded the 64 bit version of Geckodriver from seleniumhq.org

Here is my source code :

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Name
{
 public static void main(String[] args)
 {

    String Firefoxdriverpath = "C://Desktop//geckodriver-v0.14.0-win64//geckodriver.exe";   

    WebDriver driver;
    System.setProperty("webdriver.gecko.driver", Firefoxdriverpath);
    driver = new FirefoxDriver();
    driver.get("http://www.google.com");
    System.out.println(driver.getTitle());
    driver.close();
 }
}

I am getting a runtime error :

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function
    at Name.main(Name.java:15)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 1 more

Any pointers on what I may be missing is helpful?

marked as duplicate by alecxe Sep 25 '17 at 18:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Have you verified all your references on the OS and code are correct for the Selenium library, Gecko, and the firefox browser itself? It looks like one of those is missing so it's not finding the initiation class. As firefox and selenium work pretty well out of the box, I'm guessing it's something with the gecko setup specifically that you are trying to utilize. You might want to doublecheck on the geckodriver usage and ensure there isn't an extra PATH variable or system reference needed in your code to properly call the class. You IDE might also need the library in there in a certain way. – mutt Feb 22 '17 at 3:22
  • also, this might be related...stackoverflow.com/questions/37785686/… – mutt Feb 22 '17 at 3:25
  • 1
    It may be occuring because you have not added the selenium jar files to the libraries – the_coder Feb 22 '17 at 4:37
  • Thanks. I got it to work after adding the selenium jar files to the library. – Jay Feb 22 '17 at 5:46
  • Add the Selenium jar and other supporting jars files to build path and clean your project. – zishan paya Feb 22 '17 at 10:39
-1

Not sure if thats the actual code you posted but the line:

String Firefoxdriverpath = "C://Desktop//geckodriver-v0.14.0-win64//geckodriver.exe";

It looks Weird to me.

usually on windows its- C://Users//<username>//Desktop

  • The executable file can be located anywhere – Tired Of Testing Sep 25 '17 at 15:53
  • I dont think so dear – iamsankalp89 Sep 25 '17 at 17:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.