# Almost there?

**URL:** <https://community.gatling.io/t/almost-there/1570>\
**Category:** Gatling (Open-Source)\
**Created:** [October 21, 2014, 8:00am UTC](https://community.gatling.io/t/almost-there/1570 "2014-10-21T08:00:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aram](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Aram](https://community.gatling.io/u/Aram)\
**Post date:** [October 21, 2014, 8:00am UTC](https://community.gatling.io/t/almost-there/1570/1 "2014-10-21T08:00:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [October 21, 2014, 8:14am UTC](https://community.gatling.io/t/almost-there/1570/2 "2014-10-21T08:14:13Z")

</div>

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

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

> check([status.is](http://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

---

<div class="post-metadata">

**Author:** ![Aram](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Aram](https://community.gatling.io/u/Aram)\
**Post date:** [October 21, 2014, 8:25am UTC](https://community.gatling.io/t/almost-there/1570/3 "2014-10-21T08:25:37Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [October 21, 2014, 8:31am UTC](https://community.gatling.io/t/almost-there/1570/4 "2014-10-21T08:31:15Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![Aram](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Aram](https://community.gatling.io/u/Aram)\
**Post date:** [October 21, 2014, 9:48am UTC](https://community.gatling.io/t/almost-there/1570/5 "2014-10-21T09:48:25Z")

</div>

> 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)

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [October 22, 2014, 8:50pm UTC](https://community.gatling.io/t/almost-there/1570/6 "2014-10-22T20:50:53Z")

</div>

Absolutely

---

<div class="post-metadata">

**Author:** ![Mahesh](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@Mahesh](https://community.gatling.io/u/Mahesh)\
**Post date:** [June 6, 2016, 6:15am UTC](https://community.gatling.io/t/almost-there/1570/7 "2016-06-06T06:15:55Z")

</div>

> check([status.is](http://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](https://abc.com:443/pages/home.xhtml)  
headers=  
Upgrade-Insecure-Requests: 1  
Referer: [https://abc.com/](https://abc.com/)  
Origin: [https://abc.com](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](http://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](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](https://abc.com)”,  
“Referer” → “[https://abc.com/](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](https://abc.com:443/protectedPages/Dash.xhtml)  
headers=  
Upgrade-Insecure-Requests: 1  
Referer: [https://abc.com/protectedPages/Dash.xhtml](https://abc.com/protectedPages/Dash.xhtml)  
Origin: [https://abc.com](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](http://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](https://abc.com)”,  
“Referer” → “[https://abc.com/protectedPages/Dash.xhtml](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”))
