0

I have a selenium project set up in Eclipse. I was able to get my selenium project to work with the firefox driver; however, i get the following error when I try to use the HtmlUnitDriver instead:

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)

In short, I'm trying to execute the following code:

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

Any help would be greatly appreciated.

Mosty Mostacho
  • 42,742
  • 16
  • 96
  • 123
Justin
  • 742
  • 5
  • 17
  • 34

1 Answers1

0

The error is pretty clear:

FileNotFoundException: \Settlement\static\css\WebDirect_1.css (The system cannot find the path specified)

Add the file in your web server and that would be it.

Now, if you are trying to web scrape then you can't fix that. However, you can try to prevent that missing file to throw an exception by setting setThrowExceptionOnScriptError to false in the WebClientOption object.

Mosty Mostacho
  • 42,742
  • 16
  • 96
  • 123
  • How would I go about implementing the setThrowExceptionOnScriptError to false? Does webdriver have a WebClientOption member variable? – Justin Oct 02 '13 at 13:49