I've found a bug, how do I report it?

The best way is to open a bug report in the sourceforge bug tracking database. Sending a bug report to the mailing list runs the risk that the bug may get lost. Putting it in the bug database guarantees that it won't. Please search the bug database to see if your bug hasn't already been reported before opening a new one.

If you know how to fix the problem then patches are gratefully accepted.

[top]


HtmlUnit doesn't support feature X. How do I request this feature?

The best way is to open a bug report in the sourceforge bug tracking database. See the answer on bug reporting for why the database is preferred.

If you're willing to write the feature yourself, you can always send us a patch.

[top]


What are the most important configurations?

    webClient.getOptions().setJavaScriptEnabled(...);
    webClient.getOptions().setThrowExceptionOnFailingStatusCode(...);
    webClient.getOptions().setThrowExceptionOnScriptError(...);
    webClient.getOptions().getProxyConfig().set...();
            

[top]


Nothing happens when using HtmlUnit with AJAX, although page works correctly in browsers. What's wrong?

The main thread using HtmlUnit may be finishing execution before allowing background threads to run. You have a couple of options:

  1. webClient.setAjaxController(new NicelyResynchronizingAjaxController()); will tell your WebClient instance to re-synchronize asynchronous XHR.
  2. webClient.waitForBackgroundJavaScript(10000); or webClient.waitForBackgroundJavaScriptStartingBefore(10000); just after getting the page and before manipulating it.
  3. Explicitly wait for a condition that is expected be fulfilled when your JavaScript runs, e.g.
    
            //try 20 times to wait .5 second each for filling the page.
            for (int i = 0; i < 20; i++) {
                if (condition_to_happen_after_js_execution) {
                    break;
                }
                synchronized (page) {
                    page.wait(500);
                }
            }
                

[top]


How to modify the outgoing request or incoming response?

You can subclass HttpWebConnection and override getResponse() as:


        new WebConnectionWrapper(webClient) {

            public WebResponse getResponse(WebRequest request) throws IOException {
                WebResponse response = super.getResponse(request);
                if (request.getUrl().toExternalForm().contains("my_url")) {
                    String content = response.getContentAsString("UTF-8");

                    //change content

                    WebResponseData data = new WebResponseData(content.getBytes("UTF-8"),
                            response.getStatusCode(), response.getStatusMessage(), response.getResponseHeaders());
                    response = new WebResponse(data, request, response.getLoadTime());
                }
                return response;
            }
        };
            

[top]


I'm having problems with cookie support.

HtmlUnit relies on HttpClient 4 for Cookie handling. If you have an issue, please post it to the HtmlUnit mailing list.

[top]


I get error messages about redirection being disabled but I've turned it on.
26.02.2003 16:07:05 org.apache.commons.httpclient.HttpMethodBase   processRedirectResponse
INFO: Redirect requested but followRedirects is disabled
				

It's an annoyance that I haven't figured out how to fix yet.

For a variety of reasons, I handle the redirection logic inside HtmlUnit rather than letting commons-httpclient handle it for me. It's commons-httpclient that is displaying that message because I have explicitly disabled its redirection support.

I'd like to filter out that warning message but haven't figured out a clean way of doing it. A number of people have pointed out that it's easy to disable a message if you know which logger is being used. The problem is that there isn't a way to disable the messages without knowing the logger in use.

[top]


What version will feature X be in?

There is no "roadmap" of releases. Features will be added as they are written.

Changes to the product (including new features) are implemented by volunteers in their spare time. If feature X is important to you and nobody seems to be working on it then perhaps you should consider writing it yourself and submitting a patch.

[top]


HtmlUnit appears to be leaking memory; what's the deal?

Make sure (a) that you are using the latest version of HtmlUnit, and (b) that you are calling WebClient.closeAllWindows() when you are finished with your WebClient instance.

[top]