Hi All,
I am new to Gatling. Please I need help to resolve the error mentioned above. I could see result for “Login page”, “News” and “News_redirect”. However, the post request “Login” does not appear to work. It gives the above error.
I want this script to pick staff username and password from staff.csv file to login and then go to News page for 50 users. Thank you
val headers_1 = Map(“Accept” → “/”)
val feeder = csv(“staff.csv”).random
val scn = scenario(“Login page”)
.feed(feeder)
.exec(http(“Login page”)
.get("/login/")
.headers(headers_1)
.check(status.is(200),
regex(""“input type=“hidden” name=“security” class=“js-csrf-token” id=“security” value=”([^"]*)""").
find.saveAs(“securityToken”)))
.pause(11)
.exec(http(“get login”)
.post("/login/")
.formParam(“username”, “${User}”)
.formParam(“password”, “${Pass}”)
.formParam(“submit”, “Sign in”)
.formParam(“security”, “${securityToken}”)
.check(regex(“securityToken”))
.body(StringBody("""{ “${User}” }""")))
.pause(5)
.exec(http(“News”)
.get("/news/")
.headers(headers_1))
.pause (3)
setUp(scn.inject(atOnceUsers(50)).protocols(httpProtocol))
I think the problems is with feeder.
At your csv file, in the first row and column has the value ‘User’?
Thanks Lavio,
Which of the csv format is correct? no space in between the values except commas. The second one has its values on separate columns.
I have tested with both but still have the same problem.
I look forward to hearing from you soon.
Thanks
Regards,
G
The problem is that you don’t know the first line is the label of data, I think you should do this
This was exactly how it was before I posted the question to the group.
I’m new to gatling too. I don’t have more suggestions.
My csv
cpf,senha,uo
84415237622,dataprev,UO:11001020
84353873210,dataprev,UO:11001020
Code (it’s working)
object GERID {
val usuario = csv(“usuarios.csv”)
val login = exec(http(“HOME SIBE”)
.get("/PortalSibe/pages/index.xhtml")
.headers(headers_0)
.check(regex(“Acesso via Senha”),
css(“input[name=lt]”, “value”).saveAs(“lt”),
css(“input[name=execution]”, “value”).saveAs(“execution”))
.check(bodyString.saveAs(“responseBody”)))
//.exec { session => println(session(“responseBody”).as[String]); session }
.feed(usuario)
.pause(1)
.exec(http(“LOGIN GERID”)
.post(uri1 + “?service=http%3A%2F%2Fhsibepuapr01%2FPortalSibe%2Fpages%2Findex.xhtml”)
.headers(headers_1)
.formParam(“username”, “${cpf}”)
.formParam(“password”, “${senha}”)
.formParam(“lt”, “${lt}”)
.formParam(“execution”, “${execution}”)
.formParam("_eventId", “submit”)
.formParam(“submit”, “Entrar”)
.check(bodyString.saveAs(“responseBody”)))
Ok thanks a lot. I will check this out.
Hello Flavio,
This is still not working.
val scn = scenario("NewDevTest")
.exec(http("Get Login Page")
.get("/auth/login/")
.headers(headers_2)
.check(
regex("""input type="hidden" name="security" class="js-csrf-token" id="security" value="([^"]*)""").find.saveAs("securityToken")))
.pause(5)
.feed(feeder)
exec(http("Login")
.post("/auth/login/")
.formParam("username", "${username}")
.formParam("password", "${Password}")
.formParam("submit", "Sign in")
.formParam("security", "${securityToken}")
.check(regex("get login page"))
.body(StringBody("""{ "${username}" }""")))
pause(6)
I don’t know what is your error but it could be the check.
exec(http(“Get Login Page”)
.get("/auth/login/")
.headers(headers_2)
.check(
css(“input[name=security]”, “value”).saveAs(“securityToken”)))
.pause(5)
Hi Flavio,
I managed to fix it. The line below was not necessary and was embedded as part of the exec(Login) .check(regex(“get login page”))