【问题标题】:CircularOutputStream class not found exception when using Selenium with Mozilla's GeckoDriver将 Selenium 与 Mozilla 的 GeckoDriver 一起使用时,未发现 CircularOutputStream 类异常
【发布时间】:2017-02-21 21:36:36
【问题描述】:

我在使用 Java Selenium Firefox geckodriver 时遇到问题。问题来了:

*操作系统:Windows 7

*Selenium 版本:Selenium 3.0.0 beta4

*Java:8

*Geckodriver: v0.10.0

错误信息: 线程“主”java.lang.NoClassDefFoundError 中的异常:org/openqa/selenium/remote/internal/CircularOutputStream 在 org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:56) 在 org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:52) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:92) 在工具.Cadencie.LoginCad(Cadencie.java:24) 在工具.Cadencie.main(Cadencie.java:73) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) 引起:java.lang.ClassNotFoundException:org.openqa.selenium.remote.internal.CircularOutputStream 在 java.net.URLClassLoader.findClass(URLClassLoader.java:381) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:424) 在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 10 更多

代码:

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();

}

我认为这可能是版本不一致的问题。因为我有另一个使用 maven 的自动化项目 selenium 2.52.0.. 但不确定这是否会导致问题。这次我没有使用maven。只需尝试创建一个 JAVA GUI 程序(工具包)。

【问题讨论】:

    标签: java selenium geckodriver


    【解决方案1】:

    异常是因为classpath 中缺少 jar 文件。

    如果您不使用 Maven,请检查 Compile Dependencies at MVN Repository page 并手动将 jars 添加到您的类路径中。

    如果您使用的是 Maven,请参阅:java.lang.classnotfoundexception: org.openqa.selenium.io.Circular OutputStream

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-28
    • 2020-03-16
    • 1970-01-01
    相关资源
    最近更新 更多