I am writing an application that uses HtmlUnit to screen scrape some data. The logic of which fields come from which parts of the page, and the XPath to retrieve them is getting a bit complicated, so before I refactor I want to write some simple unit tests. I have used the 'page.asXml()' method to get the page XML and save that as a file in my test resources folder, but how can I load it back in as an HtmlPage?
eg
HtmlPage page = webClient.getPage(url);
System.out.println(page.asXml());
Now in my unit test I want to do the equivalent of:
HtmlPage page = new HtmlPage(myXmlTestFile);
But I can't seem to find anything that will do this. Any ideas?