[Webtest] Problems with input of type=button

webtest@lists.canoo.com webtest@lists.canoo.com
Mon, 26 Apr 2004 20:44:00 +0000


I have this problem with some, but not all, of my buttons that are type=button and have javascript.  I haven't been able to find any pattern for when it works and when it doesn't.  We tried cleaning up the HTML errors on the page, but that didn't help.  I will be very interested to learn the answer to this question!  

Here's a sample of my HTML where clickbutton can't find the button:
 <input name="submit" type="submit" class="formbutton" value="Submit" onclick="javascript: submit=1">

You could try working around it using the <index> element.  That has worked for me.
-- Lisa


> Hi,
> 
> I use webtest build 432, the latest available in the web, for testing a
> very simple web page with an input of type=button. However, the test
> fails with the following error message:
> 
> com.canoo.webtest.engine.StepFailedException: Button with name <OK> and
> value <OK> not found!, Step: ClickButton(id="Hacer click"label=OK)
> 
> The simple HTML code used for this proof is:
> 
> <script language="JavaScript">
>     function do_submit()
>     {
>         f.submit();
>     }
> </script>
>                                                                              
> <div>
>     <form name="f" action="/" method="POST">
>         <input type="button" onclick="javascript:do_submit()" 
>          name="OK" value="OK"/>
>   </form>
> </div>
> 
> I tried to make the form submit without using a javascript function,
> that's to say, I used the line:
> 
>         <input type="button" onclick="this.f.submit()" 
>          name="OK" value="OK"/>
> 
> and the error was the same. Another important information is that if I
> replace the type of the input by a type="submit", the test is
> successful.
> 
> The xml code used for the test is:
> 
> <testSpec name="instaladores - Prueba button">
>  &instaladores_include;
>  <steps>
>    &instaladores_button;
>  </steps>
> </testSpec>
> 
> instaladores_include.xml:
> 
>  <config
>    protocol="http"
>    host="${instaladores.hostname}"
>    port="${port}"
>    basepath="${basepath}"
>    haltonerror="false"
>    haltonfailure="false"
>    verbose="true"
>    resultfile="${webtest.result}"
>    showhtmlparseroutput="false"
>    saveresponse="true"
>    summary="true" />
> 
> instaladores_button.xml :
> 
> <clickbutton stepid="Hacer click" name="OK" label="OK">
>   <form name="f" />  
> </clickbutton>
> 
> Besides, I have tried to set the configuration paremeter
> showhtmlparseroutput="true" and I have not seen any error, only no
> relevant warnings.
> 
> I have read the archives of the canoo webtest list and someone said that
> there was a patch which solved this problem and was integrated in the
> main build. I read in another message that someone has got to submit
> and validate forms with inputs of type=button with Javascript.  For this
> reason, I am confused. It is very important for me to have this feature
> running in webtest because I have a lot of forms which are submitted in
> this way.
> 
> Could anyone help me ?
> 
> Cheers !!
> 
> -- 
> Francisco Javier Morán Rúa
> Ingeniero en Informática
> Telf +34 981 91 39 91 - Ext 13
> mailto:jmoran@igalia.com
> IGALIA S.L. http://www.igalia.com
> 
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest