问题
I got a problem when I use Java Selenium Firefox geckodriver. Here is the problem:
*OS: Windows 7
*Selenium Version: Selenium 3.0.0 beta4
*Java: 8
*Geckodriver: v0.10.0
Error msg: Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/remote/internal/CircularOutputStream at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:56) at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:52) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:92) at tools.Cadencie.LoginCad(Cadencie.java:24) at tools.Cadencie.main(Cadencie.java:73) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.internal.CircularOutputStream 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) ... 10 more
Code:
public class Cadencie {
static WebDriver driver;
public void LoginCad(){
//System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
System.setProperty("webdriver.gecko.driver", "C:\\Program Files (x86)\\Mozilla Firefox\\geckodriver.exe");
driver = new FirefoxDriver();
driver.get("http://172.16.1.133:8090/CADENCIE/servlet/app");
try {
Thread.sleep(1000);
} catch(InterruptedException e){
e.printStackTrace();
}
Utilities.switchToWindow("Cadencie - User Logon [LOGON]", driver);
try{
Thread.sleep(2000);
} catch(InterruptedException e){
e.printStackTrace();
}
driver.findElement(By.id("idBANK")).clear();
driver.findElement(By.id("idBANK")).sendKeys("48");
driver.findElement(By.id("idEMPLOYEE")).clear();
driver.findElement(By.id("idEMPLOYEE")).sendKeys("200003");
driver.findElement(By.id("idPASSWORD")).clear();
driver.findElement(By.id("idPASSWORD")).sendKeys("Cadencie1");
driver.findElement(By.id("maintLOGON")).click();
driver.findElement(By.id("idPASSWORD")).clear();
driver.findElement(By.id("idPASSWORD")).sendKeys("Cadencie1");
driver.findElement(By.id("maint")).click();
}
I think it might be an inconsistent version issue. Because I have another automation project which is using maven, selenium 2.52.0.. But not sure if this caused the problem. I'm not using maven this time. Just try to create a JAVA GUI program (tool kit).
回答1:
Exception is because of missing jar files in classpath.
If you don't use Maven, check the Compile Dependencies at MVN Repository page and manually add the jars to your class path.
If you're using Maven, see: java.lang.classnotfoundexception: org.openqa.selenium.io.Circular OutputStream
来源:https://stackoverflow.com/questions/40009527/circularoutputstream-class-not-found-exception-when-using-selenium-with-mozilla