Demirhan Ozel Demirhan Ozel - 3 years ago 79
Java Question

How to use alternative js/browser engine with htmlunit instead of rhino?

Throughout my experiences with using htmlunit, I have slowly come to realize that htmlunit does not interact well with javascript.

The rhino js engine which htmlunit uses is most definitely the root cause of these issues, and I was wondering if it was possible to use something like geckodriver instead while still using htmlunit.

Any help is appreciated.

Thanks.

Answer Source

Some facts

  • HtmlUnit uses a slightly modified (improved) version of the Rhino engine
  • the team behind HtmlUnit is working on an implementation based on (a slightly modified) Nashorn (the js engine from the jdk) but there is still a lot of work to do
  • from the experience with the Nashorn task i can tell you that is is not simple to use a different engine but as for any other open source project feel free to provide patches
  • HtmlUnit is a java only implementation, it is one of the benefits to have a browser simulation that works on many different platforms eg. you can simulate IE from a linux box

To make the long story short:

If you have problem with HtmlUnit's JavaScript support

The development team behind is small but active. If you provide a simple test case, there is a good chance to get it fixed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download