Hello,
I want to do something like this
.exec(http(“request_4”)
.post("/SearchAppointment")
.headers(headers_4)
.body(ELFileBody(“request.txt”))
.xpath(“A valid path to obtain an id for an appointment”).find.is( aMethodForDeterminingAppointmentId( session(“user”).as[String] ) )
)
…"user" is currently in session ( csv feeder )
Appart that I personally would rather go with validate instead of as, your code looks fine to me. What’s your problem exactly?
I dont know how to pass the session attribute “user” to the method “aMethodForDeterminingAppointmentId”
session(“user”).as[String] ← that’s exactly what you did here
Thank you for your response, my code is something like this
.exec(http(“ObtenerCitas”)
.post("""/Comunes/Citas/ObtenerCitas""")
.headers(headers_13)
.body(ELFileBody(“request.txt”))
.check( citas_dia_coincidan( ((session: Session) => { session(“fl_usuario”).as[String] }) ) )
)
where
def citas_dia_coincidan(fl_usuario: String) = {
println(fl_usuario)
}
Then, when running simulation I get:
type mismatch;
found : io.gatling.core.Predef.Session => String
required: String
I don’t know how to pass the attribute fl_usuario. Any suggestion?
Thanks in advance 
Check is a full API, not just a bare function.
Can you elaborate on what you're trying to check, like, what your
*citas_dia_coincidan* method would look like, so I can help you?
Thank you Stéphane 
citas_dia_coincidan is as follows
def citas_dia_coincidan(folio_usuario: String) = {
println(fl_usuario)
var user_appointment = getAppointment(fl_usuario)
xpath("//FL_APPOINTMENT/text()").find.is(user_appointment)
}
I only want to calculate user_appointment from folio_usuario (using method getAppointment ), then check if xpath for calculate FL_APPOINTMENT match witch expected user_appointment
Am I missing something?
OK!!!
So you were overcomplicating things 
check(xpath("//FL_APPOINTMENT/text()").find.is(session => session(“user”).validate[String].map(folio_usuario => getAppointment(folio_usuario)))
and actually, you can write this much more shortly:
check(xpath("//FL_APPOINTMENT/text()").is(_(“user”).validate[String].map(getAppointment))
- removed find because it’s the default
- replaced session => session with the scala _ wild card, because the function parameter was only used once and not in an inner call (like in foo(bar(session))
- getAppointment is a method that takes a String and returns a String, so it can be “lifted” into a function that takes a String and returns a String, which is exactly what map method expects here
But well, if you don’t want to learn a few functional tricks, the following would work too (with the limitations of .as compared to .validate):
check(xpath("//FL_APPOINTMENT/text()").is(session => getAppointment(session(“user”).as[String]))
Get it?
Thank you very much it works !!! And I think, I already understand about the placeholder “_”
My final code was:
.exec(http(“ObtenerCitas”)
.post("""/Comunes/Citas/ObtenerCitas""")
.headers(headers_13)
.body(ELFileBody(“Login_ObtenerCitas_request_39.txt”))
.check( citas_dia_coincidan )
)
where
def citas_dia_coincidan() = {
xpath("//FL_APPOINTMENT/text()").is( _(“fl_usuario”).validate[String].map(getAppointment) )
}

You don’t even need the curly braces as there’s only one instruction:
def citas_dia_coincidan() = xpath("//FL_APPOINTMENT/text()").is( _(“fl_usuario”).validate[String].map(getAppointment) )
Have fun!
And you don’t even need to make it a def:
val citas_dia_coincidan() = xpath("//FL_APPOINTMENT/text()").is( _(“fl_usuario”).validate[String].map(getAppointment) )