Java HtmlUnitDriver()不工作

Java HtmlUnitDriver()不工作,java,selenium,htmlunit,htmlunit-driver,Java,Selenium,Htmlunit,Htmlunit Driver,我在Eclipse中设置了一个selenium项目。我能够让我的selenium项目与firefox驱动程序一起工作;但是,当我尝试改用HtmlUnitDriver时,出现以下错误: Exception in thread "main" net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: Exception: java.lang.RuntimeException: java.io.FileNotFoundException

我在Eclipse中设置了一个selenium项目。我能够让我的selenium项目与firefox驱动程序一起工作;但是,当我尝试改用HtmlUnitDriver时,出现以下错误:

Exception in thread "main" net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: Exception: java.lang.RuntimeException: java.io.FileNotFoundException: \Settlement\static\css\WebDirect_1.css (The system cannot find the path specified)
at net.sourceforge.htmlunit.corejs.javascript.Context.reportRuntimeError(Context.java:965)
at net.sourceforge.htmlunit.corejs.javascript.Context.reportRuntimeError(Context.java:1017)
at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.loadStylesheet(CSSStyleSheet.java:279)
at com.gargoylesoftware.htmlunit.javascript.host.html.HTMLLinkElement.getSheet(HTMLLinkElement.java:129)
at com.gargoylesoftware.htmlunit.javascript.host.css.StyleSheetList.jsxFunction_item(StyleSheetList.java:126)
at com.gargoylesoftware.htmlunit.javascript.host.Window.jsxFunction_getComputedStyle(Window.java:1454)
at com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement.jsxGet_currentStyle(HTMLElement.java:208)
at com.gargoylesoftware.htmlunit.html.DomNode.isDisplayed(DomNode.java:683)
at org.openqa.selenium.htmlunit.HtmlUnitWebElement.getTextFromNode(HtmlUnitWebElement.java:572)
at org.openqa.selenium.htmlunit.HtmlUnitWebElement.getText(HtmlUnitWebElement.java:524)
at com.automation.selenium.HTMLToExcelExporter.extractParticipantID(HTMLToExcelExporter.java:753)
at com.automation.selenium.HTMLToExcelExporter.generateFileOutputPath(HTMLToExcelExporter.java:760)
at com.automation.selenium.HTMLToExcelExporter.initializeFileOutputStream(HTMLToExcelExporter.java:106)
at com.automation.selenium.MainClass.main(MainClass.java:38)
简而言之,我正在尝试执行以下代码:

WebDriver webDriver = new HtmlUnitDriver();
webDriver.get("Some web page");
WebElement element = webDriver.findElement(By.xpath("some xpath"));

非常感谢您的帮助。

错误很明显:

FileNotFoundException:\consolution\static\css\WebDirect\u 1.css(系统找不到指定的路径)

将文件添加到web服务器中,就是这样


现在,如果您正在尝试web刮取,则无法修复该问题。但是,您可以通过在WebClient对象中设置为
false
来尝试防止丢失的文件引发异常。

如何将setThroweExceptionOnScriptError实现为false?webdriver是否有WebClient成员变量?