You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by ohaya <oh...@yahoo.com.INVALID> on 2021/01/04 20:58:49 UTC
How to capture URLs from automatically followed redirects?
Hi,
Happy new year to you all :)!!
In my test plan, I do an HTTP request with "follow redirects" enabled, and when this request is performed, 4 automatic (302) redirects occur, and then I subsequently need to do a POST request,
However, part of the data I need for that subsequent POST is only available from the last of the 4 automatic requests.
In other words (for example), my test plan has:
http://xxxx.com/aa/bb/cc
then as a result of the above, the following appears in the Jmeter View Results:
HTTP in Test Plan: http://xxxx.com/aa/bb/cc
==> http://foo1.xxx/.....
==> http://foo2.xxx/....
==> http://foo3.xxx/....
==> http://foo4.xxx?value1=AAAAAAAAAAAAA&value2=BBBBBBBBBBB....
I need to do a POST after the above, but I need to include the "?value1=AAAAAAAAAAAAA&value2=BBBBBBBBBBB...." from the last redirect.
How can I do that?
Thanks,
Jim
P.S. I am using Jmeter 5.2.1.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org
Re: How to capture URLs from automatically followed redirects?
Posted by Felix Schumacher <fe...@internetallee.de>.
Am 04.01.21 um 21:58 schrieb ohaya:
> Hi,
>
> Happy new year to you all :)!!
>
> In my test plan, I do an HTTP request with "follow redirects" enabled, and when this request is performed, 4 automatic (302) redirects occur, and then I subsequently need to do a POST request,
>
> However, part of the data I need for that subsequent POST is only available from the last of the 4 automatic requests.
>
> In other words (for example), my test plan has:
>
> http://xxxx.com/aa/bb/cc
>
> then as a result of the above, the following appears in the Jmeter View Results:
>
> HTTP in Test Plan: http://xxxx.com/aa/bb/cc
> ==> http://foo1.xxx/.....
> ==> http://foo2.xxx/....
> ==> http://foo3.xxx/....
> ==> http://foo4.xxx?value1=AAAAAAAAAAAAA&value2=BBBBBBBBBBB....
>
> I need to do a POST after the above, but I need to include the "?value1=AAAAAAAAAAAAA&value2=BBBBBBBBBBB...." from the last redirect.
If the request to http://xxxx.com/aa/bb/cc is a GET request and you want
to extract the information from the last subsample, you can access the
subsamples on the variable 'prev' with a JSR223Sampler. With language
set to Groovy you could add 'log.info("Locations: " +
prev.subResults*.redirectLocation)' to log every location of those
subsamples. To access the last subsample (and get its location), you can
use 'log.info("Last redirect: " + prev.subResults[-1].redirectLocation))'.
Felix
>
> How can I do that?
>
> Thanks,
> Jim
>
> P.S. I am using Jmeter 5.2.1.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org