Using Config Elements in a JMETER test plan

The test plan will be very simple and consist in sending requests for the VPL.CA results page using different sort orders of results.

The typical URL of a results page of the site is


t parameter shows that the url corresponds to a keyword search and 
q parameter has the value of the search keyword

After sending this request to the server, if the page loads correctly, 10 or 25 results are loaded.

If the sort order is modified, the URL of the page becomes

Relevance sort order

Date Acquired



Published date

All sort urls start with the base URL ( and are different in the last part.

So, the JMETER project starts with creating the thread group and the http request:

The first Config Element to be used is HTTP REQUEST DEFAULTS element.

Any http request fields populated in this element can be empty in the actual request as they are "inherited" from the HTTP REQUEST. In our case, just the Server Name or IP is used:

Next, we will change the q parameter of a URL in a variable so that each request uses a different keyword value.

This is done by adding another config element, CSV DATA Set Config that reads the keyword values from a text file:

Each http request will get a value from the CSV Data Set Config through the keywordValue variable.

The http request will look a bit different now:

Next, the http request will be changed again so that the sort order is used.

First, I will add 2 new config elements to the plan: random variable and user defined variables.

The random number will have a value between 1 and 100 generated and stored in the randomNumber variable.

2 user defined variables are created as well:

I will use these config elements as follows:

if (randomNumber between 0 and 20)
sortOrder = "Relevance";

if (randomNumber between 20 and 40)
sortOrder = "acquired";

if (randomNumber between 40 and 60)
sortOrder = "Title";

if (randomNumber between 60 and 80)
sortOrder = "Author";

if (randomNumber between 80 and 100)
sortOrder = "Published";

A BeanShell sampler will determine the sort order. 
The BeanShell sampler will

- get the randomNumber variable value

- convert it from String to Integer

- set local variables with the sort order name and sort order parameters based on the random Number value

- set the user defined variables based on the local variables

- write the sort order name and the sort order parameters to the JMETER log

The http request will now have an updated value:


The http request needs a few assertions:

1. check that the number of books in the page is greater than 0

2. check that the selected sort order is the one defined in the bean shell sampler

I have also added an XPATH extractor to get the number of results in the page and another Bean Shell post-processor to display this value in the log:

It is time to run the project and look at the results:

The last 3 config elements to be added are:

HTTP Cache Manager

It allows clearing the cache for each iteration or setting the cache expiration settings.

HTTP Cookie Manager

It allows clearing the cookies after each iteration or setting cookies.

HTTP Header Manager

It allows changing the request headers so that the requests are sent using a specific browser info (Chrome).

Run Web Driver scripts from Command Prompt

The Web Driver scripts can be run easily in Eclipse after being created.

But to get the maximum benefit of having them, they should also be run from Command Prompt, maybe after each site build is generated.

How can this be done?

Let's assume that we have a JAVA project created in Eclipse with 2 test classes, each class having 2 test scripts.

The first thing to do is to open Command Prompt and make the project folder the current folder:

cd C:\Projects\workspace\ProjectWithJUNIT

ProjectWithJUNIT has the following sub-folders:

Src - the .java files can be found here
Bin - the .class files will be generated here

Then, set up the CLASSPATH variable so that it includes the following:

- path of the junit.jar file

- path of the org.hamcrest.core_1.3.0.v201303031735.jar file

- path of the selenium-java-2.44.0.jar file

- path of the selenium-server-standalone-2.44.0.jar file

- path of the project class files

The following command does the work:

set CLASSPATH=C:\Projects\workspace\ProjectWithJUNIT\bin;C:\Eclipse\plugins\org.junit_4.11.0.v201303080030\junit.jar;C:\Eclipse\plugins\org.hamcrest.core_1.3.0.v201303031735.jar;C:\Selenium\JAR\selenium-java-2.44.0.jar;C:\Selenium\JAR\selenium-server-standalone-2.44.0.jar

Next, the class files need to be generated by compiling the .java files:

javac src\ -d bin
javac src\ -d bin

The -d option is needed so that the .class files are placed in the Bin sub-folder of the project folder.

Finally, this command executes the .class files using the junit runner:

java org.junit.runner.JUnitCore Class1 Class2

Since all test methods are using the HTML UNIT DRIVER instead of the Chrome driver, no browser is launched for the execution of the test scripts.

This is the end result: