Royal Mirzayev
Royal Mirzayev

Reputation: 1

Dynamic session ID is not displayed in my JMeter response headers, even though it's present in the actual response

After entering credentials and logging in, a SessionID is generated as a Set-Cookie in the response header on the actual website, but I am not able to see it in the response of the call in JMeter. It logs in successfully. When I try to add the session ID cookies manually, it works fine. So, the scenario is that I enter my credentials at the Sign In (A) URL, then it goes to the B URL for generating the session ID, and finally, it directs to the home page (C URL). However, in JMeter, it redirects from the B URL to the A URL instead of the C URL. I guess that might be causing the issue. I checked the response body of the B URL, but there is nothing related to the Session ID. The response body is just:

<script type="text/javascript">
location.replace("http://**A** **url**.com/");
</script>

How can I fix it?

Upvotes: 0

Views: 33

Answers (1)

Ivan G
Ivan G

Reputation: 2907

As per JMeter project main page:

JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).

and in your response location is a feature of a browser API

So you need to:

  1. Add another HTTP Request sampler
  2. Use either JSR223 PreProcessor or __groovy() function in order to replicate the JavaScript logic with Groovy of the system under test

or just hardcode the redirect location

Upvotes: 0

Related Questions