Working with database in JMeter

Scenario:- Creating a database test plan, such that we can do the performance testing for CRUD operations.

Key Points:- 
1. JDBC connector files(jdbc jar).
2. Database connection details, so we can communication with database.
3. JDBC request, this is important to set the database connection details in jmeter

Step1:- Download the required connector file and place in lib folder of jmeter
For our example we have taken mySQL db, so we need the relevant connector(jar file).

Extract and place the file inside the lib folder in jmeter 

mysql connector placed in lib folder jmeter

Step2:-Add users as we did in our first test case.

Step3:-JDBC Connection configuration,establishing the connection of jmeter with database.

Right click “Thread Group” > ADD > Config element > JDBC Connection configuration
Fill the variable name, database name, driver details, and access credentials for the database.
jdbc connection with jmeter

Step4:-Use JDBC request to communicate with database and execute CRUD operations.

Right click “Thread Group” > ADD > Sampler > JDBC request.

Use the same Variable Name as we used in Step3, why ? as it tells jmeter to use the given connection string and its adds flexibility that in future we can use different connection string by adding new jdbc configuration and updating the variable name in jdbc request.

Add the CRUD operation (query)

jsbc request in jmeter

Note:- In working code we have added extra “Regular Expression Extractor”, just to extract a given value from the response of query and add that value to a variable that we can use in the future requests.

Step5:-Add reporting.

Step6:- Run 🙂

Creating first test case using Jmeter?

Scenario:- How to create a basic level test case(its called test plan) in jmeter?

Most of us things that ppl r born smart, but truth is 99% of the smartest ppl n this world are driven by commitment to learn, learn and learn more.Learn more and share more 🙂 Fb,G+,Twitter

1.Test plan :- Container for running the tests. Its the starting point, by default jmeter opens up with test plan.

2.Users(called as Thread Group in JMeter) :- How many users should be involved in sending the request to the server, how often, and ramp up time.
Why this ? it mimics the interaction of real users with the application at given time.

3.Task( what type of request that needs to be send to server, called as Samplers):-For example if we want to access the we are sending http request thus we need a particular type of sampler called http request sampler. If we are sending request to database we make use of jdbc sampler.

Note:- JMeter sends request to server based on the order they appear in the tree.

4.Assertions:– Verify the response send by server, comparing the actual value with expected value.

5.Report(called as Listeners in JMeter):- Request is send to server how to report the results for the response, we use Listeners for this.

Solution:- Lets create a pipeline for the above steps, 

ThreadGroup (We created users) > Samplers (users send request to server) > Assertions (Verify the response for the request) > Listeners (Report the response results as graphs, table and so on).

Step1:Launch jmeter 
Step2:-Add thread group 
Note:- We have renamed the test plan in our example below.

Right click Test Plan > Add > Thread(Users) > Thread Group
Rename Thread group to something logical.
Change the thread properties like number of users.

Thread group in jmeter

Step3:-Add sampler 

Right click Thread Group > Add > Sampler > HTTP Request 
Rename it something logical
Define user defined variables for a test plan (FirstTestCaseJMeter) .

  • Open test plan
  • click on Add
  • Enter name and value
Why this as it add to maintainability of application url at one place.

user defined variables in jmeter

Add APP variable into the Sampler “Server Name” like ${APP}(this is how we use variable value in jmeter ${variableName}
Select the method as “GET”

http request jmeter

Note:-Incase we need to pass any parameters or body elements we can do it here.

Step4:-Assertions (say to check 200 status code)
Right click Thread Group > Add > Assertions > Response Assertion
Select ReponseCode  and Equals, put value as 200 

response assertion jmeter

Step5:-Listeners (Report the run results)
Right click Thread Group > Add > Listener > View Result Tree

Step6:-Run the test plan
Before running we need to save the .jmx file
Ways to run :-

  • Run > Start
  • Ctrl + r
  • Green play button on the menu bar
jmeter run options

Step7:-Check the run results
Select View Result Tree
Its green, means our assertion is successful and we got the response back 🙂

run results jmeter

So we successfully created the basic test plan in jmeter. To explore more change the listener type, add more users and add different type of assertions.

Learn more and share more.

Jmeter Error :- Cannot have single quote-char in quoted field:[“] ?

Problem:-We used CSV data Set Config element in our Jmeter test to parameterize our request. But we faced the below error in logs:-

ERROR – jmeter.config.CSVDataSet: Cannot have single quote-char in quoted field:[“] 

Open the “CSV Data Set Config” > Set “Allow quoted data?” to False (By default is true)

CSV DATASET jmeter quote error

Why this as Jmeter by default will think “(quote) value in CSV file as delimiter, along with the ,(commas).

Its always recommended to refer the jmeter logs if you are not getting the expected behaviour from the tool, as for above error we were just getting as parameters values in request data for sampler.
EOF in CSV data set error

Learn JMeter
Learn Selenium
Learn JAVA

Learning Jmeter

As always our focus is to share the pragmatic approach as we did before on other tools like Selenium / UFT /RobotFramework , helping everyone to learn a new skill set in a crisp and clear way.

Connect with us for more learning:-Fb,G+,Twitter

apache jmeter tutorial

Leaning a new technology is a cake wake if we have the right mindset and proper guidance…

Keep sharing and keep leaning 🙂

How to install Jmeter?

Minimum is Java 7 (JVM) , taking the latest jmeter version into consideration.
Install Java first and verify it by typing  java –version on terminal.

Note:- Jmeter is based on Java platform thus it works seamlessly on any OS, provided its java compatible (ex windows/Linux/Mac..) 

We have considered Linux OS for our tutorial, incase you are using any other OS, download it from the official link.

Step1:- Download jmeter binary

jmeter download link

tar -xf apache-jmeter-3.0.tgz 

unzip jmeter tar

Step3:-Browse to apache bin folder
cd apache-jmeter-3.0/bin

launch jmeter linux

Launch jmeter in ubuntu

Note:- Want to know the jmeter commands

./jmeter -? 

jmeter help launching in linux

Selenium interview questions Part-3

QA Developer interview questions for SAP….

sap qa developer interview questions

1.Explain the Architecture of Selenium?

2.How is it possible to implement Selenium using different languages?

3.How can we check that application is responsive?

4.What is the data structure that implement LIFO?
Hint:- Stack

5.How to search “selenium” from 10,000 text files in a Folder?

6.How we can improve the performance of select query?

7.Key challenges you face while starting with automation?

8.Code Snippet, below how to fetch the text of second li without getting the text of anchor tag using selenium?

fetch text li using selenium

9.How to get the non existing elements from array1[1,3,4,5] in array2[3,1,5,7] using any language?

More Interview Questions?

Selenium Interview Questions – Part-2

Interview questions for Amazon first telephonic round for QAE role. 

Do share your experience or questions in the comments section to help others QA fellows in cracking the interviews.

QAE amazon interview questions

It said If you stumble make it part of the dance.

Lets prepare well and if we stumble just make it part of the answer 🙂

1.What are you doing in your current role?

2.Key challenges in working with Selenium?

3.Difference between / and // in xpath?

4.CSS selector to select the nth child?

5.How you will investigate a  website that is taking too long to load?

6.Write test cases for Tiny Url application?
Note:- tinyUrl application is used to reduce the long URL into precise URL’s

7.Coding question,in a list of integers can you find the combinations of integers that sums to k?
Will ask the complexity and how to improve the code further.

8.Have you created test plans or test strategy, what is the difference ?

First round is the elimination round, they will ask very basic questions just to check whether its worth interviewing the person face to face, in amazon office and having more 5 rounds 🙂

More interview Questions?

How to create executable JAR for TestNG class using intellij and gradle?

Problem:- How to create a executable JAR for testng class using intellij + gradle.

Tool stack :– Intellij (IDE) + Gradle (Build tool) + TestNg (Testing framework)

Share more learn more  FbG+,Twitter 

GITHUB for complete code

Step1:– Create a basic java class to display “HelloBuild!”, execution using TestNG.

public class TestBuild {
public void test() {

Step2:-Browse to the parent directory of the java class using Terminal/Command prompt > gradle clean 

This is used to clean any existing build directory (cleaning everything including leftovers from previous builds which are no longer relevant. )

Step3:- gradle build, build the java projects and create the JAR package inside build > libs > test-****.jar

Step4:- Now our jar package is ready lets browse to this package and try to run the java class
java – jar test-****.jar

This failed with “no main manifest…”

Step5:-add the below line to your build.gradle

jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
manifest {
attributes 'Main-Class': 'TestBuild'

Main-Class : ‘Name of the class to be build

Step6.:- if we repeat step2 > step 4 again, this time, you will get the “no main method error” as below. As our code doesn’t contain any main method to start the execution.

Step7:- Here comes the final solution…Adding the below code inside our main method in the “TestBuild” class and add the testng.xml file containing the TestBuild class name as below.

Now repeat the build process above, this time it will execute the code and print the “HelloBuild!”


Main Method:-

    public static void main(String[] args) {
TestNG testng = new TestNG();
List suites = Lists.newArrayList();

testng.xml file:-

<!DOCTYPE suite SYSTEM "" >
<suite name="BuildTest">
<test name="FirstTest">
<class name="TestBuild"/>

Learn More JAVA 
Learn Automation