0

I have a submit button where the onclick() method returns false when it is clicked the second time. This way I try to handle users that try to double click the submit button. With htmlunit 2.3 I was able to test the correct behaviour like this:

public static void clickTwice( ClickableElement element ) throws IOException {
    element.click();
    element.click();
}

After updating to htmlunit 2.12 the above code is not working anymore. ClickableElement was removed and HtmlElement was now clickable. So I changed it to:

public static void clickTwice( HtmlElement element ) throws IOException {
    element.click();
    element.click();
}

But now the result is different to htmlunit 2.3.

It seems that the first click invalidates the current page and shuts down the javascript engine. The second click is executed without onclick() being evaluated and so the second submit to the server isn't blocked.

Question: How can I simulate a user clicking twice a submit button on the same page with htmlunit 2.12?

4

1 に答える 1