public static void main(String[] args) throws IOException {
RbnRunner runner = new RbnRunner();
runner.run();
}
public void run() throws IOException {
System.setProperty("webdriver.chrome.driver", "/Users/me/samples/Adam_milford/src/chromedriver");
WebDriver driver = new ChromeDriver();
但是当我想创建一个无头的selenium驱动程序而不是Chrome驱动程序时,代码就会失败:
public static void main(String[] args) throws IOException {
WebDriver driver = new HtmlUnitDriver();
为什么会这样?
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/impl/conn/PoolingClientConnectionManager
at com.gargoylesoftware.htmlunit.HttpWebConnection.createHttpClient(HttpWebConnection.java:536)
at com.gargoylesoftware.htmlunit.HttpWebConnection.getHttpClient(HttpWebConnection.java:500)
at com.gargoylesoftware.htmlunit.HttpWebConnection.setUseInsecureSSL(HttpWebConnection.java:711)
at com.gargoylesoftware.htmlunit.WebClient.setUseInsecureSSL(WebClient.java:1096)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.createWebClient(HtmlUnitDriver.java:263)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:129)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:172)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:168)
at RbnRunner.run(RbnRunner.java:40)
at RbnRunner.main(RbnRunner.java:28)
Caused by: java.lang.ClassNotFoundException: org.apache.http.impl.conn.PoolingClientConnectionManager
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
答案 0 :(得分:0)
org.apache.http.impl.conn.PoolingClientConnectionManager
不可用......你有图书馆吗?