Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>

like image 817
Mark Avatar asked May 18 '11 20:05

Mark


1 Answers

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

like image 119
Eli Grey Avatar answered Oct 18 '22 10:10

Eli Grey