-->

Practical issues and solutions for working with JMeter - Part1

Most of the time we are struck with very granular issues with JMeter. To overcome these type of hurdles we are sharing the pragmatic solutions to problems.

Do share your issues/solutions in the comment section below to help others as we always believe sharing is caring, and Life is short..share while you still have knowledge

Scenario:- 
How to pass random value in Json URI or Json parameters for API call using Jmeter?

Solution :- 
By using "Random Variable"
Where to find in JMeter
Add > Config Element > Random Variable

Name the variable as you want, put the range or create your own formula and start using this variable in Json URI or Json parameters


Random variable in jmeter

Scenario:- 
Not to execute the second sampler if first sampler value fails in Jmeter?

Solution :- 
By using "if controller"
Where to find in JMeter
Add > Logic controller > if controller

In condition add ${JMeterThread.last_sample_ok} 
Note:- Above value is predefined variables in jmeter


if controller jmeter

Scenario:- 
How to execute python script(command script) in jmeter?

Solution :- 
By using "OS sampler"
Where to find in JMeter

Add > Sampler > Os sampler

Example:- Lets say we want to run our MQTT test generator code
We will replicate the command step in OS sampler, 
python3 mqttgen.py 10 10 1  and define the working directory(referring to the script path)

command script from jmeter

More scenarios

Working with database in JMeter

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

Solution:-
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


Prerequisites:-
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 google.com 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: java.io.IOException: Cannot have single quote-char in quoted field:["] 

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

Note:-
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?

Pre-requisite:- 
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

Step2:-Unzip 
tar -xf apache-jmeter-3.0.tgz 


unzip jmeter tar


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

Step4:-Launch  
./jmeter
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?
Hint:-.parent_class:nth-child(1

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?