0

I am trying to test the login part of the application and here are the steps I tried in Browser,

  1. Navigate to Home page 2.Enter credentials and click on login.

once I click on Login, a redirection happens to "\home" URL.

I recorded the scripts and when I replayed it, the I can see that "Navigation to HomePage" doesn't have any issues. The second step where I click on login redirects me to another URL "\home" with response as "302 found".

The redirection URL Sample "\home" which is executed as sub sample of the login URL, returns an error message "Missing location header in redirect for GET" with response code as "307 Temporary redirect".

The redirection URL should return me a token as response and so that I can proceed with further steps but I am not sure what it means by "missing location header".

I checked the same in fiddler, browser (dev tools), I found that the redirection URL has a cookie(Session ID) sent in request Header. Whereas in Jmeter recording it is sent in Request body. That is the only difference I can see.

I also tried installing the latest version of Jmeter, New certificate and checked the cookie manager, inserted the missing header in the header manager of the "Login URL" nothing works.

since it seems to be working in Fiddler, i assume it should be some issue related to tool and not the application

Can someone help me what this issue is and if I need to pass the cookie data in request header instead of request body, how do I do it for a redirection URL which appears only during execution and not during recording.

attachment :enter image description here

Prad
  • 1

1 Answers1

0

JMeter's HTTP Cookie Manager automatically handles cookies, to wit:

  • Extracts them from the Set-Cookie header
  • If hostname and path of the next request match, the cookie is not expired, etc. - JMeter automatically adds Cookie header with the relevant cookie(s)

If you're confused with View Results Tree listener output like this:

enter image description here

in fact JMeter generates proper Cookie header, you can double check it by replaying your script via Fiddler (or using other sniffer tool)

If you additionally need to send another header with the value of the cookie from the previous request you can:

  1. Add the next line to user.properties file:

    CookieManager.save.cookies=true
    
  2. Restart JMeter to pick up the change

  3. Add HTTP Header Manager to your test plan and configure it to send the header you need with the value of ${COOKIE_your-cookie-name-here}

    in my case it will be ${COOKIE_AEMDC}

More information: HTTP Cookie Manager Advanced Usage - A Guide

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Hi, I did all this workaround but the problem i am facing is with the redirection URL, if i save the cookies, it saves the cookie of the login URL and sends the same to redirection URL. But in Fiddler i can a new Cookie is introduced in header of redirection URL and it does not come from previous response.. also can you tell me what does "Missing location Header in redirect for Get" actually mean – Prad Sep 14 '22 at 00:39
  • If cookie doesn't come with `Set-Cookie` response header but it's present in `Cookie` request header most probably it's generated by JavaScript. As per [JMeter project main page](https://jmeter.apache.org/): `In particular, JMeter does not execute the Javascript found in HTML pages` so you need to replicate the cookie generation logic using [JSR223 PreProcessor](https://jmeter.apache.org/usermanual/component_reference.html) and [Groovy language](https://www.blazemeter.com/blog/apache-groovy) – Dmitri T Sep 14 '22 at 04:18
  • Apologies, I could see the Set-cookie in response header of the previous request, but in the subsequent request the cookie should be passed in request header as per the dev tools in browser.. but in my case it is passed in request body. other than this i dont see any difference.. I am still not sure why i am seeing an error as "Missing location Header for GET" – Prad Sep 15 '22 at 09:52