Questions tagged [htmlunit]

HtmlUnit is a "headless browser". Which means that there is no browser GUI and it does no rendering. Though it has a CSS and JS engine to simulate a real browser. Primary purpose is testing and information extraction.

HtmlUnit is a "GUI-Less browser for Java programs". It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc... just like you do in your "normal" browser.

It has fairly good JavaScript support (which is constantly improving) and is able to work even with quite complex AJAX libraries, simulating Chrome, Firefox or Internet Explorer depending on the configuration used.

It is typically used for testing purposes or to retrieve information from web sites.

HtmlUnit is not a generic unit testing framework. It is specifically a way to simulate a browser for testing purposes and is intended to be used within another testing framework such as JUnit or TestNG.

HtmlUnit is used as the underlying "browser" by different Open Source tools like Canoo WebTest, JWebUnit, Selenium WebDriver, JSFUnit, Celerity, ...

HtmlUnit was originally written by Mike Bowler of Gargoyle Software and is released under the Apache 2 license.

Useful links

1835 questions
4
votes
3 answers

how to turn off verbose reporting by htmlunit?

htmlunit reports everything from css, to parsing errors on a page. how to silence this ??
KJW
  • 15,035
  • 47
  • 137
  • 243
4
votes
1 answer

Java HtmlUnit java.lang.NoClassDefFoundError: org/w3c/css/sac/ErrorHandler stack overflow

Trying to do the tutorial examples on HtmlUnit so I can connect to web pages through Java. I am getting the following error when I try to run it: java.lang.NoClassDefFoundError: org/w3c/css/sac/ErrorHandler stack overflow Here is my code: package…
JakeT
  • 41
  • 1
  • 2
4
votes
2 answers

HtmlUnit not creating HtmlPage object

I'm very new to HtmlUnit and I'm trying to scrape a website that uses Javascript to edit the code. I heard HtmlUnit was the best way to go as it returns the final code using a headless browser. However as you will see I cannot even get past…
quantum285
  • 1,032
  • 2
  • 11
  • 23
4
votes
2 answers

XPath _relative_ to given element in HTMLUnit/Groovy?

I would like to evaluate an XPath expression relative to a given element. I have been reading here: http://www.w3schools.com/xpath/default.asp And it seems like one of the syntaxes below should work (esp no leading slash or descendant:) However,…
Миша Кошелев
  • 1,483
  • 1
  • 24
  • 41
4
votes
2 answers

How to limit HtmlUnit's history size?

I'm using HtmlUnit for a parsing job and I've discovered that the memory gets wasted with the WebClient holding the history for each WebWindow. I don't use the history at all and I'd like to disable its management or at least limit its size with 1…
htf
  • 1,503
  • 4
  • 15
  • 21
4
votes
1 answer

HTMLUnit temp files not found

I am using this code to read from an URL and the code is giving me this error: Exception in thread "main" java.io.FileNotFoundException:…
SidML
  • 183
  • 1
  • 7
4
votes
1 answer

Submitting a form using html unit

I want to login https://pacer.login.uscourts.gov/csologin/login.jsf. i have used html unit for submitting a login form. here is my code: public void submittingForm() throws Exception { final WebClient webClient = new WebClient(); // Get…
4
votes
2 answers

Xpath to get the 2nd url with the matching text in the href tag

A html page has paging links, 1 set at the top of the page and another on the bottom of the page. Using HtmlUnit, I am currently getting the HtmlAnchor on the page using getByAnchorText("1"); There is a problem in some of the links on the top, so I…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
4
votes
1 answer

htmlunit : An invalid or illegal selector was specified

I am trying to simulate the login with htmlunit. Although I wrote my code according to the examples, I have encountered a boring problem. Below are some message I have picked up from the console. runtimeError: message=[An invalid or illegal selector…
user3761116
  • 152
  • 1
  • 4
4
votes
1 answer

FileUpload with HtmlUnit doesn't fire fileUploadListener-Event (Primefaces auto upload)

I'm trying to automate a file-upload with WebDriver. It works fine for ChromeDriver and FirefoxDriver, but refuses to work for HTMLUnit. I've already read Using Webdriver for PrimeFaces file…
Matthias
  • 318
  • 1
  • 7
4
votes
2 answers

Using HtmlUnit/HttpUnit under GAE

I'm trying to load the DOM of web pages in my application (running under Google App Engine), using HtmlUnit, HttpUnit or any similar library. Did anyone manage to do something similar?
Gilad Bar Orion
  • 543
  • 6
  • 14
4
votes
3 answers

Get all HTTP requests with WebDriver/HtmlUnit

I need to verify a request for testing via WebDriver. Unfortunately there is no easy way to do this as there is no native support. It seems like I should be able to use HtmlUnit to get requests but I have only been able to get responses. Is there a…
johnsoe
  • 664
  • 1
  • 5
  • 13
4
votes
3 answers

is it possible to load a HtmlPage from a string?

I have stored a webpage's HTML in the database. I want to take advantage of HtmlUnit's ability to find/reference DOM elements. Is it possible to load the HtmlPage object from a string (via a database column)?
mrblah
  • 99,669
  • 140
  • 310
  • 420
4
votes
2 answers

htmlunit execute page javascript

I am trying get the content of a web page after the execution of the javascript code in the page. Let's suppose for example that I have the following page : test: