Articles

Loading

Website Cookie Testing, Test cases for testing web application cookies?

Functional Test
Author
rua_0611
Date
2011-08-09 13:08
Views
7184

We will first focus on what exactly cookies are and how they work.
It would be easy for you to understand the test cases for testing
cookies when you have clear understanding of how cookies work? How
cookies stored on hard drive? And how can we edit cookie settings?

What is Cookie?
Cookie is small information stored in text file on user’s hard drive by
web server. This information is later used by web browser to retrieve
information from that machine. Generally cookie contains personalized
user data or information that is used to communicate between different
web pages.

Why Cookies are used?
Cookies are nothing but the user’s identity and used to track where the
user navigated throughout the web site pages. The communication between
web browser and web server is stateless.

For example if you are accessing domain
http://www.example.com/1.html then web browser will simply query to
example.com web server for the page 1.html. Next time if you type page
as http://www.example.com/2.html then new request is send to
example.com web server for sending 2.html page and web server don’t
know anything about to whom the previous page 1.html served.

What if you want the previous history of this user communication
with the web server? You need to maintain the user state and
interaction between web browser and web server somewhere. This is where
cookie comes into picture. Cookies serve the purpose of maintaining the
user interactions with web server.

How cookies work?
The HTTP protocol used to exchange information files on the web is used
to maintain the cookies. There are two types of HTTP protocol.
Stateless HTTP and Stateful HTTP protocol. Stateless HTTP protocol does
not keep any record of previously accessed web page history. While
Stateful HTTP protocol do keep some history of previous web browser and
web server interactions and this protocol is used by cookies to
maintain the user interactions.

Whenever user visits the site or page that is using cookie, small
code inside that HTML page (Generally a call to some language script to
write the cookie like cookies in JAVAScript, PHP, Perl) writes a text
file on users machine called cookie.

Here is one example of the code that is used to write cookie and can be placed inside any HTML page:

Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME;

When user visits the same page or domain later time this cookie is
read from disk and used to identify the second visit of the same user
on that domain. Expiration time is set while writing the cookie. This
time is decided by the application that is going to use the cookie.

Generally two types of cookies are written on user machine.

1) Session cookies: This cookie is active till the
browser that invoked the cookie is open. When we close the browser this
session cookie gets deleted. Some time session of say 20 minutes can be
set to expire the cookie.

2) Persistent cookies: The cookies that are written permanently on user machine and lasts for months or years.

Where cookies are stored?
When any web page application writes cookie it get saved in a text file
on user hard disk drive. The path where the cookies get stored depends
on the browser. Different browsers store cookie in different paths.
E.g. Internet explorer store cookies on path “C:Documents and SettingsDefault UserCookies”

Here the “Default User” can be replaced by the current user you logged
in as. Like “Administrator”, or user name like “Vijay” etc.

The cookie path can be easily found by navigating through the browser
options. In Mozilla Firefox browser you can even see the cookies in
browser options itself. Open the Mozila browser, click on
Tools->Options->Privacy and then “Show cookies” button.

How cookies are stored?
Lets take example of cookie written by rediff.com on Mozilla Firefox browser:

On Mozilla Firefox browser when you open the page rediff.com or login
to your rediffmail account, a cookie will get written on your Hard
disk. To view this cookie simply click on “Show cookies” button
mentioned on above path. Click on Rediff.com site under this cookie
list. You can see different cookies written by rediff domain with
different names.

Site: Rediff.com Cookie name: RMID
Name: RMID (Name of the cookie)

Content: 1d11c8ec44bf49e0… (Encrypted content)

Domain: .rediff.com

Path: / (Any path after the domain name)

Send For: Any type of connection

Expires: Thursday, December 31, 2020 11:59:59 PM

Applications where cookies can be used:

1) To implement shopping cart:
Cookies are used for maintaining online ordering system. Cookies
remember what user wants to buy. What if user adds some products in
their shopping cart and if due to some reason user don’t want to buy
those products this time and closes the browser window? When next time
same user visits the purchase page he can see all the products he added
in shopping cart in his last visit.

2) Personalized sites:
When user visits certain pages they are asked which pages they don’t
want to visit or display. User options are get stored in cookie and
till the user is online, those pages are not shown to him.

3) User tracking:
To track number of unique visitors online at particular time.

4) Marketing:
Some companies use cookies to display advertisements on user machines.
Cookies control these advertisements. When and which advertisement
should be shown? What is the interest of the user? Which keywords he
searches on the site? All these things can be maintained using cookies.

5) User sessions:
Cookies can track user sessions to particular domain using user ID and password.

Drawbacks of cookies:

1) Even writing Cookie is a great way to maintain
user interaction, if user has set browser options to warn before
writing any cookie or disabled the cookies completely then site
containing cookie will be completely disabled and can not perform any
operation resulting in loss of site traffic.

2) Too many Cookies:
If you are writing too many cookies on every page navigation and if
user has turned on option to warn before writing cookie, this could
turn away user from your site.

3) Security issues:
Some times users personal information is stored in cookies and if
someone hack the cookie then hacker can get access to your personal
information. Even corrupted cookies can be read by different domains
and lead to security issues.

4) Sensitive information:
Some sites may write and store your sensitive information in cookies, which should not be allowed due to privacy concerns.


Some Major Test cases for web application cookie testing:

The first obvious test case is to test if your application is writing
cookies properly on disk. You can use the Cookie Tester application also if you
don’t have any web application to test but you want to understand the cookie
concept for testing.


 

Test cases: 

1) As a Cookie privacy policy make sure from your design documents that no personal or sensitive data is stored in the cookie.

2) If you have no option than saving sensitive data in cookie make sure data stored in cookie is stored in encrypted format.

3) Make sure that there is no overuse of cookies on your site under test. Overuse of cookies will annoy users if browser
is prompting for cookies more often and this could result in loss of
site traffic and eventually loss of business.

4) Disable the cookies from your browser settings:
If you are using cookies on your site, your sites major functionality
will not work by disabling the cookies. Then try to access the web site
under test. Navigate through the site. See if appropriate messages are
displayed to user like “For smooth functioning of this site make sure
that cookies are enabled on your browser”. There should not be any page
crash due to disabling the cookies. (Please make sure that you close
all browsers, delete all previously written cookies before performing
this test)

5) Accepts/Reject some cookies: The best way to
check web site functionality is, not to accept all cookies. If you are
writing 10 cookies in your web application then randomly accept some
cookies say accept 5 and reject 5 cookies. For executing this test case
you can set browser options to prompt whenever cookie is being written
to disk. On this prompt window you can either accept or reject cookie.
Try to access major functionality of web site. See if pages are getting
crashed or data is getting corrupted.

6) Delete cookie: Allow site to write the cookies
and then close all browsers and manually delete all cookies for web
site under test. Access the web pages and check the behavior of the
pages.

7) Corrupt the cookies: Corrupting cookie is easy.
You know where cookies are stored. Manually edit the cookie in notepad
and change the parameters to some vague values. Like alter the cookie
content, Name of the cookie or expiry date of the cookie and see the
site functionality. In some cases corrupted cookies allow to read the
data inside it for any other domain. This should not happen in case of
your web site cookies. Note that the cookies written by one domain say
rediff.com can’t be accessed by other domain say yahoo.com unless and
until the cookies are corrupted and someone trying to hack the cookie
data.

8 ) Checking the deletion of cookies from your web application page: Some times cookie written by domain say rediff.com may be deleted by
same domain but by different page under that domain. This is the
general case if you are testing some ‘action tracking’ web portal.
Action tracking or purchase tracking pixel is placed on the action web
page and when any action or purchase occurs by user the cookie written
on disk get deleted to avoid multiple action logging from same cookie.
Check if reaching to your action or purchase page deletes the cookie
properly and no more invalid actions or purchase get logged from same
user.

9) Cookie Testing on Multiple browsers: This is the
important case to check if your web application page is writing the
cookies properly on different browsers as intended and site works
properly using these cookies. You can test your web application on
Major used browsers like Internet explorer (Various versions), Mozilla
Firefox, Netscape, Opera etc.

10) If your web application is using cookies to maintain the logging state of any user then log in to your web application using some username and password.
In many cases you can see the logged in user ID parameter directly in
browser address bar. Change this parameter to different value say if
previous user ID is 100 then make it 101 and press enter. The proper
access message should be displayed to user and user should not be able
to see other users account.

These are some Major test cases to be considered while testing
website cookies. You can write multiple test cases from these test
cases by performing various combinations. If you have some different
application scenario, you can mention your test cases in comments below.

(Source: Internet - From my favorite blog)


Total Reply 19

  • 2011-05-07 11:54

    wow. It is a good article about testing cookies on web application. Thanks


  • 2011-06-03 01:32

    hei, it's very useful. Thank you very much.


  • 2011-11-19 20:32

    an excellent article on testing related to cookies
    well organized and precise
    thank you very much for sharing this


  • 2011-11-22 11:14

    I also think it's very excellent. So I posted it  on this site. 🙂


  • 2012-07-16 15:49

    thanks


  • 2012-08-04 20:28

    Excellent article...


  • 2012-08-07 16:23

    ^_^


  • 2012-08-18 07:47

    Very informative article.. Thank you..


  • 2012-09-29 01:15

    thank u


  • 2012-12-15 02:57

    good one


  • 2012-12-16 09:27

    fantastic article


  • 2013-02-07 12:35

    Thank you for your sharing.


  • 2013-04-10 19:16

    an excellent article on testing related to cookies
    well organized and precise
    thank you very much for sharing this


  • 2013-06-15 13:55

    thanks


  • 2013-09-25 16:53

    thanks for sharing


  • 2014-06-16 18:01

    This information is useful for me 

    thanks for sharing this information


  • 2014-06-24 18:38

    Thanks


  • 2015-05-02 14:39

    useful


  • 2015-12-20 15:05

    It's useful. Thank you.


Total 20,613
Number Title Author Date Votes Views
20613
SileniusStor is specialized in reselling Cheap Aquafadas software online.
Softwareces | 2022.09.15 | Votes 0 | Views 45048873
Softwareces 2022.09.15 0 45048873
20612
CSStore is specialized in reselling Cheap Steinberg software online.
Softwareces | 2022.09.04 | Votes 0 | Views 44985859
Softwareces 2022.09.04 0 44985859
20611
Software Tester Community Website
ItSeTsQtBer | 2021.04.11 | Votes 0 | Views 45716043
ItSeTsQtBer 2021.04.11 0 45716043
20610
SoapUI Certification Course Content
Steveskok | 2021.02.08 | Votes 0 | Views 45402648
Steveskok 2021.02.08 0 45402648
20609
JavaScript Course Content
Steveskok | 2021.02.08 | Votes 0 | Views 45670662
Steveskok 2021.02.08 0 45670662
20608
Why most mobile testing is not continuous?
(TestExpert) | 2021.02.04 | Votes 0 | Views 46039506
(TestExpert) 2021.02.04 0 46039506
20607
8 Common Mistakes When Planning and Documenting Your Tests
(TestExpert) | 2021.02.04 | Votes 0 | Views 46799212
(TestExpert) 2021.02.04 0 46799212
20606
Types of Performance Testing
Jamessmith | 2021.01.17 | Votes 0 | Views 46153262
Jamessmith 2021.01.17 0 46153262
20605
How to Build E2E Test Cases (1)
tanthanh | 2020.05.28 | Votes 0 | Views 46320028
tanthanh 2020.05.28 0 46320028
20604
[White Paper] Delivering better software using Test Automation
tanthanh | 2020.05.28 | Votes 0 | Views 45863257
tanthanh 2020.05.28 0 45863257
20603
[Whitepaper] How to choose the right API Testing Solution
tanthanh | 2020.05.28 | Votes 0 | Views 45771333
tanthanh 2020.05.28 0 45771333
20602
[Whitepaper] How to choose the right API Testing Solution
tanthanh | 2020.05.28 | Votes 0 | Views 45539628
tanthanh 2020.05.28 0 45539628
20601
TestOps Introduction
VTB | 2020.03.23 | Votes 0 | Views 45301412
VTB 2020.03.23 0 45301412
20600
TestOps Implementation Case Study
VTB | 2020.03.23 | Votes 0 | Views 46130861
VTB 2020.03.23 0 46130861
20599
Selenium Automation Tester Certification Sample Exam Set 3
(TestExpert) | 2020.02.03 | Votes 0 | Views 46141021
(TestExpert) 2020.02.03 0 46141021
20598
Selenium Automation Tester Certification Sample Exam Set 2
(TestExpert) | 2020.02.03 | Votes 0 | Views 46039685
(TestExpert) 2020.02.03 0 46039685
20597
Selenium Automation Tester Certification : Sample Exam Set 1
(TestExpert) | 2020.02.03 | Votes 0 | Views 45673535
(TestExpert) 2020.02.03 0 45673535
20596
What is agile testing? why is agile testing? and what is the benefits? (20)
oishichip | 2019.12.26 | Votes 0 | Views 44995461
oishichip 2019.12.26 0 44995461
20595
Crowd Testing — Vantagens para testadores, plataformas e clientes [pt-br]
soikmd2 | 2019.12.14 | Votes 0 | Views 45450320
soikmd2 2019.12.14 0 45450320
20594
Software Testing Industry Report (Turkey) 2018-2019 (2)
ItSeTsQtB | 2019.08.08 | Votes 0 | Views 46076382
ItSeTsQtB 2019.08.08 0 46076382
20593
How to bypass security in integration tests in ASP.Net Core
ItSeTsQtB | 2019.08.08 | Votes 0 | Views 46895884
ItSeTsQtB 2019.08.08 0 46895884
20592
For agile testing, fail fast with test impact analysis
ItSeTsQtB | 2019.08.08 | Votes 0 | Views 46683846
ItSeTsQtB 2019.08.08 0 46683846
20591
Career Path in Software Testing
^Software^ | 2019.07.28 | Votes 0 | Views 46164187
^Software^ 2019.07.28 0 46164187
20590
Challenges in Big Data Testing
^Software^ | 2019.07.22 | Votes 0 | Views 45719544
^Software^ 2019.07.22 0 45719544
20589
Essential Necessities In Big Data Testing
^Software^ | 2019.07.22 | Votes 0 | Views 45120282
^Software^ 2019.07.22 0 45120282
20588
5 Test Data Generation Techniques
^Software^ | 2019.07.22 | Votes 0 | Views 45851838
^Software^ 2019.07.22 0 45851838
20587
CI and CD for ETL (Extract-Transform-Load) testing.
^Software^ | 2019.07.22 | Votes 0 | Views 45826493
^Software^ 2019.07.22 0 45826493
20586
Quest for Quality Conference : 5-6 Nov 2019 at Dublin, Ireland
VTB | 2019.07.08 | Votes 0 | Views 45729447
VTB 2019.07.08 0 45729447
20585
TestBash Essentials Conference 2019
VTB | 2019.07.08 | Votes 0 | Views 45836537
VTB 2019.07.08 0 45836537
20584
UKSTAR Conference : 11-03-2019
VTB | 2019.07.08 | Votes 0 | Views 45826839
VTB 2019.07.08 0 45826839
20583
Testing in Context Conference Australia (TiCCA) 2019
VTB | 2019.07.08 | Votes 0 | Views 45115760
VTB 2019.07.08 0 45115760
20582
European Testing Conference 2019
VTB | 2019.07.08 | Votes 0 | Views 45805179
VTB 2019.07.08 0 45805179
20581
Automation Guild Online Conference 2019
VTB | 2019.07.08 | Votes 0 | Views 46695320
VTB 2019.07.08 0 46695320
20580
Software Quality Days 2019 : 15 Jan 2019 (1)
VTB | 2019.07.08 | Votes 0 | Views 46080283
VTB 2019.07.08 0 46080283
20579
Skills required to become a Software Tester (1)
IT-Tester | 2019.07.08 | Votes 0 | Views 45846538
IT-Tester 2019.07.08 0 45846538
20578
Automated Unit Testing with Randoop, JWalk and µJava versus Manual JUnit Testing
IT-Tester | 2019.07.08 | Votes 0 | Views 44788504
IT-Tester 2019.07.08 0 44788504
20577
Scrum Testing Guide Book (2)
IT-Tester | 2019.06.26 | Votes 0 | Views 45102945
IT-Tester 2019.06.26 0 45102945
20576
Acceptance Testing Definition in Testing vs Scrum
IT-Tester | 2019.06.26 | Votes 0 | Views 45887530
IT-Tester 2019.06.26 0 45887530
20575
User Acceptance Testing Checklist
VTB | 2019.06.20 | Votes 0 | Views 45920746
VTB 2019.06.20 0 45920746
20574
Firewalls and Types (1)
VTB | 2018.11.14 | Votes 0 | Views 45290602
VTB 2018.11.14 0 45290602
20573
Senior Test Engineer (1)
VTB | 2018.11.05 | Votes 0 | Views 45760640
VTB 2018.11.05 0 45760640
20572
Junior Test Analyst
kornadian2 | 2018.11.04 | Votes 0 | Views 45708544
kornadian2 2018.11.04 0 45708544
20571
Senior Test Engineer
kornadian2 | 2018.11.04 | Votes 0 | Views 45535304
kornadian2 2018.11.04 0 45535304
20570
Programme Test Manager, 12m, Immed Start, $NEG
kornadian2 | 2018.11.04 | Votes 0 | Views 46972116
kornadian2 2018.11.04 0 46972116
20569
Junior Test Analyst
kornadian2 | 2018.11.04 | Votes 0 | Views 45991837
kornadian2 2018.11.04 0 45991837
20568
Dev & Test Manager
kornadian2 | 2018.11.04 | Votes 0 | Views 46666704
kornadian2 2018.11.04 0 46666704
20567
Senior Test Analyst (Performance Tester)
kornadian2 | 2018.11.04 | Votes 0 | Views 46615694
kornadian2 2018.11.04 0 46615694
20566
QA Automation Test Analyst
kornadian2 | 2018.11.04 | Votes 0 | Views 45686389
kornadian2 2018.11.04 0 45686389
20565
Software/Field Testing Engineer
kornadian2 | 2018.11.04 | Votes 0 | Views 45573772
kornadian2 2018.11.04 0 45573772
20564
Compliance Technician (Tester)
kornadian2 | 2018.11.04 | Votes 0 | Views 45201268
kornadian2 2018.11.04 0 45201268