I am using Htmlunit (browser automation/testing tool) to go through a series of links or perform a set of actions on a page. At some point after this I want to see the resulting page in a browser (internet explorer or firefox etc.) How can I do this. ? Thank you Friends...
views:
106answers:
2
A:
I hope I got you correctly.
This is my solution:
WebClient wc = new WebClient();
HtmlPage page = wc.getPage("http://stackoverflow.com/");
//Get page as Html
String htmlBody = page.getWebResponse().getContentAsString();
//Save the response in a file
String filePath = "c:/temp/out.html";
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(filePath)));
bw.write(htmlBody);
bw.close();
//Open the page with a browser
Runtime.getRuntime().exec("C:/Program Files/Internet Explorer/iexplore.exe " + filePath);
Hope that helps.
Avi Y
2010-05-06 06:46:40
A:
You can also use htmlPage.save(File) (which automatically saves images) before executing real browser
Ahmed Ashour
2010-05-08 14:42:51