开发者

getting the raw source from Firefox with javascript

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.

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>

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 request the same page for the source, and just check document.documentElement.outerHTML || document.documentElement.innerHTML for the current state's source.


Have you tried something as simple as

document.documentElement.innerHTML;


Since you are also using selenium, you can use selenium.getHTMLSource(). This will return the whole source page contents.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜