Stop simulation for 1 user if check fails

At the moment I have the following check in my simulation:

check(regex("<a wicket:id=“edit” href=".(${pattern}declarations-${countEdit}-edit)">Paranda.").saveAs("someUrl))

What I want is to insert a condition that if this check fails, then this user (for whom the check failed) stops simulation. And others should continue. The thing is that the check fails for some users (it should fail) but for others it’s ok.

In gatling 2.0.0 rc1 cheatsheet I found command exitHereIfFailed, but how do I use it?

Hi Andrei,

You can achieve this behaviour by checking if the session contains the supposedly saved attribute, and marking the session as failed if it doesn’t.
Then you call exitHereIfFailed, which will skip the rest of the scenario if the session was marked as failed.

.exec(session => if(session.contains(“someUrl”)) session else session.markAsFailed)



Works great, with the one exception. It generates the error, that the regex was not found. So in the .html report there is a bunch of failed requests. Is there any way to avoid it? If not, I’ll just stick to this solution. Thanks again!

You can use ‘dontValidate’ when defining your check to tell Gatling not to consider the request failed if the check didn’t succeed :

check(regex("<a wicket:id=“edit” href=".(${pattern}declarations-${countEdit}-edit)">Paranda.").dontValidate.saveAs("someUrl))

Works flawlessly! Thank you again.

You’re welcome !

Have fun with Gatling :slight_smile: