Hello all,

I'm currently working on developing JMeter tests for my web application but 
have come up against a bit of a problem.  I'm using Tapestry so there is some 
dynamic generation of URLs, which I can get around by using the regex 
post-processor to pull out the IDs I need.  All good so far.

However, what I want to do now is simulate users clicking on random elements 
in my left-hand pane.  When the pane is rendered I can pull out all of the 
links by using the right regex and setting the match number to -1.  This 
populates the variables tapestryPvalue_1, tapestryPvalue_2 etc.

So now I'd like to somehow have a subsequent request randomly choose one of 
these variables to use.  I noticed the ForEach controller, which is the kind 
of thing I want, except I only want to use one of the variables.  
Unfortunately I can't find any documentation about dynamically building up 
variable names in JMeter; I tried the natural way of doing it and defined a 
parameter as "${tapestryPvalue_${one}}" (having previously set up a user 
defined variable called "one" that evaluated to "1") but that got sent 
through as the literal string and not evaluated as I hoped.  I also tried 
some javascript indirection with 
${__javascript("${tapestryPvalue_"+"${one}"+"}")}, noting that variables had 
to be quoted so hopefully the JS engine would resolve the ${one} before 
appending it, but no such luck.

At the moment this is academic anyway, as I couldn't get the __Random function 
to accept ${tapestryPvalue_matchNr} as the maximum value (the logs indicated 
a NumberFormatException was thrown which suggests this must be a literal).   
My initial plan was to use this function to generate a random 'index', then 
pass that variable in where I was using ${one} in the above paragraph.


Am I going about this the wrong way?  Is there a way to dynamically access 
elements of an array-type variable like this in JMeter, or am I pushing the 
envelope too hard with this one?  Any comments (including suggestions on 
refactoring to work around this issue) are welcome.

Thanks,
Andrzej

Attachment: pgpV1BVc5Fqb0.pgp
Description: PGP signature

Reply via email to