How Stable and Fast HtmlUnit

I am updating from selenium-1 to selenium-2 and testing the new HtmlUnit driver. I tried several basic tests (open the page, get_text, ..), and it seems that

  • Extremely slow (I think the remote chrome / FF drivers are faster than him)
  • Extremely unstable (opening yahoo.com using HTMLUNIT and HTMLUNITWITHJS led to errors)

I would be very happy to hear your impression of this. Hope you find that I'm wrong (I can live without (1) speed, but (2) stability is critical)? is there a comparison of the speed of HtmlUnit with selenium drivers?

+7
source share
2 answers

In my experience, HtmlUnit is much faster than Firefox, noticeably faster than chrome (the fastest browser with selenium 2.0rc2). HtmlUnit does not require loading external resources, and if you use it without BrowserVersion, javascript is disabled by default:

WebDriver driver = new HtmlUnitDriver(); 

But if you switch to the browser version, then it will be turned on, but it will work more slowly, since it will load javascript files:

 WebDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6); 

As they say, javascript does not match real browsers. The homepage of Google and Yahoo is not working properly. Modern browsers are tolerant of certain javascript errors (exploits / hacks), but HtmlUnit is not.

I usually use HtmlUnitDriver on pages / streams that do not require heavy javascript, and I just need to check the elements / data existing on the pages (which are not dynamically loaded).

+7
source

You can also enable javascript as follows.

((HtmlUnitDriver)). SetJavascriptEnabled (true);

+1
source

All Articles