htmlunit

How to get a Select/Options List if I don't have a Form in the DOM

Hi. Got the following chunk of Html... <div style="visibility:visible" id="stateProvinceDiv"> <div id="stateUSALabelDiv"><label for="stateUSAIdSelect">Find Your Bookstore</label></div> &nbsp;<select size="1" id="stateUSAIdSelect" name="stateUSAId"> <option>Loading...</option> </select> </div> The page/content for the ...

Java: Can HmtlUnit return the JavaScript redirect URL?

When HtmlUnit hits a JavaScript redirect, it will run through it without skipping a beat. If it hits one JavaScript redirect after another, it's impossible to tell which URLs it ran through -- only where it stopped. Is there a way around this? I would like to know the URLs it redirected through before it hit an end. I can disable norm...

Can HtmlUnit handle JavaScript redirects?

Instead of automatically following JavaScript redirects, can I force HtmlUnit to return the URL the JavaScript wants to redirect me to? // context: If there's 5 JavaScript redirects in a row, I can only see the URL of the page where it stopped - I can't view the 5 URLs it ran through. Perhaps I can hook up the logger to a callback met...

htmlunit javascript question..

hi.. looked through the 'net, as well as other replies on here.. i've got something that looks like the following html: var langId = '-1'; var demoKey = 'null'; var extraParams = 'null'; // only used for User Registration page var multiSelect = false; and function onCampusSelect_USA() { if($('campusUSAIdSelect').value == ''){cle...

Java: HtmlUnit crashes upon JavaScript error

Occasionally HtmlUnit stumbles upon a JavaScript error so grave it brings down the entire application. Here's the long stacktrace it spits out: http://pastie.org/806625 I have already set the webClient not to throw exceptions on script errors, but this doesn't seem to be helping: webClient.setThrowExceptionOnScriptError(false); Can ...

Screen scraping with Python

Does Python have screen scraping libraries that offer JavaScript support? I've been using pycurl for simple HTML requests, and Java's HtmlUnit for more complicated requests requiring JavaScript support. Ideally I would like to be able to do everything from Python, but I haven't come across any libraries that would allow me to do it. Do...

How to save HtmlUnit cookies to a file?

Hello. I'd like to save HtmlUnit cookies to a file and on next run load them from that one. How can I do that? Thanks. ...

How to post HEAD request with HtmlUnit?

Hello. How can I use existing WebClient to post a custom HEAD request? I.e. there is no form on the page, I want to set request properties manually. ...

How can I tell HtmlUnit's WebClient to download images and css?

Hello. How can I make WebClient download external css stylesheets and image bodies just like a usual web browser does? ...

Strange HtmlUnit behavior (bug?)

Hello. Take a look at this: WebClient client = new WebClient(); WebRequestSettings wrs = new WebRequestSettings(new URL("http://stackoverflow.com/ping/?what-the-duck?"), HttpMethod.HEAD); client.getPage(wrs); Running this code results in throwing FileNotFoundException, because HTTP Status code on the page is 404 and getting the same p...

Simultaneous XMLHttpRequests using HTMLUnit 2.7

I just updated our HTMLUnit version to 2.7 (from 2.3) and I'm seeing spurious errors in one of my tests. It appears that HTMLUnit is making one XMLHttpRequest at a time, no matter what I do. Note that this isn't an issue of single-threading the test with with the XMLHttpRequests -- I've confirmed that the test itself continues after I s...

How do I get code coverage report?

I'm using HTML unit test for presentation tier testing , is there any mechanism/framework available to find code coverage report? ...

HtmlUnit HtmlImageInput.click() not working?

Hi all, I am kinda new to HtmlUnit and am having some trouble getting a form to submit with HtmlImageInput.click(). When I call the method, nothing seems to happen, no form submission, no round trip to the server, or anything, as far as I can tell. The method returns immediately, returning the current page. There's no Javascript event ...

How can I use SOCKS with HtmlUnit?

Hello. Is it possible to use HtmlUnit through SOCKS proxy? Could anyone please provide a code sample? ==== So I've dug through webclient sources, here's the best way I can think of: Subclass MultiThreadedHttpConnectionManager so that it allows setting SOCKS info and if it is set, before returning a Connection, sets SOCKS parameters ...

.net equivalent of htmlunit?

Does anybody know if there is a .net equivalent of htmlunit or similar library? I've heard that people have used IKVM to convert the htmlunit library. But I have also heard that the converted code is slow. Requirements: Headless browser Support javascript Handle cookies .Net ...

HtmlUnit to login (post form) to csrf enable website

I am posting a form using HTMLUnit webClient by putting the username and password but it could not logging me in. When i research then found out that they have enable csrf on post request so native web browser is required. Is there any way to login (post form) in csrf enable website using HTMLUnit or any other tool in Java or it is impos...

HtmlUnit - dynamically loaded JavaScript not running

I'm trying to write some automated tests of a website using HtmlUnit. Our web pages load two JavaScripts, one of which then loads several other JavaScripts dynamically into the DOM. These JavaScripts then do some UI initialization. My problem is that HtmlUnit updates the DOM with the new JavaScripts, but does not then seem to run those J...

Using getAnchorByText, but want the 2nd of 2 links on the page

On my page, there are 2 links with the same anchor text. I am using HtmlUnit to get the link by the anchor text. The call to: page.getAnchorByText("1"); Seems to always get the first occurrance, is there a way to get the 2nd occurance if there are 2 links? ...

Xpath to get the 2nd url with the matching text in the href tag

A html page has paging links, 1 set at the top of the page and another on the bottom of the page. Using HtmlUnit, I am currently getting the HtmlAnchor on the page using getByAnchorText("1"); There is a problem in some of the links on the top, so I want to reference the bottom links using XPath. nextPageAnchor = (HtmlAnchor) page.getB...

Does calling a click method effect the HtmlPage object if there is a 404?

If I call a click method on a HtmlAnchor, and say that page returns a 404, does that mean the HtmlPage will effect, so searching for another link on the page will result in an error because the page's HTML is the error page (assuming the link is NOT on the error page). Can I manually set the page's HTML, and then locate and click on lin...