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

http://vpl.bibliocommons.com/search?q=java&t=keyword

where 

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

http://vpl.bibliocommons.com/search?q=java&t=keyword
&sort[field]=RELEVANCY&sort[type]=CATALOG_SEARCH_FIELDS&sort[direction]=descending

Date Acquired

http://vpl.bibliocommons.com/search?q=java&t=keyword
&sort[field]=NEWLY_ACQUIRED&sort[type]=BIB_FIELDS&sort[direction]=descending

Title

http://vpl.bibliocommons.com/search?q=java&t=keyword
&sort[field]=TITLE&sort[type]=BIB_FIELDS&sort[direction]=ascending

Author

http://vpl.bibliocommons.com/search?q=java&t=keyword
&sort[field]=AUTHOR&sort[type]=BIB_FIELDS&sort[direction]=ascending

Published date

http://vpl.bibliocommons.com/search?q=java&t=keyword
&sort[field]=PUBLISHED_DATE&sort[type]=BIB_FIELDS&sort[direction]=descending

All sort urls start with the base URL (http://vpl.bibliocommons.com/search?q=java&t=keyword) 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:

/search?q=${keywordValue}&t=keyword&${sortOrderParameter}


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).

0 Response to "Using Config Elements in a JMETER test plan"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel