Almost there?

Hello everybody,

I have a question a have a page that I cannot pass through.
Step_01 = work I get what need
Step_02 = here the .params are probably not working because the id’s are dynamically generated (that’s why i thought maybe a .findAll would help)

Step_03 = step three i need a 302 and to be redirected

Step_04 = step four should not give a any problems if I am passed through but that does not work

Step_05 = on step five I have to use the regex, because every redirect keeps giving 200’s back from the first step.

I someone could help me with solving this problem I would really appreciate it. I have the feeling I am close but yet so far!
Thank you

.formParam("${username}", “”“John”"")
.formParam("${password}", “”“Secret”"")

Really? Form fields names are dynamic and have to be captured from the page?

check(status.is(302))) // Gives a 200 because by this point I have been redirected to Step_01 (But needs to give 302) Here I want to be redirected

By default, Gatling follows redirects, and checks are applied on landing page, so you’ll never see the 302

Yes I am also a little bit lost but every time I inspect the element

Every time I look the string is different. So every time I record it hard codes session information?

recording

.exec(http(“request_2”)
.post(uri2 + “”"""")
.headers(headers_0)
.formParam(""“aSmOq2gnbIxp49n5a”"", “”“Jogn Secret”"")
.formParam(""“a7orXT0MYHpx9l7NO”"", “”“Secret”"")
.formParam(""“a43jWwaLFhOrWuSJf”"",

“”“version%3D2%26pm%5Ffpua%3Dmozilla%2F5%2E0%20%28x11%3B%20ubuntu%3B%20linux%20x86%5F64%3B%20rv%3A33%2E0%29%20gecko%2F20100101%20firefox%2F33%2E0%7C5%2E0%20%28X11%29%7CLinux%20x86%5F64%26pm%5Ffpsc%3D24%7C1280%7C1024%7C1000%26pm%5Ffpsw%3D%26pm%5Ffptz%3D2%26pm%5Ffpln%3Dlang%3Den%2DUS%7Csyslang%3D%7Cuserlang%3D%26pm%5Ffpjv%3D1%26pm%5Ffpco%3D1%26pm%5Ffpasw%3Dlibrhythmbox%2Ditms%2Ddetection%2Dplugin%7Cicedteaplugin%7Clibtotem%2Dgmp%2Dplugin%7Clibtotem%2Dmully%2Dplugin%7Clibtotem%2Dnarrowspace%2Dplugin%7Clibtotem%2Dcone%2Dplugin%26pm%5Ffpan%3DNetscape%26pm%5Ffpacn%3DMozilla%26pm%5Ffpol%3Dtrue%26pm%5Ffposp%3D%26pm%5Ffpup%3D%26pm%5Ffpsaw%3D1215%26pm%5Ffpspd%3D24%26pm%5Ffpsbd%3D%26pm%5Ffpsdx%3D%26pm%5Ffpsdy%3D%26pm%5Ffpslx%3D%26pm%5Ffpsly%3D%26pm%5Ffpsfse%3D%26pm%5Ffpsui%3D”"")

.resources(http(“request_3”)
.get(uri1 + “”"/ssm/sso/resume""")
.headers(headers_0),

I thought the best thing was to go up to the div which does not change and then look for the div it’s input?
Thats why i thought of using findAll?

Thanks

Yes I am also a little bit lost but every time I inspect the element

<input autofocus="autofocus" class=" firstfield" tabindex="1"
name="aSmOq2gnbIxp49n5a" id="aSmOq2gnbIxp49n5a" size="25" maxlength="20"
value="" type="text">

So yes, you have to capture it. It might prove difficult if you don't set
some kind of flag so you can easily find the field, such as a fixed id, or
a specific style class. Anyway, you can try your luck with regex or css
(css selectors).

Just being curious, which framework does this website use? The only
framework I'm aware of that does this crazy thing is Lift. IIRC, with Lift,
there's a way to disable this but it kills performance.

I thought the best thing was to go up to the div which does not change and
then look for the div it's input?
Thats why i thought of using findAll?

No. Use a css selector then.

Dear Stephane,

could something like this work? Because I can select the input fields but I only need to fill in my username in password. What is the best option?
Thank you!!!

.check(regex("""<input type=“text” autofocus=“autofocus” class=" firstfield"""").saveAs(“username”))
.check(regex("""<input type=“password” class="" tabindex=“2"”").saveAs(“password”)))

.exec(http(“Step_02”)
.post(Msite + “”"/SesamLoginServlet""")
.queryParam("${username}", “”“John”"")
.queryParam("${password}", “”“Secret”"")
.headers(head)

Absolutely

check(status.is(302))) // Gives a 200 because by this point I have been redirected to Step_01 (But needs to give 302) Here I want to be redirected

By default, Gatling follows redirects, and checks are applied on landing page, so you’ll never see the 302

Sorry for replying on a old thread. I’m using 2.2.1 and haven’t disabled follow redirect. One of my request is automatically getting redirected and the other not. I’ve posted below the HTTP request, response & relevant code snippet. Please let me know what I’m doing incorrectly which is making the server respond with a 200 rather than 302. Framework used is JSF Primefaces.

Redirect works fine below (302 reported as success and then redirected GET request is executed properly)

HTTP request:
POST https://abc.com:443/pages/home.xhtml
headers=
Upgrade-Insecure-Requests: 1
Referer: https://abc.com/
Origin: https://abc.com
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Cache-Control: max-age=0
Accept-Language: en-US,en;q=0.8
Accept-Encoding: gzip, deflate
User-Agent: Gatling (Linux) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Cookie: JSESSIONID=otBT4pwIANyITwUM3bSYdA7M.undefined
Content-Length: 217
Host: abc.com
params=
j_idt41: j_idt41
javax.faces.ViewState: -8024050803110144760:-4638024640726524952
j_idt41:form-name: abcd
j_idt41:form-pass: abcd
j_idt41:login1: j_idt41:login1
showMessageToClient: j_idt41:showMessage

HTTP response:
status=
302 Moved Temporarily
headers=
Cache-Control: no-cache
Cache-Control: no-store
Content-Type: application/xhtml+xml
Expires: -1
Location: https://abc.com/protectedPages/KYC_Customer_Landing_Page.xhtml
Pragma: no-cache
Server: Apache
Vary: X-Forwarded-Proto
X-Frame-Options: SAMEORIGIN
Content-Length: 0
Connection: keep-alive

val headers_54 = Map(
“Accept” → “text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8”,
“Accept-Encoding” → “gzip, deflate”,
“Cache-Control” → “max-age=0”,
“Connection” → “keep-alive”,
“Origin” → “https://abc.com”,
“Referer” → “https://abc.com/”,
“Upgrade-Insecure-Requests” → “1”)

val land_page =
feed(userFeeder)
.exec(http(“request_54”)
.post("/pages/home.xhtml")
.headers(headers_54)
.formParam(“j_idt41”, “j_idt41”)
.formParam(“javax.faces.ViewState”, session => session.get(“viewstate”).as[String])
.formParam(“j_idt41:form-name”, “${username}”)
.formParam(“j_idt41:form-pass”, “${passwd}”)
.formParam(“j_idt41:login1”, “j_idt41:login1”)
.formParam(“showMessageToClient”, “j_idt41:showMessage”)
.check(regex(""“ViewState:0” value="(.*)" autocomplete""").saveAs(“viewstate”)))

Below I’m expecting a 302 but 200 is reported but works fine from browser
HTTP request:
POST https://abc.com:443/protectedPages/Dash.xhtml
headers=
Upgrade-Insecure-Requests: 1
Referer: https://abc.com/protectedPages/Dash.xhtml
Origin: https://abc.com
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Cache-Control: max-age=0
Content-type: application/x-www-form-urlencoded
Accept-Language: en-US,en;q=0.8
Accept-Encoding: gzip, deflate, br
User-Agent: Gatling (Linux) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Cookie: JSESSIONID=otBT4pwIANyITwUM3bSYdA7M.undefined
Content-Length: 116
Host: abc.com
params=
j_idt11: j_idt11
javax.faces.ViewState: -3781719762879616191:3768904276059911396
j_idt11:j_idt66: j_idt11:j_idt66

HTTP response:
status=
200 OK
headers=
Cache-Control: no-cache
Cache-Control: no-store
Content-Type: text/html;charset=UTF-8
Expires: -1
Pragma: no-cache
Server: Apache
Vary: X-Forwarded-Proto,Accept-Encoding
X-Frame-Options: SAMEORIGIN
Connection: keep-alive
Content-Encoding: gzip

val headers_282l = Map(
“Accept” → “text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8”,
“Accept-Encoding” → “gzip, deflate, br”,
“Cache-Control” → “max-age=0”,
“Connection” → “keep-alive”,
“Content-type” → “application/x-www-form-urlencoded”,
“Origin” → “https://abc.com”,
“Referer” → “https://abc.com/protectedPages/Dash.xhtml”,
“Upgrade-Insecure-Requests” → “1”)

val logout_from_dashboard = exec(http(“request_282l”)
.post("/protectedPages/Dash.xhtml")
.headers(headers_282l)
.formParam(“j_idt11”, “j_idt11”)
.formParam(“javax.faces.ViewState”, session => session.get(“viewstate”).as[String])
.formParam(“j_idt11:j_idt66”, “j_idt11:j_idt66”))