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
6
votes
1 answer

Exception from call site #4 bootstrap method. Code doesn't work in Android studio, but works in Eclipse

I am writing a code to login onto a website using HtmlUnit. It has been working in eclipse, but now I decided to move it into Android studio use it in an app. I have 2 questions. Why HtmlUnit requires API 26, which is very high for technology now…
6
votes
2 answers

Java HtmlUnit - can't login to wordpress

I'm trying to use HtmlUnit to login to my local wordpress website but it seems to have a cookies issue. That's that begining of the code: WebClient webClient = new WebClient(); HtmlPage loginPage =…
Ron
  • 393
  • 1
  • 4
  • 13
6
votes
2 answers

Htmlunit get form input by ID instead of name

I have a form that has multiple rows and similar inputs. They have different IDs but the same name.
arsarc
  • 443
  • 1
  • 9
  • 22
6
votes
1 answer

What is the exactly use of Robot framework?

I'm fascinated towards robots. You know usually it creates our work easy and for web you don't need to go anywhere on links once our robots is initialized on web server. Let's come to our main question: What exactly is the use of Robot Framework ..…
pankaj padiya
  • 133
  • 2
  • 7
6
votes
1 answer

Can I configure HTMLUnit to only run specific javascript processes and not the whole thing?

I'm looking to gather information from a set of web pages that are all very similarly formatted. I need some information that is loaded onto the page by Javascript after opening. It seems that HTMLUnit is a pretty common tool to do this, so that's…
Sam Bobel
  • 1,784
  • 1
  • 15
  • 26
6
votes
1 answer

How to see the DOM generated by javascript using htmlunit?

I have got an html page in which the UI is generated using javascript.I am interested in a form which is visible when the page is inspected using developer tools but not in html source. In htmlunit i tried to wait for the javascript to execute and…
joseph
  • 940
  • 10
  • 19
6
votes
5 answers

HTMLUnit not working with AngularJS

According to https://developers.google.com/webmasters/ajax-crawling/docs/html-snapshot, with HtmlUnit (2.13) I am trying to create a snapshot for a webpage using AngularJS (1.2.1). My Java code is: WebClient webClient = new…
cnmuc
  • 6,025
  • 2
  • 24
  • 29
6
votes
2 answers

how to get text between a specific span with HtmlUnit

I'm new to HtmlUnit and I'm not even sure if it is the right tool for my project. I'm trying to parse a website and extract the values I need from it. I need to get the value "07:05" from this, 07:05 I know that I…
ManahManah
  • 263
  • 2
  • 5
  • 17
6
votes
2 answers

OutOfMemoryError while using HtmlUnit for scraping

I am using HtmlUnit to login on to a site and then download data from the table When I run my code is is causing java.lang.OutOfMemoryError And could not run further. Following is my code: WebClient webClient = new…
Kunal Kishore
  • 235
  • 2
  • 11
6
votes
2 answers

Selenium HtmlUnitDriver hangs randomly in random places

I used SeleniumHQ to record my actions and then exported them to Java Unity WebDrive. Then I edited exported code and added many small extra things like looping over array, time-stamps, etc. My code does following: Log into my site. Goto my…
Rohit Malish
  • 3,209
  • 12
  • 49
  • 67
6
votes
1 answer

HtmlUnit driver doesn't execute JavaScript

I am new to HtmlUnit and am having some trouble with logging in. Below code works perfectly fine for FireFoxDriver but fails for HtmlUnitDriver. The problem is it not executing javascript while clicking on "Login" link; site url for html viewing:…
noname.404
  • 335
  • 3
  • 11
6
votes
2 answers

HtmlUnit not able to login It returns same page after form submit

I am trying to login on this a site with the help of HtmlUnit but after clicking login it is returning the same page with the input fields filled by values I put unable to login please suggest me a solution. I am trying following code …
Kunal Kishore
  • 235
  • 2
  • 11
6
votes
1 answer

Skip particular Javascript execution in HTML unit

I have a URL. I want to fetch Page-Source of the URL after executing Java Scripts. Fetch Page source using HtmlUnit : URL got stuck Initially I suspected that it is due to system resource and High CPU usage, that the URL is getting stuck. Then I…
Learn More
  • 1,535
  • 4
  • 29
  • 51
6
votes
1 answer

Java HtmlUnit form redirect issues

I'm working in an online banking application. I would like to login to retrieve the balance. I've been doing some research, and I found some useful HtmlUnit code from other posts. However, I'm stuck handling page's redirect. The path is as follows…
Rasel Id
  • 69
  • 1
  • 4
5
votes
3 answers

Reading all response headers using HtmlUnit

I was trying to use http unit to read response header for my application - WebClient webClient = new WebClient(); WebClient.setThrowExceptionOnScriptError(false); HtmlPage currentPage = webClient.getPage("http://myapp.com"); WebResponse response =…
Tarun
  • 3,456
  • 10
  • 48
  • 82