Why not just use a random number between 1 and 5?
You can use an Assertion to check the general format of the reply first if
required.
Or you can read the random value from a file using _StringFromFile() or
__CSVRead().
==
The regular expression extractor has a random function.
For this to be of any use, the regex must be able to match several times
when repeatedly applied to the target (the RE engine will move past the
start of the previous match and try again).
Your RE "anchors" the match to start with name="cbo_Type", which means it
cannot match again - unless that string appears again.
You could try just
(?s:<option\s+value="(\d+)"\s*>)
and see what happens.
If the value can contain non-digits, you'll need to change "(\d+)", but
beware of accidentally matching too much. This should work for all except
values with embedded double-quote:
"(.+?)"
i.e. match anything one or more times, but don't be greedy. Thus it will
stop when it matches the immediately following ", rather than continuing
until it finds the last possible ".
If there is more than one combo-box on the page, I suppose it would be
possible to use the regex *extractor* with anchored search to extract only
the relevant options, and then use the regex *function* on that to select a
random value.
I recommend trying these out in the Regex Tester - truly magical!
S.
-----Original Message-----
From: Michael Stover [mailto:[EMAIL PROTECTED]
Sent: 24 August 2004 21:28
To: JMeter Users List
Subject: Re: Extracting Random Value from a Combobox
I don't think you can do that with regular expressions. To do so would
require the matcher attempt to match multiple different ways against the
same text, and that's just not how they work.
Alternatively, you can sometimes use the HTML Link Parser for this sort
of thing. I say 'sometimes' because it's a touchy piece of code that
likes things just so, but if your HTTP Request is otherwise
straightforward, you might be able to do so.
The basics of using it involve attaching an HTML Link Parser to the
request you want to modify (ie, not the previous request as you would do
with the regular expression post processor). Then, in your request you
have a parameter named "cbo_Type". For the value of that parameter, put
'*'.
It might be as easy as that. Or not :-)
-Mike
On Tue, 2004-08-24 at 15:55, Peter Bernier wrote:
> Hello,
>
> I've been trying to figure out the correct regular expression to be
> using to extract a random value from a combobox (html <select>) and
> can't quite seem to get the syntax right.
>
> I'm trying to use this expression in the Regular Expression field of a
> Regular Expression Extract Post Processor :
>
> name="cbo_Type" size="1">[\W]*<option value="-1"
> SELECTED></option>[\w\W]*<option value="(\d*)"
> >[\w\W]*</option>[\W]*</select>
>
> Where cbo_Type is the combobox that I want the values to come from and
> all values are positive integer numbers.
>
> Sample code to apply the expression on :
> <select id="cbo_Type" name="cbo_Type" size="1">
> <option value="-1" SELECTED></option>
> <option value="5" >Value 5</option>
> <option value="1" >Value 1</option>
> <option value="3" >Value 3</option>
> <option value="2" >Value 2</option>
> <option value="4" >Value 4</option>
> </select>
>
> Depending on the expression that I use, I only seem to be able to extract
> the first or last integer value (with separate expressions...).
>
> I would greatly appreciate any help with this..
>
> - Peter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
Michael Stover <[EMAIL PROTECTED]>
Apache Software Foundation
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_______________________________________________________
This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive this
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the
sender does not warrant that this transmission is virus-free and will
not be liable for any damages resulting from any virus transmitted.
_______________________________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]