mjs
mjs

Reputation: 22379

Get the entire document innerhtml

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 ?

Upvotes: 1

Views: 841

Answers (1)

user452425
user452425

Reputation:

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);
    }
}

Upvotes: 5

Related Questions