You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Ronan Klyne <ro...@groupbc.com> on 2007/08/20 14:37:37 UTC

Randomly selecting one of several XPath matches

Hello all,

I need to be able to locate several values in a page, and randomly
select one. The regular expression extractor will let me do the random
selection, but I'd rather use the XPath extractor, as it's more suitable
for specifying bits of an HTML document...
Is there any way to have the XPath extractor match several nodes, and
return one of them at random?

Cheers,

	Ronan

-- 
Ronan Klyne
Business Collaborator Developer
Tel: +44 (0)870 163 2555
ronan.klyne@groupbc.com
www.groupbc.com

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Randomly selecting one of several XPath matches

Posted by Stuart Findlay <st...@cp.net>.
I should add that the XPathExtractor does return all nodes by default.

Stuart

Stuart Findlay wrote:
> You can generate a random function to generate a choice e.g:
>
>
> ${__Random(1,${refName_matchNr},n)}
>
> you will then be able to utilise ${n} in a variable command to 
> construct the reference:
>
> $__V{refName_${n}}
>
> Hope that helps, Stuart
>
> Ronan Klyne wrote:
>> Hello all,
>>
>> I need to be able to locate several values in a page, and randomly
>> select one. The regular expression extractor will let me do the random
>> selection, but I'd rather use the XPath extractor, as it's more suitable
>> for specifying bits of an HTML document...
>> Is there any way to have the XPath extractor match several nodes, and
>> return one of them at random?
>>
>> Cheers,
>>
>>     Ronan
>>
>>   
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Randomly selecting one of several XPath matches

Posted by Ronan Klyne <ro...@groupbc.com>.
Stuart Findlay wrote:
> You can generate a random function to generate a choice e.g:
> 
> 
> ${__Random(1,${refName_matchNr},n)}
> 
> you will then be able to utilise ${n} in a variable command to construct
> the reference:
> 
> $__V{refName_${n}}
> 
> Hope that helps, Stuart

Exactly the thing - many thanks :)

	# Ronan

-- 
Ronan Klyne
Business Collaborator Developer
Tel: +44 (0)870 163 2555
ronan.klyne@groupbc.com
www.groupbc.com

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Randomly selecting one of several XPath matches

Posted by Stuart Findlay <st...@cp.net>.
You can generate a random function to generate a choice e.g:


${__Random(1,${refName_matchNr},n)}

you will then be able to utilise ${n} in a variable command to construct 
the reference:

$__V{refName_${n}}

Hope that helps, Stuart

Ronan Klyne wrote:
> Hello all,
>
> I need to be able to locate several values in a page, and randomly
> select one. The regular expression extractor will let me do the random
> selection, but I'd rather use the XPath extractor, as it's more suitable
> for specifying bits of an HTML document...
> Is there any way to have the XPath extractor match several nodes, and
> return one of them at random?
>
> Cheers,
>
> 	Ronan
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org