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
2 answers

Please help me to convert this java code to C#

I'm using Htmlunit in my C# project, but I cannot convert this code in java to C# webClient.setWebConnection(new HttpWebConnection(webClient) { public WebResponse getResponse(WebRequestSettings settings) throws IOException { …
0
votes
0 answers

HTMLU form submit giving 200 instead of 302 after first time

I was able to login to a website the first time but for later requests with different credentials, HTMLUnit is giving 200 instead of 302. Any ideas why I'm not getting 302 for successive requests? I believe it's because the server is…
user3487063
  • 3,672
  • 1
  • 17
  • 24
0
votes
1 answer

Is there a Web-UI out there for creating test's using htmlunit?

I want to be able to create the test's inside the Web-UI instead of writing them in code. Also i want to automate the tests and have extensive reporting. I am restricted to htmlunit because the websites i am testing are testable with htmlunit.
s.ijpma
  • 930
  • 1
  • 11
  • 23
0
votes
1 answer

How to extract source from website as we see in inspect element

I would like to extract the complete html source of website as we get it on chrome inspect element. I am trying to the scrap the comments of disqus from…
Arun Kishore
  • 119
  • 3
  • 12
0
votes
1 answer

How do I define a new entity for the HtmlUnit XML parser?

I'm running into an issue with the HtmlUnit parser where I'm trying to grab some XML from a website (using the website's API) do a quick parse of the resulting XML and then save the XML to a file (all within the rights of the API). (sample…
Mark Elliot
  • 75,278
  • 22
  • 140
  • 160
0
votes
1 answer

HtmlUnit gets page error

I am trying to parse this page. http://www.reuters.com/article/2015/07/08/us-china-cybersecurity-idUSKCN0PI09020150708 My code looks like this WebClient webClient = new WebClient(BrowserVersion.CHROME); final HtmlPage page =…
Mark
  • 833
  • 1
  • 9
  • 27
0
votes
0 answers

C#, HtmlUnit JavaScript Support

I am trying to read a test page using NHtmlUnit.WebClient. The page is keep asking to enable JavaScript. Am I missing something? My Code: var client = new NHtmlUnit.WebClient(BrowserVersion.FIREFOX_17); client.Options.JavaScriptEnabled =…
Eyal
  • 4,653
  • 9
  • 40
  • 56
0
votes
1 answer

How to log-in to HTTPS site using htmlUnit?

I tried log-in into HTTPS site with below webclient configuration but seems I'm unable to login. final WebClient webClient = new WebClient(BrowserVersion.getDefault(), "10.52.252.31", 8080); …
0
votes
0 answers

How get content under URL with executed js

I have problems with getting content by URL. I'm using HtmlUnit for parsing an HTML page, but when I run my application I don't get content without filling after executed js. I getting html without needed me content. Who can help me please ? Example…
Vitaliy
  • 59
  • 1
  • 1
  • 5
0
votes
1 answer

HtmlUnit: load elements on AJAX page

I am new to Java and HtmlUnit and am trying to scrape news updates from a page that loads these updates through AJAX calls. Whatever I seem to be doing the updates are not getting loaded. What am I missing? I tried several methods of waiting for the…
user
  • 1
0
votes
2 answers

Using Java how can I lay down text to an HTML textbox that responds to a users keyup action?

I'm building a Java application that interacts with a public website (I do not have access to the server-side). The website's search function is a javascript overlay that dynamically searches on the fly as the user types their search criteria in…
dbconfession
  • 1,147
  • 2
  • 23
  • 36
0
votes
1 answer

HtmlUnitDriver writes logs in my personal Log4J files

I wrote crawlers for 3 different sites and run the crawlers in 3 threads. For each crawler I use single logger. My 'log4j.properties' file looks like: log4j.rootLogger=TRACE, ZDNET, CNET,…
Yakiv Holovko
  • 421
  • 2
  • 5
  • 11
0
votes
0 answers

app:preDexDebug error in Android Studio

I am using Android Studio 1.0.1 and Gradle 1.1.0. The following are my gradle dependencies: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.0.3' compile…
Kevin Richards
  • 570
  • 1
  • 6
  • 23
0
votes
2 answers

com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot call method “appendChild” of null

use htmlunit webclient.getPage() method open login.html, and get html from ajax request result.html, can not execute body.appendChild. Because document.body is null. Example: login.html code:
aduan
  • 27
  • 2
  • 7
0
votes
1 answer

automate a page which was generate some fields by using javascript

i am facing problem in automation, using Htmlunit , a page is generate some value by using javascript , the values a available in inspact element but not in page source code . please give me some suggestion . i am sharing the url where i m…
Prade jo
  • 79
  • 1
  • 9