Romain Beaudon

JMeter HTTP tips and examples

Load all resources attached to a html file

alt text

Useful when working with frames to avoid one http request per frame (I use this a lot when scripting for PeopleSoft ERP).

Extract a value to a variable with a regular expression

alt text

You can use a Debug Listener to adjust the regexp. In this example (PeopleSoft) I checked “Main sample and sub-samples” because the value to be extracted is in a frame.

Test a variable

alt text

In this example I verify that the Regular Expression hereabove worked.

Javascript in parameters (e.g. to randomize a choice)

First we get the number of values :

alt text

Then we replace the parameter with our javascript :

1
Math.floor( Math.random() * ${VALUES_COUNT} ) )

In JMeter it becomes :

1
${__javaScript( Math.floor( Math.random() * ${NB_Lignes } ) ) }

alt text

Note : The double $$ is due to variable names in PeopleSoft (AF_PCC_WRK_SELECT_PB$1, AF_PCC_WRK_SELECT_PB$2…)