/** * Immediately refreshes the specified page using the specified URL. * * @param page the page that is going to be refreshed * @param url the URL where the new page will be loaded * @param seconds the number of seconds to wait before reloading the page (ignored!) * @throws IOException if the refresh fails */ public void handleRefresh(final Page page, final URL url, final int seconds) throws IOException { final WebWindow window = page.getEnclosingWindow(); if (window == null) { return; } final WebClient client = window.getWebClient(); if (page.getUrl().toExternalForm().equals(url.toExternalForm()) && HttpMethod.GET == page.getWebResponse().getWebRequest().getHttpMethod()) { final String msg = "Refresh to " + url + " (" + seconds + "s) aborted by HtmlUnit: " + "Attempted to refresh a page using an ImmediateRefreshHandler " + "which could have caused an OutOfMemoryError " + "Please use WaitingRefreshHandler or ThreadedRefreshHandler instead."; throw new RuntimeException(msg); } client.getPage(window, new WebRequest(url)); }