执行selenium web驱动程序时获得异常

时间:2014-09-25 09:39:59

标签: eclipse testing selenium selenium-webdriver

我正在执行简单的java程序并尝试执行我的第一个selenium脚本。

 public static void main(String[] args) {
        // Create a new instance of the html unit driver
        // Notice that the remainder of the code relies on the interface, 
        // not the implementation.
        WebDriver driver = new HtmlUnitDriver();

        // And now use this to visit Google
        driver.get("http://www.google.com");

        // Find the text input element by its name
        WebElement element = driver.findElement(By.name("q"));

        // Enter something to search for
        element.sendKeys("Cheese!");

        // Now submit the form. WebDriver will find the form for us from the element
        element.submit();

        // Check the title of the page
        System.out.println("Page title is: " + driver.getTitle());

        driver.quit();
    }

这些是我添加的依赖项:dependencies that I have added

但是在运行此代码后,我在eclipse中遇到了这个异常。

java.lang.ClassNotFoundException: org.apache.xerces.xni.XNIException

1 个答案:

答案 0 :(得分:0)

ClassNotFoundException主要发生在指定的类路径中找不到类文件时。因此,请尝试删除xerces.jar并重新添加。