33

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?

3
  • 1
    I'm also in a similar situation. I use HTMLUnit but the JS on some sites don't work on it. Did you find an alternative that works? Commented Mar 20, 2013 at 16:59
  • 1
    Clearly no one provided a solution as none is Java based Commented Oct 10, 2013 at 21:06
  • @John.which headless browser did you used in your java Application. Commented Feb 12, 2015 at 4:02

6 Answers 6

10

Nathan Ridley's answer to another similar question is the most complete one I've found so far.

Anyway, if everything fails, you could use a Python or JS alternative, expose its funcionality as a webservice inside your server, and then your Java application could use the headless browser's funcionality through the webservice. It would be a pain to set up, but it may be a viable alternative if nothing else works as desired.

Also, there are some "non-headless" browser wrappers for Java; maybe it would be possible to build a testing solution around those, depending on the requirements.

Sign up to request clarification or add additional context in comments.

Comments

6

Perhaps https://github.com/machinepublishers/jbrowserdriver -- it's headless and written only in Java.

(disclosure: I'm the project owner)

1 Comment

I am currently using JBrowserDriver for one of my projects as well – I can totally recommend it.
4

Take a look at phantom.js. Based on webkit it offers a complete headless browser.

2 Comments

Is there a Java binding for QtWebKit?
3

Rhino + env.js is a full java solution, I've used it, it's not super fast but seems reasonably stable and should give you correct js support.

Comments

1

Replying on an old thread, hoping it might be useful for some.

1) You can use QTJambi's QWebView. It was reasonably fast.

2) JBrowserDriver is another option.

Personally I found QT engine a bit faster.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.