Hello. I need help in resolving issue with one variable not being set.
Here is my code:
.foreach("#{programUrls}", "programUrl") {
exec(http("vote citation")
.get("#{programUrl}")
.check(status.is(OK))
.check(substring("Citation Voting").exists)
.check(substring("My Vote on This Citation").exists)
.check(css("input[name='form_build_id']", "value").findAll.saveAs("formBuildIds"))
.check(css("input[name='form_token']", "value").findAll.saveAs("formTokens"))
.check(css("input[name='form_id']", "value").findAll.saveAs("formIds"))
.check(css("input[value='Accept']", "name").findAll.saveAs("acceptButtons")))
.exec(session => {
println("*************************************************************************************************")
println(session("acceptButtons").as[String])
println("*************************************************************************************************")
session
}
)
.foreach("#{formBuildIds}", "citation", "counter") {
exec(http("accept citation")
.post("#{programUrl}")
.queryParam("ajax_form", "1")
.queryParam("_wrapper_format", "drupal_ajax")
.formParam("form_build_id", "#{formBuildIds(counter)}")
.formParam("form_id", "#{formIds(counter)}")
.formParam("form_token", "#{formTokens(counter)}")
.formParam("_triggering_element_name", "#{acceptButtons(counter)}")
.formParam("_triggering_element_value", "Accept")
.formParam("_drupal_ajax", 1)
.formParam("ajax_page_state[theme]", "tea")
.formParam("ajax_page_state[theme_token]", "")
.formParam("ajax_page_state[libraries]", PAGE_STATE)
.check(status.is(OK))
.check(substring("Accepted").exists)
)
}
The problem I am facing is that “acceptButtons” is not defined but the debug log shows that there are values.
Strangely, the other variables work well.
The other problem I am facing is with the index; it looks like Gatling’s counter starts from 1, which causes me an issue with first and last elements of the lists like formBuildIds (first element is skipped and last one throws out of bound). I will probably need extra work to decrease the counter by 1 before using but this again throws undefined error. I must be missing something.
Any suggestions?