1

I'm learning selenium and I just copied a simple java code from a website and tried to run it. But it gave me the below error. Please help me in fixing it.

Installed files:

 1. Selenium api 2.44.0
 2. Selenium firefox driver 2.44.0
 3. Seleinium server stand alone 2.53.1
 4. Selenium support 2.44
 5. Firefox version - 35.1.0

Error:

Exception in thread "main" java.lang.NoClassDefFoundError:
org/openqa/selenium/remote/internal/CircularOutputStream at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:59) at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:55) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:95) at Sel.OpenGoogle.main(OpenGoogle.java:6) Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.internal.CircularOutputStream 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) ... 4 more

My code:

package Sel;
import org.openqa.selenium.WebDriver;  
import org.openqa.selenium.firefox.FirefoxDriver;  
public class OpenGoogle {  
  public static void main(String args[]){  
  WebDriver driver=new FirefoxDriver();  
  System.out.println("Hello Google...");  
  driver.get("http://google.com");    
    }  
 } 

Error after adding selenium remote driver 2.4.4

Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA
Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', time: '2014-10-23 13:11:40'
System info: host: 'PC', ip: '192.168.1.2', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_101'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.Executable.<init>(Executable.java:72)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:59)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:55)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
at Sel.OpenGoogle.main(OpenGoogle.java:6)
Mohsin Awan
  • 1,176
  • 2
  • 12
  • 29
stack mark
  • 101
  • 2
  • 13
  • Yes, I right clicked on my project and then added the jar files – stack mark Jan 23 '17 at 05:59
  • 1
    Can you add selenium remote driver jar as well and test again. https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-remote-driver/2.7.0 – Sanchit Khera Jan 23 '17 at 06:12
  • Got this error after I added remote driver. Updated OP – stack mark Jan 23 '17 at 06:14
  • 1
    Did you see this error? "Cannot find firefox binary in PATH. Make sure firefox is installed." Is firefox properly installed? – Sanchit Khera Jan 23 '17 at 06:20
  • Firefox is installed in `C:\Program Files\Firefox.exe` ..should i change any thing here? – stack mark Jan 23 '17 at 06:22
  • No my system is 32 bit. Is there any other place that i should install firefox? I can change it in the environment variables after changing the path. – stack mark Jan 23 '17 at 06:31
  • 1
    Can you try solutions under this post: http://stackoverflow.com/questions/14723081/cannot-find-firefox-binary-in-path-make-sure-firefox-is-installed-os-appears-t or http://stackoverflow.com/questions/20950748/cannot-find-firefox-binary-in-path-make-sure-firefox-is-installed – Sanchit Khera Jan 23 '17 at 06:34
  • Tried all the method..still not working..My path is set here `C:\Program Files\firefox.exe` – stack mark Jan 23 '17 at 06:49

2 Answers2

0

@Stack Mark Download selenium 2.53 for java from this link

http://selenium-release.storage.googleapis.com/index.html?path=2.53/

Delete all the currently installed jar files and load the new ones. Be careful not to delete JRE system library. Then everything will work fine. By the way which firefox browser are you using? I am using 47.0.1 Benefit is you don't have to use gecko driver.

BIJAY
  • 95
  • 9
  • I got this error when i followed ur steps and I use 35.0.1 `Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function at Sel.OpenGoogle.main(OpenGoogle.java:7) 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' – stack mark Jan 23 '17 at 06:55
0

OpenGoogle.java

Your code works fine on my system. You better check the classpath for jdk. Hope this helps. :) Apart from that check these out. http://www.codegravity.com/blog/exception-in-thread-main-java-lang-noclassdeffounderror

BIJAY
  • 95
  • 9