I’m currently working on a JavaFX application that requires the ability to render websites in headless mode while executing JavaScript. At the moment, I’m utilizing JBrowserDriver, and although it performs adequately, I’ve encountered issues with certain websites that don’t render correctly, particularly those utilizing advanced CSS features like flexbox. Additionally, I often need to access specific properties of HTML elements, making accurate rendering vital for my project. While I am aware that I can run Chrome or Firefox in headless mode, this would necessitate including these browsers as dependencies on user machines, which I’d like to avoid. I am searching for a browser solution that can be packaged with my application but haven’t found a suitable match. Can anyone recommend other viable options? Thank you!
You could try HtmlUnit, a pure Java framework that offers headless browser capabilities without needing external dependencies. It supports JavaScript execution and has a decent HTML/CSS rendering engine, though advanced CSS might still be challenging.
Another option is JavaFX WebView, which can act as a lightweight web engine. However, its JavaScript and CSS support can be limited.
If you need stronger rendering capabilities, consider Selenium WebDriver with an embedded browser like PhantomJS, though be aware that some level of dependency on external headless browsers may remain.