Dealing with redirects

Hi,

I’m new to gatling so sorry if the question looks stupid. I’m sending a post including a user name and password for a login page.So the response for this request has nothing in the body and instead the page redirects two times and I see that in reports. The problem is how I can check stuff on the response’s body when I have redirects?!!

Hi,

Well, the best solution I guess is not to follow the redirects. You can achieve this with the .disableFollowRedirect setting, see : https://github.com/excilys/gatling/wiki/HTTP#wiki-follow-redirects

Does this solve your problem ?

cheers
Nicolas

So If I disable followredirect then how am I going to the new page?!

You can do that like this :

.exec(
http(“request1”)
.get("/")
.check(
status.is(302),
headers(“Location”).saveAs(“nextPageLocation”)
)
)
.exec(
http(“request2”)
.get("${nextPageLocation}")
.check(

)
)

Does it work ?

oops, it’s header() not headers(), cf : https://github.com/excilys/gatling/wiki/Checks#wiki-header-value

.exec(
http(“request1”)
.get("/")
.check(
status.is(302),
header(“Location”).saveAs(“nextPageLocation”)
)
)
.exec(
http(“request2”)
.get("${nextPageLocation}")
.check(

)
)

I’m not sure I correctly understand the question.

If you use a check on a redirected request, they’ll be applied to the landing page, not the redirected one.

I think u r right! I didnt disable the follow redirect option. I didnt know that its possible to write check even for post requests! so now it looks like :

.exec(http(“request_2”)
.post(“/DCWAT/”)
.headers(headers_2)
.queryParam(“”“-1.IFormSubmitListener-loginForm”“”, “”“”“”)
.param(“”“loginForm2db_hf_0"”“, “””“”“)
.param(”““formDomain””“, “”“xxxx””“)
.param(”““formName””“, “”“yyyy””“)
.param(”““formPassword””“, “”“zzz””“)
.check(regex(”“”

Assignments

“”"))
)

So now I am able to check if “Assignments” exist in the landed page.

Thanks :slight_smile: