Menu

Error in Rhino

Help
Max Wilson
2004-08-22
2004-08-31
  • Max Wilson

    Max Wilson - 2004-08-22

    I'm a newbie to HTTPUnit--I'm evaluating whether my work ought to use it for web testing--and I'm getting some puzzling errors in Rhino. Could anyone give me a clue what's happening? JUnit code is below. Thanks in advance.

    Max Wilson
    Brigham Young University OIT

    (I'm running this in an Eclipse framework, if that makes any difference. HTTPUnit 1.5.4.)

    package myTests;

    import java.net.URL;

    import junit.framework.TestCase;

    import com.meterware.httpunit.GetMethodWebRequest;
    import com.meterware.httpunit.WebConversation;
    import com.meterware.httpunit.WebForm;
    import com.meterware.httpunit.WebImage;
    import com.meterware.httpunit.WebLink;
    import com.meterware.httpunit.WebRequest;
    import com.meterware.httpunit.WebResponse;

    public class MyHTTPUnitTester extends TestCase {
        public void testNetscapeMail() throws Exception {
            String url = "http://netscape.net";
            URL serverUrl                = new URL(url);
            WebConversation conversation = new WebConversation();
            //assertTrue(conversation.getClientProperties().getAutoRedirect());
            WebRequest request           = new GetMethodWebRequest(serverUrl,"/");
            WebResponse response         = conversation.getResponse(request);
            assertNotNull(response);
            response = response.getImageWithSource("http://cdn.netscape.com/wpt_tonr_03/200304101209_tb_h1_i1_1_0").getLink().click();
            assertNotNull(response);
            System.out.println(response.getTitle());
            System.out.println(response.getText());
            assertEquals("Netscape.com", response.getTitle());
            return;
           
    //        WebForm SignIn = response.getFormWithName("verifyForm");
    //        assertNotNull(SignIn);
    //        SignIn.setParameter("Password","");
    //        response = SignIn.submit();
    //        assertNotNull(response);
        }
    }

     
    • Max Wilson

      Max Wilson - 2004-08-22

      Oh, yes. The actual error I get is

      ReferenceError: "setInterval" is not defined. (httpunit; line 97)
          at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:590)
          at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:550)
          at org.mozilla.javascript.optimizer.OptRuntime.callSimple(OptRuntime.java:254)
          at org.mozilla.javascript.gen.c60.call(httpunit:97)
          at org.mozilla.javascript.gen.c60.exec(httpunit)
          at org.mozilla.javascript.Context.evaluateString(Context.java:781)
          at com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.executeScript(JavaScript.java:122)
          at com.meterware.httpunit.scripting.ScriptableDelegate.runScript(ScriptableDelegate.java:64)
          at com.meterware.httpunit.ParsedHTML.interpretScriptElement(ParsedHTML.java:275)
          at com.meterware.httpunit.ParsedHTML.access$600(ParsedHTML.java:37)
          at com.meterware.httpunit.ParsedHTML$ScriptFactory.recordElement(ParsedHTML.java:404)
          at com.meterware.httpunit.ParsedHTML$2.processElement(ParsedHTML.java:556)
          at com.meterware.httpunit.NodeUtils$PreOrderTraversal.perform(NodeUtils.java:169)
          at com.meterware.httpunit.ParsedHTML.loadElements(ParsedHTML.java:566)
          at com.meterware.httpunit.ParsedHTML.getForms(ParsedHTML.java:101)
          at com.meterware.httpunit.WebResponse$Scriptable.load(WebResponse.java:611)
          at com.meterware.httpunit.javascript.JavaScript$Window.initialize(JavaScript.java:424)
          at com.meterware.httpunit.javascript.JavaScript.run(JavaScript.java:80)
          at com.meterware.httpunit.javascript.JavaScriptEngineFactory.associate(JavaScriptEngineFactory.java:46)
          at com.meterware.httpunit.FrameHolder.updateFrames(FrameHolder.java:105)
          at com.meterware.httpunit.WebWindow.updateFrameContents(WebWindow.java:230)
          at com.meterware.httpunit.WebClient.updateFrameContents(WebClient.java:457)
          at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:143)
          at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:127)
          at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:118)
          at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:141)
          at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:127)
          at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:118)
          at com.meterware.httpunit.WebClient.getResponse(WebClient.java:112)
          at myTests.MyHTTPUnitTester.testNetscapeMail(MyHTTPUnitTester.java:168)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at junit.framework.TestCase.runTest(TestCase.java:154)
          at junit.framework.TestCase.runBare(TestCase.java:127)
          at junit.framework.TestResult$1.protect(TestResult.java:106)
          at junit.framework.TestResult.runProtected(TestResult.java:124)
          at junit.framework.TestResult.run(TestResult.java:109)
          at junit.framework.TestCase.run(TestCase.java:118)
          at junit.framework.TestSuite.runTest(TestSuite.java:208)
          at junit.framework.TestSuite.run(TestSuite.java:203)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)

       
    • Max Wilson

      Max Wilson - 2004-08-31

      It's an error thrown by the interpreter. It seems that the Javascript function setInterval isn't implemented in Rhino. (?) So the interpreter doesn't know how to react to this error, and like any interpreter it then throws an exception. It turns out that you can prevent it from propagating the exception all the way up to HTTPUnit and my client code by calling

      HttpUnitOptions.setExceptionsThrownOnScriptError(false);
                 
      It still seems to have some problems, but I've gotten frustrated debugging Netscape's site and have moved to a different site to test. Hope that helps someone in the future. Future developers: email me at wilson.max@gmail.com.

      Max Wilson

       

Log in to post a comment.

MongoDB Logo MongoDB