Hi All,
how to correlate array of values using regx.
found below regx extracting only one value.
.check(regex(""“href=”/category/([a-zA-Z -]+)"""").exists.saveAs(key=“catg”)))
.pause(13)
.exec( session => {
println( “correlated values:” )
println( session( “catg” ).as[String] )
session
})
response from where to correlate:
Thanks stephane .It worked.
Hi Stephane,
I am facing a bit of a challenge around picking individual values from an array of values extracted to a variable.
how can i refer say 2nd value from ‘catg’ list below?
is it
${catg}(2) ?
object Contact{
val contact= exec(http("Contact")
.get("/contact")
.check(substring(pattern="Contact Us"))
// href="/category/unisex"
.check(regex("""href="/category/([a-zA-Z -]+)"""").findAll.exists.saveAs(key="catg")))
.exec( session => {
println( "correlated values:" )
println(List(session("catg")))
session
})
.pause(13)
}
object Allproduct{
val allproduct= exec(http("Allproduct")
// .get("/category/all"))
.get(s"/category/"+ "${catg}"))
.pause(26)
.exec( session => {
// println("size=" + "${catg}")
session
})
- what is getting printed is
correlated values:
List(SessionAttribute(Session(Buyer,1,HashMap(gatling.http.cache.baseUrl → https://demostore.gatling.io, gatling.http.cache.dns → io.gatling.http.resolver.ShufflingNameResolver@1bba26e1, gatling.http.ssl.sslContexts → io.gatling.http.util.SslContexts@40e3a63, csrfValue → 10ce108d-6b55-4eef-bb81-59985142c9b6, gatling.http.cookies → CookieJar(Map(CookieKey(jsessionid,demostore.gatling.io,/) → StoredCookie(JSESSIONID=B71E6DCECBD0C70202A8F748CB66FAFB, path=/, HTTPOnly,true,false,1637831105379))), catg → List(all, for-him, for-her, unisex), gatling.http.referer → https://demostore.gatling.io/contact),OK,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$549/0x000000080103f470@5cc6f659,io.netty.channel.nio.NioEventLoop@30b34287),catg))
Thanks,
Hari
Please read the documentation properly:
Stephane,
perfect.
And java support is really good news
Thanks,
Hari