[Webtest] Another problem related to javascript

Ritesh Trivedi webtest@lists.canoo.com
Mon, 4 Apr 2005 16:56:24 -0800


Lisa,

Where is event variable defined?

My take is that instead of setting evet.returnType, you could just
return true or false, which should be enough to or not to submit the
form.

HTH.
Ritesh

On Apr 4, 2005 2:32 PM, Lisa Crispin <lisa.crispin@att.net> wrote:
> 
> Our web app uses javascript to prevent users from clicking certain buttons
> twice.  When we first started using WebTest, we had to create a flag to
> disable that javascript so that our WebTest scripts could run.  Now that
> WebTest is based on HtmlUnit and should support a lot more Javascript, I
> hoped the scripts would work with the javascript enabled (it would allow us
> to run some smoke tests against our staging and production environments to
> verify releases).  However, it doesn't.  Here is the javascript, form and
> button, followed by the WebTest syntax and the error message.  Would anyone
> have advice for us?
>  
> 
> 
> <script languange="javascript">
> 
> var formCount0 = 0;
> 
> function formOnSubmit0() {
> 
>  formCount0++;
> 
>  if (formCount0 > 1) { alert('This page has already been submitted!');
> event.returnValue = false; }
> 
>  else { event.returnValue = true; }
> 
> }
> 
> </script>
> 
> <form method="post" action="login.jsp?submit=1&ts=65021"
> onSubmit="javascript: formOnSubmit0();">
> 
> <input name="submitBtn" value="Submit" type="submit" class="formButton">
> 
> </form>
> 
>  
> 
> WebTest script:
> 
>       <clickbutton stepid="Submit the plan features"
>           name="submitButton"/>
> 
>  
> 
> Error:
> 
> C:\java\eplan70\build.xml:1254: The following error occurred while executing
> this line:
> Test step clickbutton
> (C:\java\eplan70\src\web_test\modules\planEstStep1.xml:97:)
> 
>   named "Submit the plan features" failed with message "Step "clickbutton
> "Sub
> mit the plan features" (35/122): Script error executing at: click button"