Hi,
I am new to Gatling and did a lot of Googling, but couldn’t make it work. Here’s what I am trying to do.
- I am making a Get request to a URL, the response body has another URL (which is actually a redirect) and few key-value pairs.
- I am trying to save that response body into a variable, so that I can extract the key-value pairs.
Here’s the script, but somehow it just prints nothing.
It would be great help, if somebody can help get this script working.
Thanks,
Umesh
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class SS3 extends Simulation {
val httpProtocol = http
.baseURL(“http://abc.com”)
.disableFollowRedirect
.inferHtmlResources(BlackList("""..js""", “”"..css""", “”"..gif""", “”"..jpeg""", “”"..jpg""", “”"..ico""", “”"..woff""", “”"..(t|o)tf""", “”"..png"""), WhiteList())
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/*;q=0.8")
.acceptEncodingHeader(“gzip, deflate, sdch”)
.acceptLanguageHeader(“en-GB,en-US;q=0.8,en;q=0.6”)
.connection(“keep-alive”)
.contentTypeHeader(“application/x-www-form-urlencoded”)
.userAgentHeader(“Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36”)
val headers_4 = Map(“Pragma” → “no-cache”)
val headers_8 = Map(
“Accept” → “application/json, text/plain, /”,
“Accept-Encoding” → “gzip, deflate”,
“Origin” → “https://abc.com”)
val headers_10 = Map(
“Accept-Encoding” → “gzip, deflate”,
“Origin” → “https://cba”)
val headers_17 = Map(“Accept” → “image/webp,/;q=0.8”)
val uri1 = “www.gstatic.com”
val uri2 = “https://cba:443”
val uri3 = “http://abc/simplesamlphpms4/module.php”
//val Res1 = “”
//val Res3 = “”
//val Res4 = “”
val scn = scenario(“SS3”)
.exec(http(“request_0”)
.get("/simplesamlphpms4/module.php/core/authenticate.php?as=ssg-idp")
//.check(status.is(302),currentLocationRegex("""(.*)""").saveAs(Res1)))
//.check(currentLocation.transform(string=>string).saveAs(“Res1”)))
.check(bodyString.saveAs(“Res1”)))
.exec {session =>
//val Res1: String = session.getTypedAttribute(“Res1”)
println("Res1=> " + Res1)
session
}
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}