joseph
joseph

Reputation: 1008

How to see the DOM generated by javascript using htmlunit?

I have got an html page in which the UI is generated using javascript.I am interested in a form which is visible when the page is inspected using developer tools but not in html source. In htmlunit i tried to wait for the javascript to execute and then print it as Xml but DOM elements are not seen!!How can i do this??Please help

Upvotes: 6

Views: 1694

Answers (1)

Archimedes Trajano
Archimedes Trajano

Reputation: 41530

HtmlPage.getDocumentElement().asXml()

This can be tested using

System.out.println(page.getDocumentElement().asXml());

on

<html>
<body>
<div id="lj">
</div>
<script>
document.getElementById("lj").innerHTML = "Foo";
</script>
</body>
</html>

will show

<div id="lj">
Foo
</div>

Upvotes: 2

Related Questions