1
我正在執行簡單的java程序並嘗試執行我的第一個硒腳本。在執行硒web驅動程序時得到異常
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();
}
這些都是我所添加的相關性:
但運行此代碼後,我得到這個例外蝕。
java.lang.ClassNotFoundException: org.apache.xerces.xni.XNIException
爲什麼你有xerces.jar,我不認爲它需要運行硒腳本。刪除並再次嘗試。 – 2014-09-25 10:55:27