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

java htmlunit button click doesnt work in for loop return NullPointerException

for(int i=0;i<=5;i++){ HtmlPage currentPage = (HtmlPage)client.getPage("http:// http://testsite.com "); HtmlForm form = (HtmlForm) currentPage.getElementById("kelimeAraID"); HtmlButton button = (HtmlButton)…
0
votes
1 answer

HtmlUnit thorw error "define is not defined"

I tried to load simple page using HTMLUnit it is throwing below error Enclosed exception: net.sourceforge.htmlunit.corejs.javascript.EcmaError: ReferenceError: "define" is not defined. I think this is problem because of ECMA6 ? But I am not able…
Rahul Shukla
  • 505
  • 7
  • 20
0
votes
0 answers

HtmlUnit not working via LAN

I'm using HtmlUnit to navigate site and get some info. The code perfectly work at home via wi-fi router, but can't access internet at office (via LAN) without any Exception, it's just nothing happen. This is part of my code: public class WebParser…
0
votes
0 answers

HTMLUnit/Java - Form is not found

I have very recently started using HTMLUnit. My goal is to automate logging into another website (I am using this as my guide). However, my code is unable to find the form (of the website I am trying to log into) by ID, even though I gave it the…
0
votes
2 answers

window.setTimeout is causing htmlunit to run slow

I have a web page where I have implemented a window.setTimeout in javascript. The thing is I am implementing a timer which pops up a message when that time has expired. This value is stored in the cookie. So, when the page loads up, I configure the…
divinedragon
  • 5,105
  • 13
  • 50
  • 97
0
votes
0 answers

How to get the textarea element and its content in HtmlUnit?

I am trying to obtain the content of a element using java and htmlunit but getting some ClassCastException error. Not sure if I am getting this the correct way. Exception: java.lang.ClassCastException: com.gargoylesoftware.htmlunit.html.HtmlMeta…
Nital
  • 5,784
  • 26
  • 103
  • 195
0
votes
1 answer

i/o intensive java application speeds up on docker on limited resources

I've got an I/O-intensive java tomcat application where I want to execute htmlunit-tests in a more modern, clustered environment. I therefore also took docker into account which may provide cool features by applying swarm and so on. The tests runs…
ferdy
  • 7,366
  • 3
  • 35
  • 46
0
votes
2 answers

app engine support for HtmlUnit

I'm trying to use HtmlUnit to get DOM of webpages. However, when I try to run this code on app engine development server (using the eclipse plugin): WebClient wc=new WebClient(); HtmlPage page1= wc.getPage("http://ww.google.com/"); I get this…
0
votes
1 answer

HtmlUnit: how to extract elements from tag page

I'm trying to automate my routine job. I could see the web shows a lot of elements when inspect a element, but when I click view page source I see only Gibberish words. I want to extract the page element can someone help me. My page sample is…
Dilli
  • 13
  • 6
0
votes
1 answer

How to get td text value of nested table by XPath

I have this table inside another table inside another table and so on. And then I want to get the text value of the td element with a specific class. The XML ....

Number: xyz I…
MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125
0
votes
1 answer

Monitoring chat rooms with HtmlUnit, is it possible?

I started with HtmlUnit recently, had some success scraping some pages and interacting with it, really powerful tool... But, as far as my knowledge goes, I just retrieved a page with a certain state... My next step is to make HtmlUnit to read the…
Tacca
  • 149
  • 14
0
votes
1 answer

HtmlUnit not running all HTTP Requests in parallel ??

I use HtmlUnit to create Page Snapshots, to be used for various purposes. What i found out was that HtmlUnit is not sending requests in parallel, as it happens in browser (6 parallel requests at a time). Can somebody help me with this ? My code :- …
user3279692
  • 329
  • 2
  • 13
0
votes
1 answer

Geb functional web tests + cookies

I've been having issues with testing my Grails application's authentication. It appears that the browser won't accept cookies, so I created a simple grails application as a test. Welcome to Grails
Steven Sproat
  • 4,398
  • 4
  • 27
  • 40
0
votes
1 answer

Scraping data from web page using Jsoup

I am new to Jsoup and I need to scrape the data from below webpage. Here is the link. Webpage
user6325753
  • 585
  • 4
  • 10
  • 33
0
votes
1 answer

use htmlunit how to get modal dialog element

I want to go to the website https://console.mobra.in by htmlunit tool, but login input in the modal box, how to get username input element or login form?
penuel
  • 183
  • 1
  • 3
  • 10