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

How to use htmlunit to page down in facebook

I want to write a crawler to crawl facebook user's post for the purpose to analysis in my research. and i google some referred method, then I use this code to login facebook public class fbcrawler { public static void main(String[] args) throws…
0
votes
1 answer

HtmlUnit - getByXPath with unknown element type

I'm using HtmlUnit to scrape data and I'm getting used to the syntax of XPath. However I've run into a problem. I have an element that I need to pull that varies between pages, sometimes it is a "span" element and sometimes it is an "a" element (a…
quantum285
  • 1,032
  • 2
  • 11
  • 23
0
votes
2 answers

Is it possible to authenticate with HtmlUnit by supplying credentials without dealing with the form?

HtmlUnit communication with the remote server is based on underlying HttpClient, and the latter allows to access web sites which require authentication by providing credentials programmatically. Is it possible to do the same thing with HtmlUnit…
user3930976
  • 161
  • 7
0
votes
1 answer

Download and get the original filename with htmlunit?

I want to create a little application that download and install/upgrade all my windows software. But there are more and more annoying javascript systems. I tried phantomjs, but it can't download. I just tried htmlunit and it works very well to…
baltazer
  • 259
  • 1
  • 5
  • 12
0
votes
1 answer

Not getting the actual content while using HtmlUnit (Response is OK i.e. 200 but the data displayed on webpage is missing in downloaded content)

I am getting the proper htmlContent while using this code for other sites but one site this is not working (see below). Please advise what additional I can do? public class Test3 { public static void main(String[] args) throws…
Shashank
  • 712
  • 15
  • 33
0
votes
1 answer

How htmlUnit deal with unperfected javascript?

I know when we use HTMLUnit, they want exactly perfect javascript running on its Web client. But how do we handle when javascript code like document.createNodeIterator(root,NodeFilter.SHOW_ALL,null,false); It complains "Cannot find function…
Jin Lin
  • 293
  • 1
  • 6
  • 16
0
votes
1 answer

htmlunit not able to load jquery script

I am starting selenium standalone webserver using command java -jar selenium-server-standalone-2.45.0.jar -trustAllSSLCertificates The python code starting client is from selenium import webdriver driver =…
Ayush
  • 909
  • 1
  • 13
  • 32
0
votes
1 answer

HtmlUnit Basic-auth issues

Testing an authenticated REST-api with HtmlUnit seems simple enough. Yet, I can't seem to get it to work. I have the following code: @Test public void testApi() throws IOException { WebClient webClient = new WebClient(); …
TinkerTank
  • 5,685
  • 2
  • 32
  • 41
0
votes
1 answer

html unit load page with modernizr(error)

i have code where i use htmlUnit(2.4 version) to load page which use modernizr. And i catch exception within load page, error move from modernizr. This exception well break all events or this is local error to modernizr and all is ok and all…
Alexdharma
  • 55
  • 1
  • 8
0
votes
3 answers

What is may be reason for charles(http snoffer) does not catch htmlUnit requests?

I have test in which I get page (with help of the htmlUnit) and I may print content of that page, i.e. htmlUnit works correct and fine load my page, but I need to see how that page load all resources (css, js and other resources). My HTTP…
user3569530
  • 193
  • 2
  • 4
  • 13
0
votes
1 answer
0
votes
1 answer

Java HtmlUnit Save a Image and Replace text

I have a list of pictures here: List picsa = (List) myPageww.getByXPath("//img[@alt]"); Then I save picture for picture: for (int i2 = 0; i2 < picsa.size(); i2++) { File imageFile = new…
Patrik
  • 23
  • 6
0
votes
1 answer

HtmlUnit in android error : Execution failed for task : 'app:preDexDebug'

I am trying to perform a click activity on a web page and get the response using HtmlUnit in Android. (I don't want user to be knowing this activity. So, I am trying to use HtmlUnit or Selenium). So, I tried initially to to use WebClient present in…
poovannan
  • 21
  • 1
  • 1
  • 6
0
votes
1 answer

HtmlUnit click() behaves differently?

A question regarding the HtmlUnit java libary: I've created a log on my server, and noticed that the click() method doesn't pass the "referral" information when it is invoked through a "HtmlElement" or "HtmlArea". when invoked through the more…
rhcp2p
  • 1
0
votes
1 answer

HtmlUnit click the submitinput but the page doesn't update

first post. I'm trying to solve an HtmlUnit problem I'm having using the dvwa. When I try to click the submit button in the doFormPost section of the code it is showing me the old page with the text field still full rather than the new page. I have…
1 2 3
99
100