Hello,

I searched both the Development and User forums, but didn't find an answer.
if this has already been answered please point me to the right entry in the
archives.  Thank you in advance for any help you can provide.

i'm new to the list, but have been using JWebUnit for the last 6 months.  it
works great on one of the products i test, so we decided to use it on
another product, too.  This new product has a page that refreshes every 30
seconds, and when i go to setup my WebTester, i get an exception. about
RefreshHandlers.  We are using the HtmlUnit plugin, not selenium.  The
Question i have is how do i change the Refresh handler?  This error happens
when i call WebTester.beginAt("/"), and that method initializes the
WebClient inside a private method, and sets the refreshHandler to the
ImmediateRefreshHandler.  i'd like to use another type.


Error:
java.lang.RuntimeException: Unexpected Exception during init.
    at TestWebTester.init(TestWebTester.java:53)
    at TestWebTester.<init>(TestWebTester.java:37)
    at TestWebTester.main(TestWebTester.java:60)
Caused by: java.lang.RuntimeException: Refresh to
http://10.10.10.31:90/(30s) aborted by HtmlUnit: Attempted to refresh
a page using an
ImmediateRefreshHandler which could have caused an OutOfMemoryError Please
use WaitingRefreshHandler or ThreadedRefreshHandler instead.
    at
com.gargoylesoftware.htmlunit.ImmediateRefreshHandler.handleRefresh(ImmediateRefreshHandler.java:58)
    at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeRefreshIfNeeded(HtmlPage.java:1279)
    at
com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:218)
    at
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:427)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:303)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:360)
    at
net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.gotoPage(HtmlUnitTestingEngineImpl.java:248)
    at
net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.beginAt(HtmlUnitTestingEngineImpl.java:207)
    at net.sourceforge.jwebunit.junit.WebTester.beginAt(WebTester.java:228)
    at TestWebTester.init(TestWebTester.java:48)


Here is an example code snippet that uncovers the issue:

****************************************************************************************
public class TestWebTester extends WebTester {
    private String baseUrl;

    public TestWebTester() {
        super();
        init();
    }

    public TestWebTester(String baseUrl) {
        super();
        this.baseUrl = baseUrl;
        init();
    }

    public void init() {
        System.out.println("TestWebTester.init()");
        // set base url
        try {

            setBaseUrl(this.baseUrl);
            // first part to load
            System.out.println("  -> set begin at  = '/'");
            beginAt("/");

        } catch (TestingEngineResponseException e) {
            throw new RuntimeException("Unexpected
TestingEngineResponseException during init.", e);
        } catch (Exception e) {
            throw new RuntimeException("Unexpected Exception during init.",
e);
        }
    }

    public static void main(String[] args) {
        System.out.println("----- Begin -----");
        try {
            TestWebTester twt = new TestWebTester("http://10.10.10.31:90/";);
        } catch (Throwable t) {
            System.out.println("*** ERROR ***");
            t.printStackTrace();
            System.out.println();
            System.out.println("*************");
        }

        System.out.println("-----  end  -----");
    }
}
****************************************************************************************
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
JWebUnit-users mailing list
JWebUnit-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to