how to use foreach

I have an section of my gatling script that I want to repeat about 30 times, I want have a counter for each time it loops and use that counter.

for example wnat to loop through the below code 30 times and use the counter to replace the day in the date.

.exec(http(“request_40”)

.post(“https://server1.com/userportal/trips/save”)
.headers(headers_40)

.param(""“tripDay”"", “”“2013-05-DAY”"")

I am not sure I understand using .foreach

foreach is for looping on a sequence attribute stored in the Session, for example, a list of links captured in a previous page with a regex.
What you want is a simple repeat(30, “nameOfTheCounter”) {


.param(""“tripDay”"", “”“2013-05-${nameOfTheCounter}”"")
}

yes that worked, thanks

sorry it didn’t work. I am using
.repeat(2,“DAY”){
exec(http(“request_42”)
.post(“https://qa.crsinc.com/userportal/trips/save”)
.headers(headers_42)
.param(""“id”"", “”"""")
.param(""“commuteDistance”"", “”"""")
.param(""“customFields[purpose]”"", “”“Visit to Everything Just A Buck ${DAY}”"")
.param(""“distance”"", “”“0"”")
)
}

this always substitutes the value 0

this is my entire code
package junk
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import com.excilys.ebi.gatling.jdbc.Predef._
import com.excilys.ebi.gatling.http.Headers.Names._
import akka.util.duration._
import bootstrap._
import assertions._

class junk extends Simulation {

val httpConf = httpConfig
.baseURL(“https://server1:443”)
.acceptHeader(“image/png,image/;q=0.8,/*;q=0.5”)
.acceptEncodingHeader(“gzip, deflate”)
.acceptLanguageHeader(“en-US,en;q=0.5”)
.connection(“keep-alive”)
.userAgentHeader(“Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0”)

val headers_1 = Map(
“Accept” → “”“text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"”",
“Cache-Control” → “”“max-age=0"”"
)

val headers_2 = Map(
“Accept” → “”“text/css,/;q=0.1"”",
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40ec2-208a4-4ddf06a7579ff”"""
)

val headers_3 = Map(
“Accept” → “”"/""",
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:55 GMT”"",
“If-None-Match” → “”"“41b06-1faca-4ddf06a78ae4f”"""
)

val headers_4 = Map(
“Accept” → “”"/""",
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40ec3-a9c23-4ddf06a7585b7"”""
)

val headers_5 = Map(
“Accept” → “”"/""",
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40ec7-2211-4ddf06a75899f”"""
)

val headers_6 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“407c5-4da-4ddf06a73ff17"”""
)

val headers_7 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40ecc-39d-4ddf06a75899f”"""
)

val headers_8 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40ecd-e3b3-4ddf06a75899f”"""
)

val headers_9 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“407c2-4d4-4ddf06a73ff17"”""
)

val headers_10 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“407c7-acdf-4ddf06a73ff17"”""
)

val headers_11 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40ecf-6df-4ddf06a75899f”"""
)

val headers_12 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“407ee-39f8-4ddf06a741687"”""
)

val headers_13 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“407eb-a50c-4ddf06a741687"”""
)

val headers_14 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“407c6-909-4ddf06a73ff17"”""
)

val headers_15 = Map(
“Accept” → “”“text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“401ff-47e-4ddf06a6f3487"”""
)

val headers_16 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40325-19b3-4ddf06a73d807"”""
)

val headers_17 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:55 GMT”"",
“If-None-Match” → “”"“4187a-333-4ddf06a78585f”"""
)

val headers_18 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40eca-734-4ddf06a75899f”"""
)

val headers_19 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:55 GMT”"",
“If-None-Match” → “”"“418d7-152d-4ddf06a786417"”""
)

val headers_20 = Map(
“Cache-Control” → “”“max-age=0"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:55 GMT”"",
“If-None-Match” → “”"“418a4-303-4ddf06a78602f”"""
)

val headers_21 = Map(
“Accept” → “”“text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"”",
“Cache-Control” → “”“no-cache”"",
“Content-Type” → “”“application/x-www-form-urlencoded; charset=UTF-8"”",
“Pragma” → “”“no-cache”"",
“X-Requested-With” → “”“XMLHttpRequest”""
)

val headers_22 = Map(
“Accept” → “”“text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"”"
)

val headers_23 = Map(
“Accept” → “”“text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"”",
“If-Modified-Since” → “”“Mon, 03 Jun 2013 08:58:40 GMT”""
)

val headers_24 = Map(
“Accept” → “”“text/css,/;q=0.1"”",
“If-Modified-Since” → “”“Mon, 03 Jun 2013 08:59:20 GMT”""
)

val headers_25 = Map(
“Accept” → “”"/""",
“If-Modified-Since” → “”“Mon, 03 Jun 2013 08:59:20 GMT”""
)

val headers_30 = Map(
“If-Modified-Since” → “”“Mon, 03 Jun 2013 08:58:40 GMT”""
)

val headers_31 = Map(
“Accept” → “”“application/json, text/javascript, /; q=0.01"”",
“X-Requested-With” → “”“XMLHttpRequest”""
)

val headers_33 = Map(
“Accept” → “”"/""",
“X-Requested-With” → “”“XMLHttpRequest”""
)

val headers_42 = Map(
“Accept” → “”"/""",
“Cache-Control” → “”“no-cache”"",
“Content-Type” → “”“application/x-www-form-urlencoded; charset=UTF-8"”",
“Pragma” → “”“no-cache”"",
“X-Requested-With” → “”“XMLHttpRequest”""
)

val headers_44 = Map(
“Accept” → “”"/""",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:55 GMT”"",
“If-None-Match” → “”"“41b06-1faca-4ddf06a78ae4f”"""
)

val headers_45 = Map(
“Accept” → “”“text/css,/;q=0.1"”",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40ec2-208a4-4ddf06a7579ff”"""
)

val headers_46 = Map(
“Accept” → “”"/""",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40ec3-a9c23-4ddf06a7585b7"”""
)

val headers_47 = Map(
“Accept” → “”"/""",
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40ec7-2211-4ddf06a75899f”"""
)

val headers_48 = Map(
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40ecf-6df-4ddf06a75899f”"""
)

val headers_49 = Map(
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“407c5-4da-4ddf06a73ff17"”""
)

val headers_50 = Map(
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40ecc-39d-4ddf06a75899f”"""
)

val headers_51 = Map(
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40ecd-e3b3-4ddf06a75899f”"""
)

val headers_52 = Map(
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“407c2-4d4-4ddf06a73ff17"”""
)

val headers_53 = Map(
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“407c7-acdf-4ddf06a73ff17"”""
)

val headers_54 = Map(
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“407ee-39f8-4ddf06a741687"”""
)

val headers_55 = Map(
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“407eb-a50c-4ddf06a741687"”""
)

val headers_56 = Map(
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“407c6-909-4ddf06a73ff17"”""
)

val headers_57 = Map(
“If-Modified-Since” → “”“Thu, 30 May 2013 14:35:54 GMT”"",
“If-None-Match” → “”"“40325-19b3-4ddf06a73d807"”""
)

val scn = scenario(“Scenario Name”)

.exec(http(“request_1”)
.get(“https://server1/”)
.headers(headers_1)
)
.pause(184 milliseconds)
.exec(http(“request_2”)
.get(“https://server1/resources/2b6c732475f91ffbb3899572fe8af89f.css”)
.headers(headers_2)
.check(status.is(304))
)
.exec(http(“request_3”)
.get(“https://server1/scripts/prototype.js”)
.headers(headers_3)
.check(status.is(304))
)
.exec(http(“request_4”)
.get(“https://server1/resources/c07b311750fa627de90d4a5ef3f39337.js”)
.headers(headers_4)
.check(status.is(304))
)
.pause(90 milliseconds)
.exec(http(“request_5”)
.get(“https://server1/resources/fcb9dbfd662b6128f2c6611a65a3fbfe.js”)
.headers(headers_5)
.check(status.is(304))
)
.pause(321 milliseconds)
.exec(http(“request_6”)
.get(“https://server1/layouts/marketing/img/corner4.gif”)
.headers(headers_6)
.check(status.is(304))
)
.pause(45 milliseconds)
.exec(http(“request_7”)
.get(“https://server1/resources/img/icons-sprite.gif”)
.headers(headers_7)
.check(status.is(304))
)
.exec(http(“request_8”)
.get(“https://server1/resources/img/logo-with-header.jpg”)
.headers(headers_8)
.check(status.is(304))
)
.exec(http(“request_9”)
.get(“https://server1/layouts/marketing/img/corner1.gif”)
.headers(headers_9)
.check(status.is(304))
)
.pause(14 milliseconds)
.exec(http(“request_10”)
.get(“https://server1/layouts/marketing/img/hero.jpg”)
.headers(headers_10)
.check(status.is(304))
)
.pause(12 milliseconds)
.exec(http(“request_11”)
.get(“https://server1/resources/img/primary-btn-bg.gif”)
.headers(headers_11)
.check(status.is(304))
)
.pause(62 milliseconds)
.exec(http(“request_12”)
.get(“https://server1/layouts/marketing/img/nav-module-sprite.jpg”)
.headers(headers_12)
.check(status.is(304))
)
.exec(http(“request_13”)
.get(“https://server1/layouts/marketing/img/nav-module-image-sprite.jpg”)
.headers(headers_13)
.check(status.is(304))
)
.pause(14 milliseconds)
.exec(http(“request_14”)
.get(“https://server1/layouts/marketing/img/footer-fade.gif”)
.headers(headers_14)
.check(status.is(304))
)
.pause(90 milliseconds)
.exec(http(“request_15”)
.get(“https://server1/favicon.ico”)
.headers(headers_15)
.check(status.is(304))
)
.exec(http(“request_16”)
.get(“https://server1/images/glyphs/ribon_serverinfo_o.png”)
.headers(headers_16)
.check(status.is(304))
)
.pause(5)
.exec(http(“request_17”)
.get(“https://server1/scripts/ext-3.3.3/resources/images/default/form/text-bg.gif”)
.headers(headers_17)
.check(status.is(304))
)
.exec(http(“request_18”)
.get(“https://server1/resources/img/gadget-body-bg.gif”)
.headers(headers_18)
.check(status.is(304))
)
.exec(http(“request_19”)
.get(“https://server1/scripts/ext-3.3.3/resources/images/default/panel/tool-sprites.gif”)
.headers(headers_19)
.check(status.is(304))
)
.pause(8)
.exec(http(“request_20”)
.get(“https://server1/scripts/ext-3.3.3/resources/images/default/grid/loading.gif”)
.headers(headers_20)
.check(status.is(304))
)
.pause(450 milliseconds)
.exec(http(“request_21”)
.post(“https://server1/system/login.php”)
.headers(headers_21)
.param(""“username”"", “”“133873"”")
.param(""“password”"", “”“1"”")
.param(""“ajaxLogin”"", “”“1"”")
)
.pause(5)
.exec(http(“request_22”)
.get(“https://server1/system/”)
.headers(headers_22)
)
.pause(768 milliseconds)
.exec(http(“request_23”)
.get(“https://server1/userportal/resources/images/favicon.ico”)
.headers(headers_23)
.check(status.is(304))
)
.exec(http(“request_24”)
.get(“https://server1/userportal/resources/css/userportal.css”)
.headers(headers_24)
.check(status.is(304))
)
.pause(94 milliseconds)
.exec(http(“request_25”)
.get(“https://server1/userportal/resources/js/userportal.js”)
.headers(headers_25)
.check(status.is(304))
)
.pause(54 milliseconds)
.exec(http(“request_26”)
.get(“https://server1/userportal/resources/fonts/proximanova-regular-webfont.woff”)
.headers(headers_23)
.check(status.is(304))
)
.pause(416 milliseconds)
.exec(http(“request_27”)
.get(“https://server1/userportal/resources/fonts/proximanova-regular-webfont.woff”)
.headers(headers_23)
.check(status.is(304))
)
.pause(25 milliseconds)
.exec(http(“request_28”)
.get(“https://server1/userportal/resources/fonts/crs.woff”)
.headers(headers_23)
.check(status.is(304))
)
.exec(http(“request_29”)
.get(“https://server1/userportal/resources/fonts/proximanova-semibold-webfont.woff”)
.headers(headers_23)
.check(status.is(304))
)
.exec(http(“request_30”)
.get(“https://server1/userportal/resources/images/crs-loader.gif”)
.headers(headers_30)
.check(status.is(304))
)
.pause(20 milliseconds)
.exec(http(“request_31”)
.get(“https://server1/userportal/settings/person/current/userportal.mileage”)
.headers(headers_31)
.queryParam(""“startDate”"", “”“2013-06-05"”")
.queryParam(""“endDate”"", “”“2013-06-06"”")
)
.pause(25 milliseconds)
.exec(http(“request_32”)
.get(“https://server1/favicon.ico”)
.headers(headers_15)
.check(status.is(304))
)
.pause(1)
.exec(http(“request_33”)
.get(“https://server1/userportal/async/status/personSyncJob”)
.headers(headers_33)
)
.pause(25 milliseconds)
.exec(http(“request_34”)
.get(“https://server1/userportal/resources/images/icon-calendar.gif”)
.headers(headers_30)
.check(status.is(304))
)
.exec(http(“request_35”)
.get(“https://server1/userportal/resources/images/pdficon.png”)
.headers(headers_30)
.check(status.is(304))
)
.pause(42 milliseconds)

.exec(http(“request_36”)
.get(“https://server1/userportal/period/favr/current”)
.headers(headers_31)
)
.pause(25 milliseconds)

.exec(http(“request_37”)
.get(“https://server1/userportal/settings/person/current/userportal.mileage”)
.headers(headers_31)
.queryParam(""“startDate”"", “”“2013-06-1"”")
.queryParam(""“endDate”"", “”“2013-06-31"”")
)
.pause(25 milliseconds)
.exec(http(“request_38”)
.get(“https://server1/userportal/trips/list”)
.headers(headers_31)
.queryParam(""“startDate”"", “”“2013-06-01"”")
.queryParam(""“endDate”"", “”“2013-06-31"”")
)
.pause(1)
.exec(http(“request_39”)
.get(“https://server1/userportal/resources/images/fallback_bg_navicon.png”)
.headers(headers_30)
.check(status.is(304))
)
.pause(9)

.exec(http(“request_40”)
.get(“https://server1/userportal/location/find”)
.headers(headers_33)
.queryParam(""“address”"", “”“3300 Broadway St, Eureka, CA 95501, USA”"")
.queryParam(""“day”"", “”“2013-06-01"”")
.queryParam(""“maxResults”"", “”“5"”")
)
.pause(25 milliseconds)
.exec(http(“request_41”)
.get(“https://server1/userportal/resources/fonts/proximanova-regularitalic-webfont.woff”)
.headers(headers_23)
.check(status.is(304))
)

.pause(6)
.repeat(“2”,“DAY”){
exec(http(“request_42”)
.post(“https://server1/userportal/trips/save”)
.headers(headers_42)
.param(""“id”"", “”"""")
.param(""“commuteDistance”"", “”"""")
.param(""“customFields[purpose]”"", “”“Visit to Everything Just A Buck “””)
.param(""“distance”"", “”“0"”")
.param(""“sequenceNum”"", “”“1"”")
.param(""“tripDay”"", “”“2013-06-${DAY}”"")
.param(""“unit”"", “”“MILES”"")
.param(""“toLocationAddress”"", “”“3300 Broadway St, Eureka, CA 95501, USA”"")
.param(""“toLocationClientLocationId”"", “”“1007"”")
.param(""“toLocationDataEntrySourceName”"", “”“browser”"")
.param(""“toLocationDetectedMilliseconds”"", “”“1370460506342"”")
.param(""“toEndDayStop”"", “”“false”"")
.param(""“toLocationId”"", “”“1027"”")
.param(""“toLocationIsGoogleVerified”"", “”“true”"")
.param(""“toLocationLatitude”"", “”“40.779146"”")
.param(""“toLocationLongitude”"", “”"-124.18738""")
.param(""“toLocationName”"", “”“Everything Just A Buck”"")
.param(""“toLocationPersonLocationId”"", “”“2092"”")
.param(""“fromLocationAddress”"", “”“1615 Alexander Ln, Grants Pass, OR 97527, USA”"")
.param(""“fromLocationDetectedMilliseconds”"", “”“1370460506342"”")
.param(""“fromLocationId”"", “”“40980"”")
.param(""“fromLocationIsGoogleVerified”"", “”“true”"")
.param(""“fromLocationName”"", “”“Base Location”"")

)

.pause(6)
}
.exec(http(“request_43”)
.get(“https://server1/userportal/logout”)
.headers(headers_22)
)
.pause(714 milliseconds)
.exec(http(“request_44”)
.get(“https://server1/scripts/prototype.js”)
.headers(headers_44)
.check(status.is(304))
)
.exec(http(“request_45”)
.get(“https://server1/resources/2b6c732475f91ffbb3899572fe8af89f.css”)
.headers(headers_45)
.check(status.is(304))
)
.exec(http(“request_46”)
.get(“https://server1/resources/c07b311750fa627de90d4a5ef3f39337.js”)
.headers(headers_46)
.check(status.is(304))
)
.pause(76 milliseconds)
.exec(http(“request_47”)
.get(“https://server1/resources/fcb9dbfd662b6128f2c6611a65a3fbfe.js”)
.headers(headers_47)
.check(status.is(304))
)
.pause(310 milliseconds)
.exec(http(“request_48”)
.get(“https://server1/resources/img/primary-btn-bg.gif”)
.headers(headers_48)
.check(status.is(304))
)
.exec(http(“request_49”)
.get(“https://server1/layouts/marketing/img/corner4.gif”)
.headers(headers_49)
.check(status.is(304))
)
.exec(http(“request_50”)
.get(“https://server1/resources/img/icons-sprite.gif”)
.headers(headers_50)
.check(status.is(304))
)
.pause(11 milliseconds)
.exec(http(“request_51”)
.get(“https://server1/resources/img/logo-with-header.jpg”)
.headers(headers_51)
.check(status.is(304))
)
.exec(http(“request_52”)
.get(“https://server1/layouts/marketing/img/corner1.gif”)
.headers(headers_52)
.check(status.is(304))
)
.exec(http(“request_53”)
.get(“https://server1/layouts/marketing/img/hero.jpg”)
.headers(headers_53)
.check(status.is(304))
)
.pause(47 milliseconds)
.exec(http(“request_54”)
.get(“https://server1/layouts/marketing/img/nav-module-sprite.jpg”)
.headers(headers_54)
.check(status.is(304))
)
.pause(13 milliseconds)
.exec(http(“request_55”)
.get(“https://server1/layouts/marketing/img/nav-module-image-sprite.jpg”)
.headers(headers_55)
.check(status.is(304))
)
.exec(http(“request_56”)
.get(“https://server1/layouts/marketing/img/footer-fade.gif”)
.headers(headers_56)
.check(status.is(304))
)
.pause(81 milliseconds)
.exec(http(“request_57”)
.get(“https://server1/images/glyphs/ribon_serverinfo_o.png”)
.headers(headers_57)
.check(status.is(304))
)
.exec(http(“request_58”)
.get(“https://server1/favicon.ico”)
.headers(headers_15)
.check(status.is(304))
)

setUp(scn.users(1).protocolConfig(httpConf))
}