htmlunit

Error while using JSFUnit/HtmlUnit/CSSParser

We've just recently converted our project to using Maven for builds and dependency management, and after the conversion I'm getting the following exception while trying to run any JSFUnit tests in my project. Exception class=[java.lang.UnsupportedOperationException] com.gargoylesoftware.htmlunit.ScriptException: CSSRule com.steadystate....

HTMLUNIT Facebook javascript warning

Hi I am trying to create simple application that would be able to search people on facebook using given e-mail. I am already able to log into an account using the HTMLunit tool and even create a page, which should throw result of my search. But when I try to print the result as XML the file is missing some blocks of javascript results (...

Java - HtmlUnit - Unable to save HTML to file (in some cases)

Hi all, I am having intermittent issues saving the response HTML in HtmlUnit. Caused by: java.io.IOException: Unable to save file:C:\ccview\PP50773_4.0_walter\TSC_hca\Applications\HCA_J2EE\HCA\target\HtmlUnitTests\single\1\com\pnc\tsc\hca\ui\test\SiteCrawler\crawlSiteAsProvider\10.SiteCrawler.crawl.html at com.pnc.tsc.hca.ui.util.G...

How can I display an HtmlPage object (from HtmlUnit) to be opened in a real browser ?

I am using Htmlunit (browser automation/testing tool) to go through a series of links or perform a set of actions on a page. At some point after this I want to see the resulting page in a browser (internet explorer or firefox etc.) How can I do this. ? Thank you Friends... ...

How to force HtmlUnit to save page?

Hello. I'm using HtmlUnit to click on a HtmlElement that triggers Javascript action: currentPage = ((HtmlElement) currentPage.getByXPath("//*[contains(@onclick, 'check();')]").get(0)).click(); The element is: <a href="#" onclick="check(); return false;"> The page returned is quite similar to the page, containing that element: same ...

HtmlUnit doesn't load externally referenced javascript

I have run into a problem while trying to test a web application with HtmlUnit. Please bear in mind that I haven't used HtmlUnit very long so I might be missing something trivial. For some reason externally referenced javascripts aren't being loaded. When I print the page as xml all i get is this: <script language="javascript" src="url...

How to limit HtmlUnit's history size?

Hello. I'm using HtmlUnit for a parsing job and I've discovered that the memory gets wasted with the WebClient holding the history for each WebWindow. I don't use the history at all and I'd like to disable its management or at least limit its size with 1 or 2. Is that possible? ...

HTMLUnit click() on HtmlElement does not work

I'm trying to get HTMLUnit to perform a click action on a span, which doesn't work for some reason. Please take a peek at the code below. HtmlElement clickable = (HtmlElement) page.getByXPath("//div[10]/div/div/span").get(0); clickable.click(); By doing this I get a really long error message. The interesting bit seems to be the foll...

HtmlUnit click() behaves differently?

Hi, 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 commonly used HtmlAnchor- the refferral information is passed. This is strange since Html...

Exception thrown in YUI: "Sizzle" is not defined!

Hi, We are using HTML Unit v2.6 with Web-Harvest and extended its functionality to create a new element <web session="sess1" browser="firefox2"> <web-getpage url="https://www.linkedin.com/secure/login"/&gt; <web-setinput name="uname">username</web-setinput> <web-setinput name="pwd">password</web-setinput> <web-clickinput name="login"/...

Html, handling a JSON response

I have a page that comes back as an UnexpectedPage in HtmlUnit, the response is JSON. Can I use HTMLUnit to parse this or will I need an additional library? ...

Accessing html generated by Javascript with htmlunit -Java

I am trying to be able to test a website that uses javascript to render most of the HTML. With the HTMLUNIT browser how would you be able to access the html generated by the javascript? I was looking through their documentation but wasn't sure what the best approach might be. WebClient webClient = new WebClient(); HtmlPage currentPage ...

XPath _relative_ to given element in HTMLUnit/Groovy?

Dear All: I would like to evaluate an XPath expression relative to a given element. I have been reading here: http://www.w3schools.com/xpath/default.asp And it seems like one of the syntaxes below should work (esp no leading slash or descendant:) However, none seem to work in HTMLUnit. Any help much appreciated (oh this is a groovy s...

Convert cookies from HTMLUnit to HTTPBuilder?

Dear All: I am doing this (in Groovy): def cookies=webClient.cookieManager.cookies def http=new HTTPBuilder("myurl") http.request(POST) { def headersCookie='' cookies.eachWithIndex() { cookie,i-> if (i>0) { headersCookie+='; ' } headersCookie+=cookie.getName()+"="+cookie.getValue() } headers.'Cookie'=headersCook...

Interfacing HTTPBuilder and HTMLUnit... some code

Ok, this isn't even a question: import com.gargoylesoftware.htmlunit.HttpMethod import com.gargoylesoftware.htmlunit.WebClient import com.gargoylesoftware.htmlunit.WebResponseData import com.gargoylesoftware.htmlunit.WebResponseImpl import com.gargoylesoftware.htmlunit.util.Cookie import com.gargoylesoftware.htmlunit.util.NameValuePair ...

HtmlUnit incomplete fetch

We are trying to "browse" Facebook using HtmlUnit. We are able to login and fetch my "home page" as follows: final URL url = new URL("http://www.facebook.com/login.php"); final HtmlPage loginpage = (HtmlPage)webClient.getPage(url); final HtmlForm form = (HtmlForm)loginpage.getElementById("login_form"); form.getInputByName("email").setV...

htmlunit eofexception

hi, i am using htmlunit to parse a page. but when i tried to get page from url i got an exception, lets have a look on my code: WebClient wc = new WebClient(BrowserVersion.FIREFOX_3); HtmlPage page = wc.getPage(strUrl); when compilet goes to wc.getPage(strUrl) it throws an exception i.e. java.io.EOFException at java.util.zip.G...

Disable automatic Date parsing in HtmlUnit

Having just upgraded to a newer version of HtmlUnit (2.4), I've noticed certain tests are failing when comparing the output of asText. Looking into the differences, this is because dates (present on the page in the format 11/06/2010 00:00z) are being altered in the output to read 2010-06-11. Has anybody else encountered this, and can an...

how to turn off verbose reporting by htmlunit ?

htmlunit reports everything from css, to parsing errors on a page. how to silence this ?? ...

How to make 2 HtmlUnit's WebClients use same cookies?

Hello. If I create 2 WebClients in different threads, how do I make them use the same cookies? ...