How to do Parameterization in Jmeter Scripts
After recording scripts we need to do parameterization for recorded
scripts
Please refer my previous Post for Script recording
Steps to do
parameterization :
1.Login session id parameterization : For every user login
will get one unique ID that unique ID we need to parameterization
· - Check http sample result where we are getting login
session ID
· - Copy particular line in Regular Expression Extractor
· - Use Regular Expression Extractor reference name in all
http sampler to parameterize
Regular Expression Extractor :
In above image we have added captured session id line in regular expression field and we replace required value with (.+?)
Template is nothing
but the count of (.+?) in your regular expression ,we use $1$ to take first
value of (.+?)
Ex: input type="hidden" id="(.+?)"
name="defaultSessionID" value="(.+?)"
In above case if we want value then we have to use $2$
in template field
Match No. is position
of your regular expression in http sample result
Referance
Name is name of your regular expression which store the value of
regular expression this reference name further we use for parameterization
Using
regular expression Reference name in scripts :
We have use regular expression reference name like ${RegularExpressionReferanceName}
Like this we have to change in throughout scripts and also
we have to do for other parameters:
Some useful parameterization :
${__time(dd/MM/yyyy,)}
${__time(hh:mm a,)}
For space between two parameter KH/0187804/16(?s).+?"boRID"
value="79806">(.+?)
In above parameter one line having KH/0187804/16 <space> <neline space> "boRID" value = "79806">(Required value)
1.If controller to create condition
Writing into CSV
file using JMeter :
1.If controller to create condition
Ex: "${RegularExpression}" == " RegularExpressionValue"
Refer above image to create CSV and store values
Code inside BeanShell
:
errors = vars.get("Errors"); // Regular expression
with errors
itemName=vars.get(“Item Name”); // Regular expression to Fetch
item value
log.info(errors); // if you want to log something to jmeter.log
file
// Pass true if you want to append to existing file
// If you want to overwrite, then don't pass the second
argument
f = new FileOutputStream("yourpath/result.csv",
true);
p = new PrintStream(f);
this.interpreter.setOut(p);
print("Reference Number is," + errors);
f.close();
Thanks for Reading My Post
Adding JDBC Request in JMeter:
Now
that we defined our users, it is time to define the tasks that they will be
performing. In this section, specify the JDBC requests to perform.
- Right-click on the JDBC Users element.
- Select Add > Config Element > JDBC Connection Configuration.
- Set up the following fields (we are using MySQL
database called tutorial):
o
Variable name bound to pool. This needs to
identify the configuration uniquely. It is used by the JDBC Sampler to identify
the configuration to be used. We have named it as test.
o Database URL:
jdbc:mysql://localhost:3306(Port)/tutorial.
o JDBC Driver class: com.mysql.jdbc.Driver.
o Username: <Username for Database connection>
o Password: <Password for Database connection>
The other fields on the screen are left as
defaults as shown below:
Now add a JDBC Request which refers to the JDBC
Configuration pool defined above. Select JDBC Users element
1.
Click your
right mouse button to get the Add menu
2.
Select Add
> Sampler > JDBC Request.
3.
Select this
new element to view its Control Panel.
4.
Edit the
properties as shown below:
o
Variable name
bound to pool. This needs to uniquely identify the configuration. It is used by
the JDBC Sampler to identify the configuration to be used. Named it as test.
o Name: JDBC Request (Any name)
o Enter the Pool Name: test (same as in the configuration element).
o Query Type: Select statement.
o
Enter the SQL Query String field.
To Execute Sql Query in JMeter:
Thanks for Reading My Post
Feel Free To Comment Your Queries
Comments
Post a Comment