Headless browser with full javascript support for java

Viewed 25656

I have been using HtmlUnit (the developers did a great job) as an headless browser for some of my previous applications but the javascript support isn't working for some website that my next application will be accessing.

  1. I heard about QtWebKit binding for Python but my application will be in Java or is there a Java binding for WebKit or QtWebKit?

  2. Does anyone know a good headless browser for Java with full javascript support?

6 Answers

How about a built-in webview. I'm not sure about full JS support, but a quick check on the website shows that it can support javascript.

JavaFX WebView: JFX WebView


     private static void initWebView(Stage primaryStage) {
        primaryStage.setTitle("JavaFX WebView Example");
        WebView webView = new WebView();
        //webView.getEngine().load("http://localhost:9009");
        webView.getEngine().loadContent("<h3 id='aa'>JAVA FX WebView, HelloWorld</h3><script>document.getElementById('aa').innerHTML='TEST'</script>");
        webView.getEngine().setJavaScriptEnabled(true);
        VBox vBox = new VBox(webView);
        Scene scene = new Scene(vBox, 960, 600);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

And not related to the question, but also take a look at this: Java-Express or NanoHttpd

The combination may help somebody.

Related