Home > Net >  In JMeter How to iterate the requests with nested conditions based on defined input
In JMeter How to iterate the requests with nested conditions based on defined input

Time:10-30

In JMeter How to iterate the requests with nested conditions based on defined input

In my application, we have 3 requests

  1. Get Vehicle Type (we need to choose car, bikes)
  2. Enter Brand Name of the car/bike
  3. Enter model name of car/bike

I have only three requests but based on my inputs, I need to iterate the loops for request. In the below table given an example flow for iterations

: Enter Vehicle Type - Car : 1st request :

: Enter Brand Name - TATA : 2nd request with first brand :

: Enter model - Altroz : 3rd request with first model :

: Enter model - Nexon : 3rd request with second model :

: Enter model - Harrier : 3rd request with third model :

: Enter Brand Name - Maruthi : 2nd request with second brand :

: Enter model - Swift : 3rd request with first model :

: Enter model - Baleno : 3rd request with second model :

In the above example first request will be sent only once but brand and model requests iterated based on input. In the above table for brands I need to iterate 2 times and inside 1st brand I need to iterate models 3 times and inside 2nd brand need I reiterate models 2 times. Can we achieve this using any loop controller or do we need to write scripts to achieve the same and also how can we set csv data for the same when multiple users or threads running the same

CodePudding user response:

I think in order to achieve the same you need to have separate CSV files for the same.

Like:

  1. vehicleType.csv

    Car
    
  2. brands.csv

    TATA
    Maruthi
    
  3. TATA.csv

    Altroz
    Nexon
    Harrier
    
  4. Maruthi.csv

    Swift
    Baleno
    

Once done in order to read the same you could use __CSVRead() function

Using Loop Controller is a good idea, you can use __groovy() function to count the number of lines in this or that CSV file so you will know how many time to loop for the same

Check out How to Pick Different CSV Files at JMeter Runtime

  • Related