3

I am looking a way to save the current DOM state of the webpage into a separate .html/.mht file with all images, JavaScript and CSS files included.

I know driver. PageSource / driver.getPageSource() allows to get the current DOM state, but how can I save all statically/dynamically referenced images, JavaScript files, CSS files and other assets?

Example, why I need this:

For instance, the web application is a Single Page Application, based on KnockoutJS framework.
When an error occurs during the test execution, I would like to have the HTML page which has all dynamically generated content in order to investigate the problem.

When I perform a static HTTP download -- it always gives me the project login page, instead of the current opened documents.

Dmytro Zharii
  • 291
  • 4
  • 14
  • i think that this would be a custom solution, much like the `Save As... -> Webpage, Complete` functionality on Chrome. As far as I know, there is no solution to do this. Simply find each `` `` and `` and just save those files – ddavison Jan 02 '14 at 16:00
  • Dmytro, were you able to solve this? I require this for my usecase – contactabbas Oct 28 '14 at 10:55
  • Some JavaScript magic will do the trick http://stackoverflow.com/questions/22368613/how-to-save-page-in-firefox-chrome-phantomjs-with-selenium-webdriver/27467317#27467317 – Toolkit Dec 14 '14 at 07:41

1 Answers1

-3

Ok I think you might be thinking about the issue in a wrong way. Downloading the whole thing is not the answer to your problem.

Selenium is a very good tool for understanding flaws in the software from the user perspective based on the stories and requirements but when it comes to the underlying issues and it's investigation you are going to need the right tool for job.

luckily if you are using KO and MVVM pattern you are benefiting from a code structure that lends itself well to unit testing which is exactly what you need in order to investigate what has gone wrong and not the snapshot code of the application.

if for all methods in your view model (or at least the important ones) you write good unit test coverage (jasmine.js is so easy to use) you can just run your test suite and when a selenium test fails then see which unit tests are also failing and that will get you a lot quicker to the solution.

here are some resources for you to look at:

KnockoutJS and Testing

http://machadogj.com/2011/10/unit-testing-wit-knockout-js-with-tdd.html

makeitmorehuman
  • 11,287
  • 3
  • 52
  • 76