|
HtmlUnitDriver
Information about the HtmlUnit Driver
HtmlUnit DriverThis is currently the fastest and most lightweight implementation of WebDriver. As the name suggests, this is based on HtmlUnit. Pros
Cons
Javascript in the HtmlUnitDriverNone of the popular browsers uses the javascript engine used by HtmlUnit (Rhino). If you test javascript using HtmlUnit the results may differ significantly from those browsers. When we say "javascript" we actually mean "javascript and the DOM". Although the DOM is defined by the W3C each browser out there has its own quirks and differences in their implementation of the DOM and in how javascript interacts with it. HtmlUnit has an impressively complete implementation of the DOM and has good support for using javascript, but it is no different from any other browser: it has its own quirks and differences from both the W3C standard and the DOM implementations of the major browsers, despite its ability to mimic other browsers. With WebDriver, we had to make a choice; do we enable HtmlUnit's javascript capabilities and run the risk of teams running into problems that only manifest themselves there, or do we leave javascript disabled, knowing that there are more and more sites that rely on javascript? We took the conservative approach, and by default have disabled support when we use HtmlUnit. Enabling JavascriptHaving said that, enabling Javascript support is very easy: HtmlUnitDriver driver = new HtmlUnitDriver(); driver.setJavascriptEnabled(true); This will cause the HtmlUnitDriver to emulate IE's Javascript handling by default. |
Sign in to add a comment
I think the main point of using WebDriver? or Selenium is to run the JavaScript?. For testing the backend, it is much quicker to use a tool that emulates the browser gets and posts - runs at least 10x quicker! On our websites we find that the vast majority (well over 90%) of the regression problems relate to the server, so we don't even bother regression testing the JavaScript?. Having said that, we are doing more and more with JavaScript? which is why I'm looking complimenting our existing automated regression testing with something like WebDriver?.