JMeter Beginner Tutorials | Tips n Tricks 11 💡 How to loop CSV file - WHILE CONTROLLER

  Рет қаралды 21,355

Automation Step by Step

Automation Step by Step

Күн бұрын

Today we will learn:
1. How to refer values from csv file
2. How to run the test equal to the count of rows in csv file
Step 1: Create a ThreadGroup
Step 2 : Add a WhileController
Step 3 : Add a sampler (as child of WhileController)
Step 4 : Add CSV data set config (as child of WhileController)
Step 5 : Add values. Keep
Recycle on EOF = FALSE
Stop Thread on EOF = FALSE
Step 6 : Refer the variable in sampler request
Step 7 : Add a listener. Run and validate
________________________________________________________________
Do like, share and subscribe
Keep Learning,
Raghav
_________________________________________________________________
_______ ONLINE COURSES TO LEARN _______
automationstep...
----------- UI TESTING -----------
Selenium Beginners - bit.ly/2MGRS8K
Selenium Java Framework from Scratch - bit.ly/2N9xvR6
Selenium Python - bit.ly/2oyMp5x
Selenium Tips - bit.ly/2owxc50
Selenium Builder - bit.ly/2MKNtlq
Katalon Studio - bit.ly/2wARFdi
Robot Framework - bit.ly/2Px6Ue9
----------- API TESTING -----------
Web Services (API) - bit.ly/2MGafL7
SoapUI - bit.ly/2MGahmd
Postman - bit.ly/2wz8LrW
General - bit.ly/2PYdwmV
----------- MOBILE TESTING -----------
Mobile Playlist - bit.ly/2PxpeUv
----------- CI | CD | DEVOPS -----------
Jenkins Beginner - bit.ly/2MIn8EC
Jenkins Tips & Trick - bit.ly/2LRt6xC
Docker - bit.ly/2MInnzx
----------- VERSION CONTROL SYSTEM -----------
Git & GitHub - bit.ly/2Q1pagY
----------- PERFORMANCE TESTING -----------
JMeter Beginner - bit.ly/2oBbtIU
JMeter Intermediate - bit.ly/2oziNVB
JMeter Advanced - bit.ly/2Q22Y6a
JMeter Tips & Tricks - bit.ly/2NOfWD2
Performance Testing - bit.ly/2wEXbLS
----------- JAVA -----------
Java Beginners - bit.ly/2PVUcXs
Java Tips & Tricks - bit.ly/2CdcDnJ
----------- MAVEN -----------
Maven - bit.ly/2NJdDRS
----------- OTHERS -----------
Redis- bit.ly/2N9jyCG
Misc - bit.ly/2Q2q5xQ
Tools & Tips - bit.ly/2oBfwoR
QnA Friday- bit.ly/2NgwGpw
Sunday Special - bit.ly/2wB23BO
Ask Raghav - bit.ly/2CoJGWf
Interviews - bit.ly/2NIPPxk
All Playlists - bit.ly/2LSiezA
Keep Learning,
Raghav
Website - automationstep...
LifeCharger -
Udemy Courses - www.udemy.com/...
Facebook - / automationstepbystep
Twitter - / automationsbs
KZbin - / automationstepbystep

Пікірлер
@krithigar6587
@krithigar6587 5 жыл бұрын
Excellent. Nowhere it is explained this way without hiding the steps.Thanks a lot :)
@RaghavPal
@RaghavPal 5 жыл бұрын
You're welcome Krithiga
@praveenbudde2494
@praveenbudde2494 5 жыл бұрын
Hi Raghav , could you please tell me how to use below controllers 1.For each controller in jmeter 2.Critical section controller in jmeter
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Praveen, I will create a session on this. Until then pls refer online
@slobodanparizoski6869
@slobodanparizoski6869 Жыл бұрын
So basically, the While controller checks: while(variable exists == true)...execute sampler. And the CSV data config is taking care on every new step, new line to be checked?
@RaghavPal
@RaghavPal Жыл бұрын
Hi Slobodan, The While controller in JMeter executes its child samplers repeatedly as long as the specified condition is true. In your case, the condition is "variable exists == true". The CSV Data Set Config element is responsible for reading data from a CSV file and making it available to the test plan. Each line in the CSV file represents a set of values that can be used in a test. Each time the test plan runs, the CSV Data Set Config element reads the next line from the CSV file and makes its values available to the samplers that reference it.
@manekagayomi9079
@manekagayomi9079 5 жыл бұрын
Hi Raghav,I have a test scenario for validate the email address.For that I create a csv which contain multiple email address in different format.I added this using file through the csv data config. Is there any way to add assertion for each row of the csv?because I need fully automate that test and get only the pass/fail status.
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Maneka, look at this like, any value that you put in your jmeter test, you can get it from csv. So if you use any assertion element and you put a value, you can get it from csv. You just need to add csv data set config. So the setup and use the variable name like ${varName} in place of your value. Hope you have seen the csv data set config video. automationstepbystep.com/909-2/online-courses/
@debasishdash2253
@debasishdash2253 4 жыл бұрын
Can we run a test plan in a particular time, so that I can set the time and the test plan will run on that time which I already have been set.(Both in cmd line and in GUI of jmeter)
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Debasish, you can use the Scheduler section in ThreadGroup Check - www.quora.com/How-can-we-set-a-scheduler-in-a-JMeter For command-line mode, you can use some in-built tool for scheduling running of your commands. For e.g. check this - stackoverflow.com/questions/35175784/i-want-to-schedule-task-at-particular-time-using-jmeter
@hassanchreif7761
@hassanchreif7761 2 жыл бұрын
hi raghav, i have a post http request (create product), the data uploaded as json file to the http sampler ( not as body), and i want to repeat this request in the same iteration ( creating 10 products for example), the problem is that i receive an error response "product already exist" plz advise how we can handle this problem.
@RaghavPal
@RaghavPal 2 жыл бұрын
You can add some random string in some value so that i will be taken as a unique product and will not duplicate, Can use functions in JMeter
@hassanchreif7761
@hassanchreif7761 2 жыл бұрын
​@@RaghavPal thanks for your quick response, i want to create 10 different products by the same post request, and the data are uploaded to the sampler as a json file and i tried to use a functions in the parameters tab, but the ProductName still the same as defined in the Json file uploaded. your response is highly appreciated and thanks in advance.
@RaghavPal
@RaghavPal 2 жыл бұрын
Hi Hassan, you can append some random string by using random function, something similar to this- stackoverflow.com/questions/56661408/how-can-i-add-random-value-using-jmeter-in-json
@samirmulani1910
@samirmulani1910 3 жыл бұрын
Hi Ragha, I want to import TX id which are in CSV file more than 2500 Txs. And those are used as a restApi. Those should be thread safe while executing and as I don't know how much time it will take so no value for rampup. And every thread should take unique value. Is it possible?How to do?
@RaghavPal
@RaghavPal 3 жыл бұрын
HI Samir, in case the txn id can be random, you can just use the random function But if the tx ids are fixed, you can put them in csv and use CSV Data Set Config, every thread will take the value from next row
@samirmulani1910
@samirmulani1910 3 жыл бұрын
@@RaghavPal Agreed. You have a great experience man👍
@hazimabdoh6303
@hazimabdoh6303 Жыл бұрын
dear Mr Raghaf : to keep: Stop Thread on EOF = FALSE OR TRUE ?? thanks alot
@RaghavPal
@RaghavPal Жыл бұрын
Hi Hazim, it depends on your needs, if you want to stop each thread when the last row of the csv file is reached you can make it True Else if you like it to continue from the 1st row, can keep it false
@hazimabdoh6303
@hazimabdoh6303 Жыл бұрын
@@RaghavPal thanks a lot
@anoopbhaskaran3908
@anoopbhaskaran3908 4 жыл бұрын
Sir,Do we have a feasiblity to fetch the data from CSV and put the result into CSV file when ever we run ?.
@RaghavPal
@RaghavPal 4 жыл бұрын
Yes, can do that Anoop, will have to explore some examples online
@anoopbhaskaran3908
@anoopbhaskaran3908 4 жыл бұрын
@@RaghavPal Can you please one example so that it will help others as well sir
@RaghavPal
@RaghavPal 4 жыл бұрын
Sure I will plan a session
@vivekijeri
@vivekijeri 6 жыл бұрын
Hi Raghav, Here you have shown how to fetch data from multiple rows from CSV for a single request. In my case I want multiple request, lets say 6 request to fetch data from 6 different rows with columns containing around 10-12 parameters. How do I achieve this ? Please help me out on this.
@RaghavPal
@RaghavPal 6 жыл бұрын
Hi Vivek, so you can create a csv according to your need and also parametrize your tests accordingly. for exmaple in your case you need 10 parameters. So your csv file will have 10 columns and you can provide your paramter name as header for each column. Then in your tests you can use the same variables.
@vivekijeri
@vivekijeri 6 жыл бұрын
Hi Raghav, I have added all parameter names as headers in the first row but that was not my query. My query is I have 5 rows of parameters and I have 5 requests. I want 1st request to fetch data from 1st row ( excluding the header ) and 2nd request to fetch from 2nd row and so on ... how do I achieve this ?
@YouPinguim
@YouPinguim 4 жыл бұрын
Thank you so much!
@RaghavPal
@RaghavPal 4 жыл бұрын
You're welcome Pedro
@TheFlashmark
@TheFlashmark 5 жыл бұрын
Hi Raghav, I'm using JMeter for functional (API) test for my iOS App. When login to the App, there are several records (rows). User can tap any of the row. I want to tap each and every record (row). Is there a way to do this?
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Lakmal, in case of web ui you can try to record this scenario and check the sampler. For API, you might have to fetch the urls and then in subsequest request keep on invoking the fetched urls. Look at correlation and json extractor videos.
@TheFlashmark
@TheFlashmark 5 жыл бұрын
@@RaghavPal Can't we use a loop for this? The loop should run from Record 1 - Record n.
@RaghavPal
@RaghavPal 5 жыл бұрын
Yes, if loop works for you, go for it.
@GirishKumar-uq1uh
@GirishKumar-uq1uh 2 жыл бұрын
i want to generate a excel where i can get this ouput ("1","name","23123","test") I tried in csv it works. but when i open in XL it is not reflecting the quotes can you help on this
@RaghavPal
@RaghavPal 2 жыл бұрын
Hi Girish, will need to check on this
@sagarsalvi4957
@sagarsalvi4957 2 жыл бұрын
Could you please show me how to deal with body data in create order when we using csv file
@RaghavPal
@RaghavPal 2 жыл бұрын
Hi Sagar, I will check on this
@chaitp863
@chaitp863 4 жыл бұрын
Hi Raghav , I have a scenario where in I need to wait for the response text .I need to send the same request till i get the required response text. I included my http samples in while loop with a counter. Now I am not able get the correct while condition. Tried with below conditions. ${__javaScript(("${recordTypeLabel1}"!="NPAC Pending" && ${counter} < 5),)} ${__jexl3("${recordTypeLabel1}" != "NPAC Pending",)} Both are failing. How to handle this? Threadgroup --Once only controller --> Login -- loop controller -HTTP req -HTTP req -While loop --Counter --HTTP request --HTTP Request --JSON extractor ( I am getting recordTypeLabel1 variable here) -HTTP req --Once only Controller --> Logout
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Chait, I may not have completely understood you, but when you add a request and then add JSON extractor it will take care of the rest of the things provided the json path and settings are correct. Also check the video - kzbin.info/www/bejne/aaiTqWmraZJppMk
@gayatritankar7856
@gayatritankar7856 9 ай бұрын
Hello sir, How can I pass the parameter for a quiz where multiple users can play the same quiz simultaneously through JMeter(I am testing APIs)? I made a CSV file for login credentials, when I tried to run it in JMeter it worked fine. After that, I created another CSV file for contest-id, and trying to run it's not working because here I have passed a specific user Token. I don't understand how can I pass multiple tokens to multiple users. Could you please reply? This quiz is like a mcq question. Also, how can we select different answers for multiple users? Can we add more CSV file in a single Thread? Please reply. #raghavpal #automationstepbystep #raghavsir
@RaghavPal
@RaghavPal 9 ай бұрын
Gayatri Here's how to achieve multiple users taking a quiz with different tokens and answers in JMeter: 1. Combine CSV Data: - Use a single CSV file with all required data: ``` username,password,token,contest-id,answer1,answer2,answer3 user1,password1,token1,123,A,B,C user2,password2,token2,123,B,C,A ``` - Alternatively, use multiple CSV Data Set Config elements with proper configuration. 2. Configure CSV Data Set Configs: - Add two CSV Data Set Config elements: - One for login credentials (username and password). - One for quiz data (token, contest-id, and answers). - Set variables for each field: - `${username}`, `${password}`, `${token}`, `${contest-id}`, `${answer1}`, etc. 3. Pass Parameters in HTTP Request: - Use variables in request parameters: - `api.example.com/login?username=${username}&password=${password}` - `api.example.com/quiz/${contest-id}?token=${token}&answer=${answer1}` 4. Simulate Multiple Users: - Use a Thread Group with multiple threads: - Each thread represents a virtual user. - JMeter iterates through CSV data, assigning different values to each thread. 5. Select Different Answers: - Use a Random Variable element for answer selection: - Set variable name (e.g., `${randomAnswer}`). - Choose distribution (e.g., uniform). - Set possible values (e.g., `A`, `B`, `C`). - Use `${randomAnswer}` in request parameters. 6. Additional Considerations: - Correlation: Extract dynamic values (e.g., tokens) using Regular Expression Extractor or JSON Extractor and store them in variables for later use. - Assertions: Verify responses to ensure successful logins and expected quiz behavior. - Think Time: Add pauses between requests to simulate real user behavior. - Parameterization: Use JMeter's parameterization features for flexibility and reusability. - Performance Testing: Use JMeter to measure response times and server load under concurrent users.
@gayatritankar7856
@gayatritankar7856 9 ай бұрын
Thanks for your reply, Sir here I have a query I need tokens from Postman, so how can I generate multiple tokens for multiple users, is there any way to do it generate tokens easily because I have to run thousands of users in JMeter@@RaghavPal #RAGHAVSIR #AUTOMATIONSTEPBYSTEP #raghavpal
@RaghavPal
@RaghavPal 9 ай бұрын
Gayatri Here are strategies to efficiently generate multiple tokens for thousands of JMeter users: 1. Automated Token Generation in Postman: - Script the login request: Use Postman's test scripts to automate login and token retrieval for different user credentials. - Extract tokens: Use `pm.response.json().token` (or similar, depending on API response structure) to extract tokens. - Store tokens: Save tokens in a file (CSV, JSON, etc.) or a database. 2. Leverage Token Generation API (if available): - Directly create tokens: If the API offers a dedicated endpoint for token generation, use it to produce multiple tokens programmatically. 3. Integrate Postman with JMeter: - Export Postman collection as JMX: Convert your Postman collection to a JMeter test plan, including recorded login requests and token extraction. - Dynamically retrieve tokens: Use Meteor’s CSV Data Set Config or other parameterization techniques to read tokens from a file and use them in subsequent requests. 4. Use JMeter's Built-in Features: - HTTP Request Defaults: Set common headers (e.g., Authorization) for all requests in a Thread Group. - CSV Data Set Config: Read tokens from a CSV file and assign them to variables for use in requests. - User Defined Variables: Pre-define tokens as variables for use across multiple requests. Additional Considerations: - Token Validity: Ensure generated tokens have sufficient lifespan for your test duration. - Token Handling: Manage token refresh or replacement if they expire during testing. - Security: Implement robust security measures to protect token confidentiality. Choose the most suitable method based on: - API capabilities - Token generation logic complexity - Desired level of automation - Integration with JMeter
@gayatritankar7856
@gayatritankar7856 9 ай бұрын
Thank you so much I will try this for sure. @@RaghavPal 🙏
@kranthikumar2367
@kranthikumar2367 4 жыл бұрын
Hi Ragav,after executing request with while controller and then my subsequent requests are not executing ..can you please let me know what to do for this??
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Kranthi, will have to see your setup. Just try to debug and find out - kzbin.info/www/bejne/bXusZHp6Zc6Zitk
@Lucifer-sl7hh
@Lucifer-sl7hh 6 жыл бұрын
Please update a course for taurus also
@RaghavPal
@RaghavPal 6 жыл бұрын
sure will plan to do that Shubham
@Lucifer-sl7hh
@Lucifer-sl7hh 6 жыл бұрын
thanxxx
@brynz2010
@brynz2010 5 жыл бұрын
Hi Raghav, how do i use Jmeter response parameter for another request input parameter
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Brian, you can check this kzbin.info/www/bejne/bV6xlKyQqrqEpNk kzbin.info/www/bejne/aaiTqWmraZJppMk&list=PLhW3qG5bs-L-oMT1Cnrurt7gEaLrRub2V&index=6
@victoradolfomosqueragonzal6704
@victoradolfomosqueragonzal6704 4 жыл бұрын
My application uses keycloak and angular when recording the test only stores the requests to the keycloak and not to the rest services
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Victor, not very sure, Will have to check on this online
@DouglasSilva-pq5hk
@DouglasSilva-pq5hk 2 жыл бұрын
There is anyway to loop trought a csv inside another loop?
@RaghavPal
@RaghavPal 2 жыл бұрын
Hi Douglas, will need to check
@laxvaru3290
@laxvaru3290 3 жыл бұрын
Hi sir how to write the iteration number of thread group to csv file using beanshell post processor
@laxvaru3290
@laxvaru3290 3 жыл бұрын
Sir could you please give me the solution
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi, I will need to check on this. Can try some online examples
@kashmiradugad5161
@kashmiradugad5161 6 жыл бұрын
hi.In my csv i have 10 rows and for single thread i want to read whole csv.please give the solution.
@RaghavPal
@RaghavPal 6 жыл бұрын
Hi Kashmira, did you check this video - kzbin.info/www/bejne/l3nCi5uDp817nqs
@ASHISH1441
@ASHISH1441 6 жыл бұрын
In CSV data set config. Make Recycle on EOF false and stop thread on EOF true.
@tejasvinerkar2514
@tejasvinerkar2514 6 жыл бұрын
Hi Raghav, I have used same method but it not working. In result tree showing me result as "GET ${URL}/". Can you help here. I have list of 100 URLs.
@RaghavPal
@RaghavPal 6 жыл бұрын
Hi Tejas, so its not able to get ${URL}. How are you referring this. Any logs?
@andyueapisit3442
@andyueapisit3442 6 ай бұрын
If I add more column in csv file, how to do in JMeter
@RaghavPal
@RaghavPal 6 ай бұрын
Andy To add more columns to a CSV file in JMeter, you can follow these steps: 1. Prepare Your CSV File: Add the new column manually to your CSV file using a text editor or a spreadsheet program like Excel. Ensure that the header row (if present) and all subsequent rows have the new column added. 2. Update JMeter Test Plan: If you're using the CSV file with a CSV Data Set Config element in JMeter, update the "Variable Names" field to include the name of the new column. 3. Use the New Column in Your Test: Reference the new column in your JMeter test plan by using the variable name you assigned to it in the CSV Data Set Config. Here's an example of how you might use the new column in a JMeter test: ```groovy // Assuming the new column is named 'newColumn' and you've added it to the CSV Data Set Config String newColumnValue = vars.get("newColumn"); // You can now use 'newColumnValue' in your test plan as needed ``` Remember, JMeter is primarily a load testing tool, not a CSV manipulation tool. If you need to add columns programmatically or perform complex CSV manipulations, consider using a scripting language like Python or Groovy, which can be integrated into JMeter through JSR223 Test Elements. If you're looking to append data to specific columns of an existing CSV using JMeter, you can use a JSR223 Sampler with a Groovy script. Here's a simplified example of how you might append data to specific columns: ```groovy def csvFile = new File('path/to/your/file.csv'); def lines = csvFile.readLines(); def newLines = []; lines.each { line -> def columns = line.split(','); // Assuming you want to add data to the third and fifth columns columns[2] = 'newDataForThirdColumn'; columns[4] = 'newDataForFifthColumn'; newLines
@manishchopra9755
@manishchopra9755 4 жыл бұрын
Hi Raghav, Can you help me with integrating 2 while controllers. I used CSV data config and while controller. For first iteration of CSV the second while controller executes but the second iteration of CSV row does not execute second while controller
@RaghavPal
@RaghavPal 4 жыл бұрын
I will have to check the setup and logs Manish
@ksridhar291989
@ksridhar291989 5 жыл бұрын
How to use for each controller . after adding i didnt get response in View results tree
@RaghavPal
@RaghavPal 5 жыл бұрын
Will have to see your setup Sridhar
@ullaste355
@ullaste355 6 жыл бұрын
How to get the data from database instead of csv by using while loop?
@RaghavPal
@RaghavPal 6 жыл бұрын
Hi Ullas, this should help you - stackoverflow.com/questions/31264820/use-database-table-as-csv-dataset-for-jmeter
@chandrupsekar
@chandrupsekar 2 жыл бұрын
how to get the last row number of the csv file
@RaghavPal
@RaghavPal 2 жыл бұрын
Hi Chandra, can check this stackoverflow.com/questions/61305057/jmeter-how-to-read-particular-row-data-in-csv-file-based-on-a-column-value-and
@subhrajaghsoh1299
@subhrajaghsoh1299 4 жыл бұрын
how to restrict transaction?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Subhraja, can check this - stackoverflow.com/questions/35967902/jmeter-control-transaction-rate-for-transaction-controllers
JMeter Beginner Tutorials | Tips n Tricks 12 💡 How to use TIME FUNCTION
4:20
Automation Step by Step
Рет қаралды 10 М.
JMeter Beginner Tutorials | Tips n Tricks 5 💡 How to use JSON Extractor
14:14
Automation Step by Step
Рет қаралды 46 М.
Incredible: Teacher builds airplane to teach kids behavior! #shorts
00:32
Fabiosa Stories
Рет қаралды 12 МЛН
Watermelon magic box! #shorts by Leisi Crazy
00:20
Leisi Crazy
Рет қаралды 95 МЛН
Help Me Celebrate! 😍🙏
00:35
Alan Chikin Chow
Рет қаралды 76 МЛН
小路飞嫁祸姐姐搞破坏 #路飞#海贼王
00:45
路飞与唐舞桐
Рет қаралды 28 МЛН
JMeter tutorial 07 - How to read data from CSV File | Parameterization in JMeter
16:12
9 | JMeter | HowToGetDataFromCSVFile |
12:14
Automation Step by Step
Рет қаралды 16 М.
JMeter Beginner Tutorial 16 - Functions and Variables
13:58
Automation Step by Step
Рет қаралды 91 М.
JMeter Beginner Tutorial 28 - Remote Testing | Master Slave | Distributed Testing
17:55
Incredible: Teacher builds airplane to teach kids behavior! #shorts
00:32
Fabiosa Stories
Рет қаралды 12 МЛН