Getting source from Firefox using javascript

I am writing a program to check 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 register the HTML code generated by the page. Now accessing the HTML DOM is easy, but I am having real problems finding the source path. Thanks.

I must repeat that I am not looking for a DOM, but the source is unmodified source code. As can be seen from the image of the right mouse button → view. In particular, if <Html> <body> <table> <tr> <td> fear the table data </td> </table>

is real HTML. Calls document.documentElement.outerHTML || document.documentElement.innerHTML 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>

+6
source share
3 answers

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

+2
source

Have you tried something simple like

 document.documentElement.innerHTML; 
-1
source

Since you also use selenium, you can use selenium.getHTMLSource() . This will return the contents of the entire source page.

-1
source

Source: https://habr.com/ru/post/888472/


All Articles