Home > jmeter > Jmeter: Add “Cookie Manager”

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:

Recorded scripts

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)

Login parameterization

7. Update your “login” sample by changing Value to ${Variable_name}

login

8. Now go to your “fill out express registration form” sample and edit new values for last name, first name and middle name.

new user

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

Cookie Manager, saves the day!

Advertisements
  1. virk
    June 3, 2010 at 2:10 am

    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.

  2. June 3, 2010 at 10:11 am

    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

  3. virk
    June 4, 2010 at 2:17 am

    Hey Girlie,

    Thanks alot. Its ALIVE! now 🙂

  4. virk
    June 4, 2010 at 2:33 am

    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???

  5. virk
    June 4, 2010 at 3:47 am

    Never mind, the issue was with the delay…..inserted a timer and is working just fine…thanks again

  6. chandrasekhar
    August 2, 2010 at 9:38 pm

    Hey Girlie,
    Tell me about userdefined cookies and actual use of it, how to pass values to that

  7. chandrasekhar
    August 2, 2010 at 9:40 pm

    Hey Girlie,
    Tell me about http cookie mgmt

  8. sunil
    August 5, 2010 at 2:49 pm

    thanks a lot! it worked for me.

  9. Raymond
    November 29, 2011 at 4:57 pm

    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..

  1. November 9, 2011 at 6:57 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: