HTTP User Parameter Modifier

The User Parameter Modifier uses an XML file get values for HTTP arguments. Any HTTP Request that this modifier modifies will be checked for the existence of the specified arguments. If found, the values for those arguments will be replaced by the values found in the xml file. The XML file can have multiple sets of the same values. This modifier will iterate through these values in a round-robin style, thus each request will get a different set of values until the last set of values is reached, at which point it will begin again at the first set.

We can use HTTP User Parameter Modifier to parameterize a sample. In this example we will parameterize a search query to Google.

Steps:

1. Record the Google site with a search entry “Jmeter”. Add a Listener. (Add->Listener->View results tree).

hum_1

The Send Parameter with request in search sample looks like below picture. The variable name for search query is q and value is Jmeter. We will parameterize that value from an external file for two persons.

hum_23

2. Now to generalize the value for parameter q we have to get values from data.xml file. The search queries put in the data.xml file are proxy and Blogs. Copy the contents the contents of the below two files in a note pad and save them as data.xml and sample.dtd in bin directory.

data.xml

<?xml version=”1.0″?>
<!DOCTYPE allthreads SYSTEM “sample.dtd”>
<allthreads>
<thread>
<parameter>
<paramname>q</paramname>
<paramvalue>Proxy</paramvalue>
</parameter>
</thread>
<thread>
<parameter>
<paramname>q</paramname>
<paramvalue>Blogs</paramvalue>
</parameter>
</thread>
</allthreads>


sample.dtd

<!ELEMENT allthreads (thread+)>
<!ELEMENT thread (parameter+)>
<!ELEMENT parameter (paramname,paramvalue) >
<!ELEMENT paramname (#PCDATA) >
<!ELEMENT paramvalue (#PCDATA) >


3. Add HTTP User parameter modifier to search sample. (Add->preprocessor->HTTP User parameter modifier).In that element change the File Name value to data.xml (the default file is users.xml).

hum_3

4. In Search sample replace the value of parameter q with *. Make sure to give number of threads (users) to 2 in Thread Group.

hum_4

5. Now run the test. In view results tree the response data will be shown. See the result of search response in Render HTML view. The values have been passed from the file.hum_5

Advertisements

One Response

  1. Thanks, All the information mentioned in this Site really helped me to scale up in Jmeter at ease with less time

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: