How to see the DOM generated by javascript using htmlunit?

橙三吉。 提交于 2019-12-22 06:58:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!