entrup
entrup

Reputation: 113

Headless browser automation - Using Selenium with htmlunit driver

I'm looking for a reliable application/tool for automation using headless browser. Looked into htmlunit and httpunit and as far as I understand, they were built in and 'era' way before modern Javascrips became available therefore using them may result some issues.

Then I looked further and apparently it is possible to use Selenium (Which I have used before) in conjunction with the htmlunit driver.

I'm confused. Firstly, why would you use Selenium with htmlunit? Which API's are called during the test, Selenium's of htmunit's? The other thing is why would anybody chose to use htmlunit knowing it does not support modern web sites ?

Thanks in advance.

Upvotes: 2

Views: 1890

Answers (1)

Erki M.
Erki M.

Reputation: 5072

Firstly Selenium with HtmlUnit supports JS at present time, but with some limitations:

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.

Reference

Firstly, why would you use Selenium with htmlunit?

HtmlUnitDriver is by far the fastest implementation of WebDriver. Some times you just don't care about JS execution - there really are still sites like this. There are definitely tons of reasons. For example I have used it to do simple administration tasks.

Which API's are called during the test, Selenium's of htmunit's?

You would be using WebDriver's API that would make calls to the browser.

There is something similar here.

Upvotes: 1

Related Questions