I am creating Gatling script for create new user. I am passing user defined values (fName = "newuser" , emailDomain = "@perftestorg.com") into the next request.
But, in response it didnot return the defined values and timestamp is also not printed. Please suggest what am I doing wrong here?
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import java.util.Calendar
import java.util.Date
import java.text.SimpleDateFormat
class CreateNewUser extends Simulation {
val fName = "newuser"
val emailDomain = "@perftestorg.com"
val sdfDate = new SimpleDateFormat("ddMMyy.HH.mm.ss.SSS")
val now = new Date()
val timeStamp = sdfDate.format(now)
val httpProtocol = http
.baseURL("https://abcxyz.com")
.acceptHeader("application/json, text/javascript, */*; q=0.01")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US")
.userAgentHeader("Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko")
.disableCaching
.doNotTrackHeader("1")
val scn = scenario("CreateNewUser")
.exec(http("LogIn")
.post("https://" + uri1 + "/login-page")
.headers(headers_0)
.formParam("_58_redirect", "")
.formParam("_58_rememberMe", "false")
.formParam("_58_login", "newuser002@perftestorg.com")
.formParam("_58_password", "scOrpiO")
.exec(http("checkUserAlreadyExist")
.post("/api/checkUserAlreadyExist")
.headers(headers_2)
.formParam("emailAdd", "$fName+timeStamp+$emailDomain"))
.exec(http("CreateNewUser")
.post("/api/UserSubscription")
.headers(headers_2)
.formParam("UserSubscription", """{"userEmail":"$fName+timeStamp+$emailDomain", "fName":"$fName","lName":""""+timeStamp+"""","languageId":"en_GB","subscription_id":"1","contractNumber":"1234567890","emailNotification":true,"orgName":"Performance Testing Organisation"}""")
.formParam("sendLoginCredential", "true"))
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}
Your help would be much appreciated.
thanks, Praveen
When you use something as $fName you need to put the variable in session. Use
exec(_.set("fName","username")).exec(http...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.