[Webtest] Re: Iteration through an XPath results set

Christopher Painter-Wakefield webtest@lists.canoo.com
Mon, 5 Apr 2004 15:11:45 -0400




No useful iteration of the type you are asking about is possible, to my
knowledge.  There is some kind of repeat step, but that again depends on
you knowing how many elements you need to test.

In general, this kind of non-deterministic testing is of limited
usefulness.  You can't tell at a glance that you have tested anything
worthwhile; for instance, if your search returns no results, you won't have
any bad links :)

To avoid this problem, control everything - your test data, your test
environment, etc., as much as possible.  Since we can use all of Ant, we
use Ant SQL tasks to set up data for each set of tests on our
database-driven application.  The tests then can be very focused and
specific for each case, by setting up each case in the database.  For the
other kind of testing, we use eyeballs.

That being said, some kind of looping constructs would come in handy in
certain cases.  Also, I have considered extending verifylinks to allow
verification of all links matching a particular pattern (regex or xpath);
my webapp is part of a larger suite of webapps, so our pages have a layout
that includes links to the other systems, and of course the obligatory
links to our institution and so forth.  I would like to be able to verify
all links on the page that are just internal to my application.  This
should be a fairly easy extension, but my need has not been strong enough
to find the time to do it.

Good luck!

-Christopher




Message: 2
From: "Oster Nathan" <Oster_Nathan@bah.com>
To: <webtest@gate2.canoo.com>
Date: Sat, 3 Apr 2004 00:13:23 -0500
Subject: [Webtest] Iteration through an XPath results set
Reply-To: webtest@lists.canoo.com


I'm a newbie to both XPath and WebTest, so I apologize if this is too
basic.

Is is possible to loop/iterate through the results of an XPath
expression that returns a set of elements?

For example, if the XPath expression returns a set of product href
links, can I iterate through all of them and call "verifylinks"?

If iteration through a results set is not possible, can someone please
provide me with an alternative test design for cases where you need to
validate a set of randomly generated page elements.  This includes
verifying search results, product lists, a list of navbar buttons, etc.

Thanks!
Nate