1

Is there a way to get the innerhtml for the entire page, including html, head, body and so on.

I am only able to call page.getDocument().getBody().getInnerHTML() ... there is no page.getDocument().getInnerHTML() ... shouldn't there be ?

Naftali
  • 144,921
  • 39
  • 244
  • 303
mjs
  • 21,431
  • 31
  • 118
  • 200

1 Answers1

5

There is no such api for Ui4j but you could use the following example to get innerhtml of the entire page.

import static com.ui4j.api.browser.BrowserFactory.getWebKit;

import com.ui4j.api.browser.Page;

public class Main {

    public static void main(String[] args) {
        Page page = getWebKit().navigate("https://bing.com");
        String html = (String) page.executeScript("document.documentElement.innerHTML");
        System.out.println(html);
    }
}
  • Yes, that'll do. Thanks for a great framework! You've done an excellent job. When I get rich I will donate you some money! Tip: You should consider adding a link to this tag on the github page, it's much easier to get proper feedback here. Gitter is hard to navigate. They even override the CTRL + F which does not even search the current page. – mjs Jun 17 '15 at 16:28
  • @Answers and questions popup easier on google as well :) – mjs Jun 17 '15 at 16:29