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

Submitting form with HtmlUnit

Is there someone that know how to submit this form with HtmlUnit, Java?
EspenG
  • 537
  • 3
  • 10
  • 20
0
votes
4 answers

Javascript HtmlUnit

I have a submit button that I can't click on.. I have tried this: page = (HtmlPage) form.getInputByValue("Send SMS").click(); but…
EspenG
  • 537
  • 3
  • 10
  • 20
0
votes
1 answer

How do I fix this BrowserVersion for HTMLUnit?

I'm trying to scrape a CloudFlare-protected website using HTMLUnit and to do that I need to add the cookie and user agent. I've already added the cookie using the CookieManager, but I'm having trouble setting the user agent with the BrowserVersion…
silverAndroid
  • 960
  • 3
  • 11
  • 29
0
votes
1 answer

Information on Server Is Not Updated

I've been testing HtmlUnit with a few sites; in all these sites,they have elements such as a radio button or checkbox that when you click, then your profile on that site is updated; you don't need to submit a form or anything. But when I take the…
user1888243
  • 2,591
  • 9
  • 32
  • 44
0
votes
1 answer

Text set by HtmlUnit is not recognized by web page

I am trying to use HtmlUnit to fill a form which puts some conditions on its inputs (for example the value of one input has to be at least 3 characters long). I use HtmlInput's setValueAttribute method to fill the form's, but when it clicks on the…
XaitormanX
  • 891
  • 1
  • 11
  • 22
0
votes
4 answers

org.openqa.selenium.NoSuchElementException: Unable to locate a node using HtmlunitDriver/Phantomjs

I am using HTMLUnitDriver. It is unable to locate the xpaths and css selectors WebDriver d=new HtmlUnitDriver(); WebDriverWait wait = new WebDriverWait(d, 10); // d.manage().timeouts().implicitlyWait(20,…
0
votes
2 answers

HTMLUnit Java OutofMemory Heap Space Exception

I have been trying to solve Java Heap Space OutOfMemory Exception thrown from my program that uses HTMLUnit API to visit pages (the pages have extensive javascripts so i choosed to use HTMLUnit for this). The program runs for about 1 hour and the…
Aryal Sumu
  • 53
  • 7
0
votes
2 answers

Download wav files in HTMLUnit

before someone tells me that there's already this question here, i must say i've tried basically every single example i've found. The url i'm trying to download has a type of 'audio/wav', embedded in a video tag, or at least this is what i see when…
Bruno Brs
  • 673
  • 1
  • 6
  • 23
0
votes
1 answer

HtmlUnitDriver browser emulate mode

I have created a simple factory method that creates a HtmlUnitDriver in a specified mode. For example public static HtmlUnitDriver createHtmlUnitDriver(String browserMode) { switch(browserMode.toLowerCase()) { case "chrome": …
PDStat
  • 5,513
  • 10
  • 51
  • 86
0
votes
1 answer

Set the value for an hidden form element

i am using HTMLUNit to set the value of a form hidden element as below. HtmlHiddenInput hidden = (HtmlHiddenInput) page.get("someid"); hidden.setValueAttribute(seriesName); But this does not work as expected and throw an…
rakeeee
  • 973
  • 4
  • 19
  • 44
0
votes
0 answers

How to Timeout Page Using Websockets in HtmlUnit

Sample URL: http://www.heatpressnation.com/sublimation-printers-ink.html Websocket URL: https://us22.zopim.com When calling that page, HtmlUnit never completes because of the websocket connection to zopim.com. How can I force the page to finish…
Vaibhav
  • 2,073
  • 4
  • 23
  • 26
0
votes
1 answer

Sending a POST request with multiple keywords as parameters using HTMLUnit

I am sending a POST request using HTMLUnit that sends keywords as parameters. An example of the URL is: website.com/foo/bar/api?keywords=word1,word2,word3&language=en The problem is my application is dynamically picking these words and the amount…
GreenGodot
  • 6,030
  • 10
  • 37
  • 66
0
votes
1 answer

Java HtmlUnit 301 status code on a working page

When trying to load a page through htmlUnit I always get a 301 error, even though the exact same page loads fine in a browser. The code giving me the error is public String getPage(String url) { try { WebClient webClient = new…
0
votes
1 answer

Java HtmlUnit failing to find elements on a page

I've used HtmlUnit to send a login through a form before and I've been trying to do it again but just can't get it to work on this site: http://www.runescape.com/companion/comapp.ws Using the code final HtmlPage page1 =…
user2288508
  • 45
  • 3
  • 9
0
votes
0 answers

HtmlUnit: trying to scrape AngularJS webpage

I'm trying to use HtmlUnit to scrape the content of a Website. I am able to programmatically login to my account, but most of the content on the client-side is generated using Javascript (Angular JS). So my questions are: Can we use HTMLUnit to…
user5045166