如何查看使用htmlunit由javascript生成的DOM? [英] How to see the DOM generated by javascript using htmlunit?

查看:79
本文介绍了如何查看使用htmlunit由javascript生成的DOM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML页面,其中使用javascript生成了UI。我对使用开发人员工具检查该页面时可见但不在html源中可见的表单感兴趣。
在htmlunit中,我试图等待javascript执行,然后将其打印为Xml,但看不到DOM元素!我该怎么办?请帮助

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

推荐答案

HtmlPage.getDocumentElement()。asXml()

可以使用

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

on

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

将显示

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

这篇关于如何查看使用htmlunit由javascript生成的DOM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆