Gatling2: how to perform a simple text for an attribute

(Very new at this)

The docs for version 1 refer to something like:

doIf( session => session.hasAttribute(“blahblah”) ) { … }

This doesn’t work in version 2. The one that sort of works is:

.doIf(session => session(“blahblah”).validate[String].map(_ != “”))

but from this, I get ERROR log messages:

00:10:37.403 [ERROR] i.g.c.action.If - No attribute named ‘blahblah’ is defined

It’s definitely from this code block, as removing the block eliminates the error messages. This suggests this is not the “right” way to test for the existence of an attribute.

Please help.

(PS, there’s probably a better way to do what I’m needing to do, but I’m working with OPC here.)

Oops. I meant “test” for an attribute, not text.

“hasAttribute” became “contains” in Gatling 2

“validate” handles missing attribute as a blocking error, session(“blahblah”).asOption[String].map(_ != “”).getOrElse(false) would have produced the expected result, but well… contains is teh way to go! :slight_smile:

Great! That did the trick. Thank you.