Random value from csv in a repeat statement

19 views
Skip to first unread message

Rajat Singh

unread,
Sep 24, 2016, 4:54:07 AM9/24/16
to Gatling User Group
Hi folks,

I want to choose random value for every iteration for csv file 


.repeat(3){ // repeating the iteration 3 times and everytime i want that new value it takes from the csv file
feed(search)// Here i am putting the csv file 
exec(http("Search")
.get("/en/search/searchkey?text=${product}")// product is name of the column in csv file
.headers(headers_1)
.check(regex("""productURL\":\"/ralphlauren/en/mens/(.+?)\"""").findAll.saveAs("test1")))
.exec( session => {
val listB=session( "test1" ).as[List[String]]// converting the session variable test1 into list
val size = listB.size// size of the list
val OrderRef = r.nextInt(size);
val test12=listB(OrderRef)
  println( "Size of list is" )
  println( test12 )
  println(size)
  println(OrderRef)
  session
})
 



.pause(1)
.exec( session => {
  println( "product:" )
  println( session( "product" ).as[String] )// Using session variable i am printing the value which is fetched from csv file 
  session
})
}
Reply all
Reply to author
Forward
0 new messages