(This article is part of the JMeter Series)
In the following we’ll do these things:
- we go to a form submit page
- we order something
- we get that something we ordered
In more detail:
We use a “Cookie Manager” to carry forward cookies between calls
We set up our variables
The idea here being that we predefine the variables, so they would show up in the “Debug Sampler” which makes debugging easier, because you see at each step, whether the variable has the correct value or not. I do predefine the variables with a “non-value” so that I can see immediately whether the variable has been already assigned something during the execution of the test or not.
We go to a form submit page
We extract the AUTHTOKEN from that form
(The auth token is being used by the web application to prevent cross-site-scripting)
Notice that the extractor is set to extract the string from the HTTP reply-body.
We also extract the session cookie
This is because we want to pass the cookie to an outside application, so that it can call the web app from within the same session.
Notice that this time we told the extractor to extract the string from the HTTP reply-headers.
We now use all our extracted parameters to submit our order
Note that:
- we are passing the AUTHTOKEN along with the HTTP POST
- since we are not sure whether possibly the AUTHTOKEN contains some problematic character (in my case it was an equal sign ‘=’ that was interferring with the parameter encoding) we tell JMeter to URL-encode the string.
- we also pass along another parameter telling the web app what we’re interested in getting back from our order
- we are using HTTPS
Submitting the order will redirect us to the page that’ll show us the resulting order.
We extract the ORDER_ID from HTTP headers which would otherwise redirect us to the resulting page
The headers contain the location of the resulting order page where we would be redirected to.
Finally we download the resulting artefact with curl
Note that:
-
we are passing the SESSION_COOKIE to curl to be able to download the artifact in the same (potentially authenticated) session.
-
we also construct the download URL from the ORDER_ID
You can download this JMeter test from here
Tomáš Pospíšek, 4.1.2011