[Webtest] iteration over all links in a page

Marc Guillemot webtest@lists.canoo.com
Wed, 13 Jul 2005 10:06:46 +0200


What about verifyLinks?
http://webtest.canoo.com/manual/syntax.html#verifyLinks

Marc.

Brian Hubbard wrote:
> Hi,
>  I want to be able to check that all the links on a web page have valid links.
>  As the pages are generated automatically the number and urls must be discovered
> in the page itself.
>  I have attempted to do this with a combination of storexpath and repeat, í.e.
> 
>  <steps>
>   <invoke ...>
>   <storexpath xpath="count(//a/@href)" property="n_links"/>
>   <repeat count="#{n_links}">
>    <storexpath xpath="//a[#{count}+1]/@href" property="link"/>
>    <invoke url="#{link}/">
>   <repeat/>
>  <steps/>
> 
>  This gets the number of links correctly, but the xpath //a[n] fails for
> anything other than 1. My understanding is that //a[1]/@href should return the
> first value of href for the first occurance of the tag "a", //a[2]/@href should
> return the value for the second "a" tag within the document and so on.
> 
>  Why doesn't this work?
>  Is there a better way to achieve this?
> 
>  Thanks in Advance,
>   Brian
> 
> 
> 
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>