views:

79

answers:

1

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 = webClient.getPage("some url");
String Source = currentPage.asXml();
System.out.println(Source);

This is an easy way to get back the html of the page but would you use the domNode or another way to access the html generated by the javascript?

A: 

Assuming the issue is HTML generated by JavaScript as a result of AJAX calls, have you tried the 'AJAX does not work' section in the HtmlUnit FAQ?

There's also a section in the howtos about how to use HtmlUnit with JavaScript.

If your question isn't answered here, I think we'll need some more specifics to be able to help.

Brabster