How to convert from String to Int for repeat loop?

I am trying to construct a repeat loop where the count is read from a CSV file. When I execute the code, I get an error

I looked at some of the other discussions, but can not find a solution for the issue I am facing.
(https://groups.google.com/forum/#!msg/gatling/GPJTzGdfs1w/Inm4wCwX1-MJ)

The HOWMANY is the 2nd value from the CSV file.

.feed(csv(“getuserinfo.csv”))

.repeat(_=>session("${HOWMANY}").as[Int]){
exec(
http(“Info”)
.post("${protocol}://${IPAddress}/api/v1/SessionService.svc")
.headers(MYHeaders.getMyInfoHeader)
.body(StringBody(SOAP_REQUESTS.soapGetUserInfoRequest))
.check(status.is(200))
).pause(1 milliseconds)
}

<<<<<<<<<<<<<<<<<<<<<<<<<

19:24:09.390 [ERROR] i.g.c.a.InnerWhile - Could not evaluate condition: Can’t cast value $HOWMANY of type class java.lang.String into int, exiting loop

Once I get past this obstacle, I will next increment the USERID in the subsequent loop.

Thanks
Pandi

You mustn’t use an EL here. That’s:
.repeat(_=>session(“HOWMANY”).as[Int]){

Thanks Stephane.

.repeat(session=>(session(“NumESN”).as[Int])){

fixed the error. However, I am kind of lost. Was looking for examples, but could not find!

I want to read the starting ID and iterate, say N times and the value N is fed from a file.

Do I need a separate function or Java code?

.feed(csv(“getuserinfo.csv”))

.repeat(3){ //this work. How to read the counter from a file?
exec(
http(“Info”)
.post("${protocol}://${IPAddress}/api/v1/SessionService.svc")
.headers(MYHeaders.getMyInfoHeader)
.body(StringBody(SOAP_REQUESTS.soapGetUserInfoRequest))
.check(status.is(200))
).pause(1 milliseconds)
}

Thanks
Pandi

First, stop tryint to use Gatling EL there! The name of the attribute is HOWMANY, not $HOWMANY.

Then, if your value comes from a csv feeder, it’s a String, not an Int, so you have to convert.

.repeat(_=>session(“HOWMANY”).as[String].toInt){

Stephane,

Thanks.

I spent enough (?) time going through the Scala and Gatling-2 documentation before coming back here. Still, I couldn’t come up with a working solution.
My problem is a simple one. I want to read sets of 2 values (start and loopnumber) from a CSV file. Send SOAP requests n-number of times beginning with the starting value increment in each iteration.

getuserinfo.csv:
startingNumber,HOWMANY

8,3
3,7
4,300

For the first line, send request with 8, 9 and 10 (3 times)
second loop will send 3,4,5,6,7,8,9,10 (7 times)
and so on.

.feed(csv(“getuserinfo.csv”)) //read startingNumber,HOWMANY values

.repeat(session=>(session(“HOWMANY”).as[String].toInt)){

exec(
http(“Info”)
.post("${protocol}://${IPAddress}/api/v1/SessionService.svc")

.headers(MYHeaders.getMyInfoHeader)

.body(StringBody(SOAP_REQUESTS.soapGetUserInfoRequest))
.check(status.is(200))
).pause(1 milliseconds)
}

Thanks,
Pandi