Cookies in my script are set using dynamically, or using JavaScript. How can I handle this?
Cookies are automatically handled by ZebraTester if they are received in a HTTP(S) response header from the web server. As this is commonly the case, there's usually no need to parameterize cookies. If a cookie is set by the browser itself using JavaScript, you can use a Load Test Plugin called Cookie Injector to emulate the JS functionality. Here's how you do it. First, from within the Var Handler window, scroll down to the "Load Test Plugins" section (beneath variables etc) and click "Add Plugin".
You'll need to define the NEW cookie name and value as separate stand-alone vars, or extract them from somewhere earlier in the script:
Then assign them as run-time input parameters.
For example, say we have a POST call that returns a 500 error. When we compare the original recording to a replayed one (which we performed by hitting "Replay Recording":
We see that the cookies differ from the original vs. the new recording. So in order to get the expected 200 code back we need to use the original cookies. So, we copy the original name/value pair of the "Cookie" in the Request Header and store them in user defined variables:
Then we assign them to the Cookie Injector, as explained above. When the load test executes, the "originalASPsessionIDValue" defined above is added as a cookie in the request header for URL 250.
NOTE: if you need to replace a cookie, there is also a "removeCookie" plugin so you can first remove the previous cookie. Otherwise this will happen and the cookie will not be replaced:
Please sign in to leave a comment.
Comments
0 comments