Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

ReferenceError: "clearTimeout" is not defined

Help
joken
2007-06-29
2013-04-26
  • joken
    joken
    2007-06-29

    The html for testing:
    <html>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK">
    <SCRIPT LANGUAGE="JAVASCRIPT">
    <!--
    var position = 0;
    var timeoutid=null;
    function scrollhtml() {
    if (position < 400 ){
    position++;
    //scroll(0,position);
    clearTimeout(timeoutid);
    timeoutid = setTimeout("scrollhtml()",100); }
    else{
    clearTimeout(timeoutid);
    //scroll(0,0);
    }
    test = document.getElementById("test");
    test.value="333333";
    }
    -->
    </SCRIPT>
    <body>
    <form name="thisfrm" id="thisfrm" >

    <input type="button" name="aLogin" id="aLogin" value="开始滚动" onClick="scrollhtml()">

    <input id="test" type="text" value="">
    </form
    </body>
    </html>

    The code is :
            public static void main(String[] arg) {
            WebConversation wc = new WebConversation();
            try {
                WebResponse indexhtm = wc.getResponse("http://192.168.168.150:8080/captureweb/cleartime.html");
                //System.out.println(indexhtm.getText());
                 WebForm form = indexhtm.getFormWithID("thisfrm");
                Button alogin =  form.getButtonWithID("aLogin");
                 alogin.click();
                System.out.println("----------"+indexhtm.getText());
                
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SAXException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    return text:
         org.mozilla.javascript.EcmaError: ReferenceError: "clearTimeout" is not defined.
        at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3229)
        at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3219)
        at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3292)
        at org.mozilla.javascript.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1636)
        at org.mozilla.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntime.java:1906)
        at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:95)
        at org.mozilla.javascript.gen.c1._c1(httpunit:6)
        at org.mozilla.javascript.gen.c1.call(httpunit)
        at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3085)
        at script.x(httpunit)
        at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2251)
        at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:161)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:340)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2758)
        at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:159)
        at com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.performEvent(JavaScript.java:172)
        at com.meterware.httpunit.scripting.ScriptableDelegate.doEvent(ScriptableDelegate.java:56)
        at com.meterware.httpunit.Button.doOnClickEvent(Button.java:103)
        at com.meterware.httpunit.Button.click(Button.java:81)
        at TestBig.main(TestBig.java:27)
    Exception in thread "main" com.meterware.httpunit.ScriptException: Event 'scrollhtml()' failed: org.mozilla.javascript.EcmaError: ReferenceError: "clearTimeout" is not defined.
        at com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.handleScriptException(JavaScript.java:202)
        at com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.performEvent(JavaScript.java:175)
        at com.meterware.httpunit.scripting.ScriptableDelegate.doEvent(ScriptableDelegate.java:56)
        at com.meterware.httpunit.Button.doOnClickEvent(Button.java:103)
        at com.meterware.httpunit.Button.click(Button.java:81)
        at TestBig.main(TestBig.java:27)

     
    • joken
      joken
      2007-06-30

        who can help me?

       
      • Karim Varela
        Karim Varela
        2007-06-30

        I've heard that nobody has contributed to httpunit in a couple of years, and this sounds like maybe a feature that was never included in the package, but then again I'm a newb to httpunit myself, and nobody answered my question that I posted here either.

         
    • zeyad
      zeyad
      2007-07-01

      This is not HttpUnit error , this is Rhino parser error (JavaScript interpreter ), as I see in your case you need to declare your JavaScript function (clearTimeout) in your code to be executed by  Rhino parser . Also the HttpUnit still valid and we have a lot of users that uses HttpUnit in his test cases for automated testing purpose.

       
    • joken
      joken
      2007-07-02

        谢谢各位的回答。
        Then It can be passed in htmlunit whith Rhino .and I can passed in firefox. but only it is error in httpunit .
         
              为什么?
                                      谢谢大家!

       
    • joken
      joken
      2007-07-02

      The clearTimeout method is available on window objects. It is used to clear a delay to a function that was set using setTimeout().

       
    • joken
      joken
      2007-07-04

      请版主多多帮忙。
      Any help? thanks!

       
    • joken
      joken
      2007-07-05

        看来这没有一点人气,只有放弃使用httpunit了.~.~