I want to read the entire webpage contents including dynamic contents (also HTML contents loaded by JavaScript inside iFrames, nested iFrames). I could simply rebuild the page with printed page contents. I tried using Java here (How to print external script inside iframe using htmlunit?) but did not succeed. Any suggestions?
Asked
Active
Viewed 968 times
2
-
If you know the name of frame then use HtmlPage currentPage = (HtmlPage)webClient.getWebWindowByName("Frame Name").getEnclosedPage(); and see the content of the iframe – Kick Jul 10 '14 at 09:28
-
Thanks @Kick by this way i can get the javascript, How can i get the contens(HTML) loaded by that JavaScript? is there any way? – RDD Jul 10 '14 at 11:32
-
possible duplicate of [Get the changed HTML content after it's updated by Javascript? (htmlunit)](http://stackoverflow.com/questions/17843521/get-the-changed-html-content-after-its-updated-by-javascript-htmlunit) – Mosty Mostacho Jul 10 '14 at 13:24
-
i already checked the question what is mentioned as **Duplicate** here `waitForBackgroundJavaScript()` doesn't work out here for my scenario, i already used `waitForBackgroundJavaScript()` no change. I dont want to wait to specific js to execute, but what i wanted is entire page contents. that is the reason why this question raised. Sorry if its duplicating. – RDD Jul 11 '14 at 04:57
-
1You have to reload the page by using method currentPage.initialize(); – Kick Jul 11 '14 at 07:34
-
@Kick i would like to mention here that `List
fms = page2.getFrames();` `for(FrameWindow f: fms){ System.out.println(f.getEnclosingPage().asXml()); }`i could able to get the iframe contents (including nested iframes),without using `currentPage.initialize()`. But my main intention is to get the contents as it is. Is there any way? – RDD Jul 14 '14 at 11:33