[Webtest] javascript link

Denis N. Antonioli Denis N. Antonioli" <denis.antonioli@canoo.com
Wed, 30 May 2007 21:01:43 +0200


On 30 mai 07, at 17:14, Francisco Javier Martin Gutierrez wrote:

> I need to follow a javascript link but it does not work. I try using
> clicklink and storeregex but both fail. There are more than one  
> links like
> this:
> <!--<td align="center" bgcolor="#FBFBFB">	<a
> href="javascript:eliminar('10101A', 'prueba marcos');"><img
> src="imagenes/ico_eliminar.gif" alt="eliminar" width="8" height="9"
> border="0"></a></td>-->
> If I try:
>   <clickLink	description="Click link: click boton: Eliminar"
>     href="javascript:eliminar('10101A', 'prueba marcos');"

The fragment shows that this link has been commented out!
How do you expect webtest to locate it then?

> So I though that I could store the link contained in javascript  
> function but
> it also failed. I tried:
> <storeRegEx
>       description="Extract target location from javascript command"
>       text=".*name=&quot;href&quot;.*href=&quot;javascript:eliminar 
> (10101A,
> prueba marcos)&quot;"
>       property="targetLocation" />
>     <invoke
>       description="Invoke target page specified in the javascript  
> statement"
>       url="#{targetLocation}"
>       save="targetPage" />


> Test step steps (C:\webtest 2.5\SAUSS\PruebaPc004b.xml:53: ) null  
> failed
> with message "No match for regular expression <
> .*name="href".*href="javascript:eliminar('10101A', 'prueba marcos')">"

As the error message shows, your regexp does not match.
This could do:
> <storeRegEx
>       description="Extract target location from javascript command"
>       text="href=&quot;javascript:eliminar(10101A, prueba marcos) 
> &quot;"
>       property="targetLocation" />

But I would consider it dubious to try to click on a link that isn't  
even available to the user!


There once was an Age of Reason, but we've progressed beyond it.
   -- Ayn Rand, 'Atlas Shrugged'