【发布时间】:2014-09-25 09:39:59
【问题描述】:
我正在执行简单的 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();
}
这些是我添加的依赖项:
但是在运行这段代码之后,我在 eclipse 中遇到了这个异常。
java.lang.ClassNotFoundException: org.apache.xerces.xni.XNIException
【问题讨论】:
-
为什么你有 xerces.jar ,我认为不需要运行 selenium 脚本。删除它,然后再试一次。
标签: eclipse testing selenium selenium-webdriver