Missing Form exception

Help
2008-06-09
2013-04-26
  • John Collier
    John Collier
    2008-06-09

    I just started using HttpUnit today (it looks like it will be very helpful in testing our application suite), and I am attempting to simply load our application home page and list some information about it.

    Here is a code snippet for what I am attempting to do:

    WebConversation wc = new WebConversation() ;
    response = wc.getResponse("http://localhost:8080/myApplication/") ; //ERROR
    WebForm[] forms = response.getForms() ;
    // Probably will output something simple about the forms

    The call to "getResponse()" is failing with the following:

    org.mozilla.javascript.EcmaError: ReferenceError: "searchForm" 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)

    (the rest of the stack trace is omitted).

    I could understand where this might be a problem, except for the fact that I find the Form in the page source:

    <form name="searchForm" method="get" action="/myApplication/search.do
          onsubmit="return submitSimpleSearch(this)" style="display: inline;">       

       search for:
                                            
       <select name="searchType" onchange="adjustEmailDisplay(searchForm)">
          <option value="keyword">Keyword</option>                              <option value="itemNumber">Item Number</option>
          <option value="orderNumber">Order Number</option>
       </select>

       <input type="text" name="keyword" maxlength="50" size="18" value="">

       <span id="emailspan" style="display: none; visibility: hidden;">
          &nbsp;Email:
          <input type="text" name="emailAddress" maxlength="80" size="18"
                 value="">
       </span>
       <input type="submit" value="Search">
       <input type="hidden" name="numResults" value="">
    </form>

    The form itself is actually built via JSP (using standard custom tags):

    <sslext:form method="get" action="/search.do" style="display: inline;"
                 onsubmit="return submitSimpleSearch(this)">

    (other stuff omitted)

    which shouldn't make any difference (as far as I can tell anyway).

    I would really like to see this work, but I don't see anything obviously wrong.  Is there something wrong with the page that I am not seeing?  Or is there something wrong with what I am trying to do?

     
    • John Collier
      John Collier
      2008-06-09

      A little additional info about the error:  Further down the stack trace is the following line:

      com.meterware.httpunit.ScriptException: Script 'adjustEmailDisplay(searchForm);' failed: org.mozilla.javascript.EcmaError: ReferenceError: "searchForm" is not defined.

      This might be helpful.