0

I'm trying the following sample snippet

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Test
{
public static void main(String[] args)
{
     WebDriver driver = new FirefoxDriver();    
      driver.get("http://www.google.com");

    //System.out.println("My new program");

}
}

When I run this code, getting the following error.

 Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function
at Test.main(Test.java:6)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more

Firfox version is 48.0 Jar which added in eclipse is selenium-java-2.53.0, selenium-java-2.53.0-srcs.

Could anyone please help me to fix this issue.

testing
  • 1,736
  • 15
  • 46
  • 75
  • Similar Issue check here http://stackoverflow.com/questions/5134953/noclassdeffounderror-in-java-com-google-common-base-function – ravthiru Aug 16 '16 at 06:59
  • I have followed the above link and added all the lib file. now the problem which i'm facing is url is getting in the address bar after ff launched : Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. – testing Aug 16 '16 at 07:33
  • Amirdha, A Question, are you using "selenium-firefox-driver-2.48.1.jar " ? and what is the Firefox browser version ? I would like to replicate your issue. – likeToCode Aug 16 '16 at 08:27
  • Firfox version is 48.0 and selenium-java-3.0.0-beta2. I have added all the files in eclipse which is in 3.0.0-beta2. please follow the link http://stackoverflow.com/questions/38970080/the-path-to-the-driver-executable-must-be-set-by-the-webdriver-gecko-driver-issu – testing Aug 16 '16 at 08:37
  • @amirdha which url ar you trying to load ? are you able to load the url directly in the firefox ? – ravthiru Aug 16 '16 at 09:58
  • yes. I have downloaded the Jeckodriver.exe and added the following code. now url loading in the firefox. System.setProperty("webdriver.gecko.driver", "path/to/geckodriver.exe"); DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability("marionette", true); WebDriver driver = new FirefoxDriver(capabilities); – testing Aug 16 '16 at 11:35

0 Answers0