问题
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
回答1:
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>
来源:https://stackoverflow.com/questions/21014517/how-to-see-the-dom-generated-by-javascript-using-htmlunit