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.


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


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.


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.


<?xml version=”1.0″?>
<!DOCTYPE allthreads SYSTEM “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).


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


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

XML Schema assertions-Jmeter Tutorial

The XML Schema Assertion allows the user to validate a response against a XML Schema.

XML Schema is an XML-based alternative to DTDs. An XML Schema describes the structure of an XML document. The XML Schema language is also referred to as XML Schema Definition (XSD).Before going through this tutorial please have a brief idea on XML and XML schema.


1. We record the simple.xml file form the site ( and validate it against simple.xsd.


<?xml version=”1.0″?>
alok ranjan


<?xml version=”1.0″ encoding=”UTF-8″ ?>
<xs:schema xmlns:xs=””><xs:element name=”name”>
<xs:complexType mixed=”true” />

<xs:element name=”person”>
<xs:element ref=”name” />


Copy the contents of simple.xsd to a notepad and save it as simple1.xsd.Place it under bin directory. You can record your own XML file and validate it against its schema. For generating the schema for a XML file we can use XSD generator tools .This can also be done online here:


2. Add schema assertions to the simple.xml sample. (Add->assertions->Xml Schema assertions)

3. Now provide the path and filename of schema in XML Schema Assertion element. Here we put simple1.xsd.


Now run the script and the view the result in View results tree . If assertion is passed the result is shown in green otherwise red.To view the results add an assertions results listener to the xml sample. (Add->listener->assertions Results)

By default all the failure details are shown in the assertions result tab in the view results tree.


we can tweak the schema to see what errors can be thrown by jmeter.

1. Remove the xmlns part from second line in the schema file sipmle1.xsd. The line is shortened to: <xs:schema>.Now run the script.An error comes like this:

Assertion failure message : fatal: line=2 col=12 The prefix “xs” for element “xs:schema” is not bound.

2.Lets remove the fifth line i.e </xs:element>.Running the script gives following error.

Assertion failure message : fatal: line=16 col=3 The element type “xs:element” must be terminated by the matching end-tag “</xs:element>

XML Assertions in Jmeter

Before going through this tutorial please have a brief idea about XML.

The XML Assertion tests the response data whether it consists of a formally correct XML document.So it validates the response to be a valid XML type.It does not validate the XML based on a DTD or schema.To validate the response against any schema you can use XML Schema Assertions.

To use XML Assertions we have to record the XML file from the server.In this example we will be recording these files:

1. Correct XML document
2. Invalid XML document

File1:Valid File4:Invalid
<?xml version=”1.0″?>
<?xml version=”1.0″?>
<body>Call me today.<body>


1. Record file1 (Valid XML) and file4 (invalid XML) from this link: you can can record any file of your own choice.xmlassn1

Now add XML assertions to both the sample. (Add->assertions->XML assertions).also add a View Results tree Listener. Now run the script. The result in listener will look like this.The failure is shown in red.

The Assertion result is like this.

Error on line 7: The element type “body” must be terminated by the matching end-tag “</body>”.

To view the assertion results we can add an assertions results listener. (Add->Listener->assertions results)

If you try to assert the response of any normal html request with XML assertions it will though a mark up error,like this:

The markup in the document preceding the root element must be well formed.


What is XML

  • XML stands for EXtensible Markup Language
  • XML is a markup language much like HTML
  • XML was designed to carry data, not to display data
  • XML tags are not predefined. You must define your own tags

XML is hierarchical, and as such the proper nesting of tag elements is crucial.


<?xml version=”1.0″?>
<title>The Matrix</title>
<actor>Keanu Reeves</actor>
<actor>Laurence Fishburne</actor>
<director>Wachowski Brothers</director>

Well Formed XML Documents:

A “Well Formed” XML document has correct XML syntax.The syntax rules are:

  • XML documents must have a root element
  • XML elements must have a closing tag
  • XML tags are case sensitive
  • XML elements must be properly nested
  • XML attribute values must be quoted

Valid XML Documents

A “Valid” XML document is a “Well Formed” XML document, which also conforms to the rules of a Document Type Definition (DTD).

The purpose of a DTD is to define the structure of an XML document. It defines the structure with a list of legal elements:

DTD for the above xml :

<!DOCTYPE MovieCatalog [
<!ELEMENT MovieCatalog (movie,title,actors+,director)>
<!ELEMENT actors(actor)>
<!ELEMENT movie (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT actors (#PCDATA)>
<!ELEMENT actor (#PCDATA)>
<!ELEMENT director (#PCDATA)>

an XML based alternative to DTD called XML Schema can also be used.

Jmeter Tutorials

Following are some good tutorials on Jmeter

1. Your First Jmeter Test

2.Regression Testing With JMeter

3. JMeter FAQ

4.Load Testing your Applications with Apache JMeter

5. Load Testing with Apache JMeter

Parametrization in JMeter -2

Method2 Using preprocessor (User Parameter)

For a parameterization using CSV Config Element please read my previous post – Parameterization in Jmeter-1.


1. To parameterize a login scenario for more than one user first record the login scenario.

2. Open a notepad and enter userid and password for three users.

Save the file as test.csv. The extension csv makes it a comma separated Value (CSV) file.


3. Select the Login sample and add a “User Parameter” element to it.

Add->Preprocessor-> User parameters


In parameters add three variables and fill it as shown in below figure:


__CSVRead is a function which reads values from file test.csv . The second parameter of the function is the column number .Name is the variable name which is referenced in the request sample.


Now select the login sample and change the values of userid and password to ${A} and ${B}.


You can also generate the value for variable using function helper dialog. Open it from options or use shortcuts ctr+F. Choose __CSVRead from choose a function dropdown list. The value field of first row in the Function parameters represents the file name (here test.csv) and second row represents column number (e.g. 0, 1, 2…).

Now run the script and observe the result in view result tree.

Simple Parameterization in Jmeter:

When you want to run/execute one test plan for more than one user at the same time you go for parameterization. It is a method of generalizing an action.

Here is a simple example to parameterize a Google search for three different users.

1. Record a simple Google search in Jmeter. Put the search keyword as “Jmeter”. The result will be something like this.


We will parameterize the search keyword “Jmeter”.

2. Now add a CSV Data set Config and a Listener element to the thread group.

Add->Config Element->CSV Data Set Config
Add->Listener->View Results Tree

3. Now open a notepad (inside bin) and enter your keywords.


Save the file as search.csv. The extension csv makes it a comma separated Value (CSV) file.

4. Now select the CSV Data set Config element and fill in the fields as follows

Filename: search.csv

(Give the path name if you have put it inside a subfolder e.g. foldername\search.csv)

Variable Names: A

(This variable name is referenced in the search sample.)

Delimiter: ,


5. Now go to search sample and change the value of variable q to ${A}.In Jmeter we reference a variable using ${} .For each iteration the value of q will be replaced as fetched by variable A.


6. Now go to thread group and make the number of threads (users) to 3.

7. Run the script(ctr+R) and observe the result in result tree.