[Webtest] Dynamic field naming

Ben Cox ben@bjtechnics.com
Tue, 19 Mar 2002 11:43:12 -0800


   I am trying to use webtest, and, while I think it's great, I am 
finding a little difficult to use in practice.  One thing that would 
really help is the ability to use the text that matches a regex in one 
of the verifyXXX tags later in the build file somehow, so that, for 
example, the names of form fields and the values they hold could be 
detemined dynamically in the later invocations of setXXX tags.
   In particular, I am trying to write tests (better late than never) 
for a webapp that uses object ids in many of its form fields, and those 
ids are determined by an autoincrement in MySQL.  It seems that MySQL 
won't roll back to using id number 1 after deleting all of the entries 
if I am using the same JVM and connection pool to insert the new one 
(which the webapp is unless I take it down), so the numbers in the 
names/values of form fields that I need to click end up different in 
subsequent runs of the tests.  Though the webapp will frequently be 
taken down between test runs once the tests are written, this is 
particularly unwieldy while trying to debug the tests themselves, rather 
than the code they're testing, because the webapp doesn't have to come 
down in between each run and change of the test.
   This brings me to a question about the "ffo" sample in the WebTest 
CVS distribution.  It seems that most of the invocations of 
<clickbutton>, <setinputfield>, etc.  use properties in their value 
attributes that often look something like ${z00__wb} or 
${draft_contract}.  I can't find anywhere that these are initialized in 
the sample buildfiles or props files, so I was wondering how and where 
these properties are being set?  Is there another framework or tool 
(perhaps buillding on ant?) that this sample project uses?  This _looks_ 
like it addresses the problem I'm facing, but I really can't tell what 
it's doing!
   If anyone has some idea of what's going on in there, or a good 
implementation of this concept, would you be so kind as to shed a little 
light over here?
   Thanks in advance,

      Ben