使用javascript从Firefox获取原始源代码 [英] getting the raw source from Firefox with javascript

查看:96
本文介绍了使用javascript从Firefox获取原始源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个程序来验证远程服务器上的网页。它使用selenium RC通过一系列测试来运行Firefox,因此我可以调用任意javascript。当出现故障时,我想记录页面生成的HTML。现在可以轻松访问DOM HTML,但是我找到了一种获取源代码的方法。谢谢。

I am writing a program to validate web pages on a remote server. It uses selenium RC to run Firefox with a battery of tests, so I can call arbitrary javascript. When there is a failure I would like to log the page's generated HTML. Now getting access to the DOM HTML is easy, But I am having real trouble finding a way to get at the source. Thanks.

我应该重申,我不是在寻找DOM,而是原始的未经修改的源代码。通过右键单击 - >查看页面源可以看到。具体来说,如果
< Html>
< body>
< table>
< tr>
< td>
担心表格数据
< / td>
< / table>

I should reiterate that I am not looking for the DOM, but the original unmodified source code. As can be seen through Right click -> view page source. Specifically if <Html> <body> <table> <tr> <td> fear the table data </td> </table>

是真正的HTML。调用 document.documentElement.outerHTML || document.documentElement.innerHTML selenium.getHTMLSource()将导致< head> < /头><身体GT; <表> < TBODY>< TR> < TD>担心表数据< / td> < / TR>< / tbody的>< /表> < / body>

is the real HTML. Calls to document.documentElement.outerHTML || document.documentElement.innerHTML and selenium.getHTMLSource() will result in <head> </head><body> <table> <tbody><tr> <td> fear the table data </td> </tr></tbody></table> </body>

推荐答案

XHR请求源的同一页面,然后检查 document.documentElement.outerHTML || document.documentElement.innerHTML 表示当前状态的来源。

XHR request the same page for the source, and just check document.documentElement.outerHTML || document.documentElement.innerHTML for the current state's source.

这篇关于使用javascript从Firefox获取原始源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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