Need help with check plus saveAs method

Hello!

I have a scenario, where I request a list of deposits and then make several requests for each deposit found. For this purpose I use check with xpath(…).findAll.saveAs(…) methods, but it caused me a lot of error s in report because 70% of users don’t have any deposit and the check returns error.

val request_deposit_list = execWithStdChecks(http(“Deposit list”)

.post("/example.com/accounts/accounts-list.xml")

.headers(headers_Content_Length_0)

.check(

xpath("//account[starts-with(producttypeid/text(), ‘dep’)]/accountid")

.findAll

.saveAs(“deposit_ids”)

)

)

val request_deposits_info = execWithStdChecks(http(“Deposit info”)

.get("/example.com/deposits/deposits_list.xml")

.queryParam(""“id”"", “${deposit_id}”)

)

val request_deposits_payment_schedule = execWithStdChecks(http(“Payment Schedule for Deposit”)

.post("/example.com/deposits/deposit_schedule.xml")

.headers(headers_Content_Length_0)

.queryParam(""“id”"", “${deposit_id}”)

)

val request_deposit_archive = execWithStdChecks(http(“Deposit Archive”)

.get("/example.com/deposits/deposits_archive.xml")

val request_all_deposit_info = foreach("${deposit_ids}", “deposit_id”){

exec(request_deposits_info)

.pause(150 milliseconds)

.exec(request_deposits_payment_schedule)

.pause (6 seconds)

}

val chain_deposits = exec(request_deposit_list)

.pause(300 milliseconds)

.exec(request_all_deposit_info)

.pause(150 milliseconds)

.exec(request_deposits_payment_schedule)

.pause (6 seconds)

.exec(request_deposit_archive)

.pause(150 milliseconds)

Could you advise the way the script is to be rewritten to avoid error messages in report when a user does not have any deposit?

2 things:

doIf(session => session.isAttributeDefined(“deposit_ids”)) { // Gatling 1 syntax

exec…
}

Cheers,

Stéphane

Thank for so quick response.

I’m using Gatling 2

I try add doIf in my block . But got an error (as I expected, to be honest)
val request_all_deposit_info = foreach("${deposit_ids}", “deposit_id”){
doIf(Session => session.getAttribute ("${deposit_ids}").exists()){
exec(request_deposits_info)
.pause(150 milliseconds)
.exec(request_deposits_payment_schedule)
.pause (6 seconds)
}

In Gatling 2, that’s session => session.contains(“deposit_ids”)

Thank a lot!!!
Now checks works as I expected