Jmeter: Add “Cookie Manager”
Objective: Create an automated scripts using JMeter that will do the following scenarios in a healthcare system application and use the same scripts to register more patients.
1. admin user login
2. register new patient
3. save registration
4. verify new patient in the patient’s list
5. admin logout
Issue: Changing values of an automated scripts does not add the new value to the database on test playback.
Here’s how we do it:
1. In our JMeter testplan, add a Non-Test Element>Proxy Server in the WorkBench to do the initial recording.
2. Add Constant Timer under your HTTP Proxy with value “S{T}” to capture the actual delay during recording.
3. Start your browser, enable proxy in your browser and start recording.
4. After one action is recorded, JMeter generates a Header Manager which allows you to customize what information JMeter sends in the HTTP request header. Make a copy of the Header Manager from the first sample and paste it as a child of your thread group before all the HTTP requests, this will serve as the default header manager to be used. Continue recording until all the scenarios are finished.
5. After recording, update the samples to a more descriptive names just like this:
At this point, new user created during recording is successfully added in the database when manually validated. Next steps will help us parameterized and set new values for our new user.
6. To parameterized your login account, go to your thread group, add a Config Element > User Defined Variable. Then set values for login and password that are accepted in the appliication (in my case, login = admin; password=admin)
7. Update your “login” sample by changing Value to ${Variable_name}
8. Now go to your “fill out express registration form” sample and edit new values for last name, first name and middle name.
8. Run playback or hit CTRL-R to add to automatically add the new user values.
Actual: Scripts are successfully run but new user is not added in the user list
Expected: Succesfully run the script and add the new user in the user list
Solution: After futher readings of JMeter forums and wikis, I bumped across this post, and in its one reply suggest to add a Cookie Manager. True enough after adding a Config Element > Cookie Manager, set its Policy to “Compatibility,” and rerun the scripts, the new user value we edited was successfully added in the user list.
Cookie Manager, saves the day!





Hi Girlie,
Thank you for the post. Worked great for me. I am a newbie and I have some doubts.
I am testing a similar site as your example states. However my scenario is little different.
I have the same recorded script which adds a patient to the database.But, in my case there exists a field “patient id” which has to be unique every time I have to save the form. So every time I have to change the pat id manually, is there any way I can increment previous id and keep running the script in loop, generating and saving numerous patients at a time.
Any help would be highly appreciated.
Hi Virk!
I think what you need is the __time function, which returns the current time everytime you run scripts and combine it with your patient ID so every ID will be unique.
e.g.
PATIENT.${__time(YMD)} will give you PATIENTyyyyMMdd
check this link for reference: http://jakarta.apache.org/jmeter/usermanual/functions.html see “19.5.17 __time” for more time formats
Regards,
Girlie
Hey Girlie,
Thanks alot. Its ALIVE! now
Hey Girlie,
Now the problem is, if I run just one loop with only one user, the patient gets added…but if i run more than one loop and more than one user than only one user gets added….do u hv any idea ts goin on???
Never mind, the issue was with the delay…..inserted a timer and is working just fine…thanks again
Hey Girlie,
Tell me about userdefined cookies and actual use of it, how to pass values to that
Hey Girlie,
Tell me about http cookie mgmt
thanks a lot! it worked for me.
Hi…
I need help on the parameterization…using CSV or any or other method…I’m have recorded the script and parameterize values such as ‘Login’,'Password’ and some other fields.
but the issue is,when i run the script ,i not able see the values updated in DB.however i can see the Login and Logout in DB.
Could pl anyone throw some lights on this..