Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 368
joseph Avatar asked Jan 09 '14 07:01

joseph


1 Answers

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>
like image 168
Archimedes Trajano Avatar answered Nov 03 '22 21:11

Archimedes Trajano