Friday, November 27, 2009

Website Cookie Testing: Test cases for testing web application cookies

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 Settings\Default User\Cookies”
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.
This should be enough to know what cookies are. If you want more cookie info see Cookie Central page. 
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.

Testing for Internationalization

Objective
In today’s world, most of the companies are aiming to go global in order to tap the vast opportunities that exist in various global territories. To achieve this aim, there is a growing need of their applications (web and desktop) and websites to support multiple languages. Apart from developing such applications, there is a huge demand for testing these applications.
During my career, we did a lot of research for performing effective language specific testing for various applications. In this paper I am summarizing the findings which can help any novice to understand and achieve effective internationalization testing.
What is Internationalization


Internationalization (abbreviated as “i18n”) entails to design and development of an application or product that removes the barriers to localization.
It can be termed as a process or a practice that allows easy migration of a product from one language to another. The main aim of internationalization is that it helps in product localization.


What is Localization
Localization (abbreviated as “l10n”) entails to adaptation of an application or a product to support the language, culture and other requirements of a particular Locale. 
The first thing that comes to anyone’s mind when asked to perform localization is translation to a particular language. But localization is not just translation. During the course of this document you will come to know about the various things that will help you to perform effective localization testing.


Environment Compatibility
Though Unicode is becoming an increasingly adapted standard for coding, still different Operating Systems show different behaviors for this support. Windows 2000 and Windows XP provide a support for i18n, but Windows Millennium shows a bit of issues with Unicode. Other kind of issues can be seen with Mac and Unix platforms.


Know the Languages and Locales
Various different languages in the world have different characteristics. To build an application that is compatible with Western Europe languages is simpler to the one that needs to support Far eastern languages like Arabic. 


For Left-to-Right (L2R) languages, some of these languages require more screen area as compared to English. E.g. German language UI typically require almost 30% more area than that required by English. Some text translations can also raise issues like in Spanish, OK is translated to ‘Aceptar’, which will raise the issue of button size.


For Right-toLeft (R2L) languages, to perform tests for these languages, an input Method Editor (IME) is mostly preferred as they require a combination of keys for the 101 key keyboards. Among other far east languages, Japanese language uses the combination of two syllabaries with ideographs and also makes use of Latin characters as well, which further complicates the testing process.


Before starting testing identify and decide on the locales that are to be certified initially.
Identify Areas to Test and create Test Plan
It is very important to define the environments before starting the testing for internationalization. The hardware and software requirements for an application that needs to be internationalized should be narrowed down, in the starting, for getting quick results.
Apart from locale language, some of the things that should be kept in mind while testing for localization are


Date and time formats – Some regions put date in dd/mm/yyyy while some put the same in mm/dd/yyyy. The clock is preferred in some regions as in 24 hour format, while some prefer AM/PM. 


Numeric – These can be denoted differently in different countries. Like in US, 100000 is written as 100,000 while the same in India is written as 1,00,000. 
Use of currency – Currency is different for different locales. Even in English locale, currency is different for different countries like US and Canada. 


Symbols, icons and colors – Color schemas can be different for different regions. Like in the traffic lights in US, “Green” symbolizes the “Go” while in Japan the color for same is “Blue”. Same holds true for symbols and icons for regions. 


Names – Most of the English speaking countries use First Name + Middle Name + Last Name, but in some countries like China, Family Name is considered as the First Name. Similar kind of differences can be seen for different countries. 


Keyboard Usage – Apart from the 101 Key Keyboards, different countries have different key caps. Like English-language keyboard starts with “qwerty”, while a German-language keyboard starts with “qwertz”. 


Text and graphics can contain references to objects, actions or ideas which make different sense in different regions.


Varying legal requirements including the appropriate contact information for various locales 
Based on the above information, create a Test Matrix that includes platforms and versions for all the components eligible for certification. Create test cases based on the following guidelines:


Specify tests for English and non-English configurations. 


Develop non-ASCII data for any text that is used in testing. This can either be real non-English data or it can be pseudo-localized data. 


Develop tests that use non-ASCII values in path names, file names, URIs, account preferences, etc., not just in “regular” data. 


Develop tests for time or date values that specify different time zones and include cross-time zone and daylight savings. 


Create some testcases for some mixed configurations (such as Indian client to Japanese server). 


Develop tests for localizability 


Test the Life-cycle (install, uninstall, configure, etc.) 

Internationalization Testing

Definition


Internationalization is the process of designing and coding a product so it can perform properly when it is modified for use in different languages and locales. Localization (also known as L10N) refers to the process, on a properly internationalized base product, of translating messages and documentation as well as modifying other locale specific files. Assuming that there is not a separate base product for the locale, the localized files are installed at their proper location in the base product. This product is then released as a localized version of the product. 
Localizing a properly internationalized product in most cases should require no changes to the source code. 


Internationalization testing is the process, which ensures that product’s functionality is not broken and all the messages are properly externalized when used in different languages and locale. Internationalization testing is also called I18N testing, because there are 18 characters between I and N in Internationalization.


Internationalization 


In I18N testing, first step is to identify all the textual information in the system. This includes all the text present on the application’s GUI, any text/messages that application is producing including error message/warning and help/documentation etc. 


Main focus of the I18N testing is not to find functional defects, but to make sure that product is ready for the global market. As in other non functional testing it is assumed that functional testing has been completed and all the functionality related defects are identified and removed. 


I18N testing can be divided in to two parts. First, to make sure that application’s GUI or functionality will not be broken with the translated text. Second to make sure that translation of all the strings have happened properly. This activity is called Translation Verification Testing and is normally conducted by person who knows the language very well. 


To make sure that application’s functionality or GUI will not be broken after the translation a popular technique known as pseudo-translation is used. In pseudo-translation instead of translating it completely, it is translated in a pseudo manner. For example an externalized string “Bad Command” can be translated in Japanese as [JA XXXXX Bad Command XXXXXX JA]. Now if the product is launched with locale as Japanese it should show the externalized string as given above instead of “Bad Command”. There are utilities to do this job for you, to do pseudo-translation of all the externalized strings of your application. During pseudo-translation you need to make sure that you are doing it roughly according to the rule. For example, width is normally expanded up to forty percent for the pseudo-translated strings as compare to the English. 


As stated above, In I18N testing focus is not on the functionality but on the translation and locale related issues. Once all the externalized strings are pseudo-translated, you need to make sure that you have test case for every message or text element present in the system. Once it is done, same set of test cases can be executed on the properly translated build to make sure that translation is proper.


Pseudo Localisation


A convenient approach to internationalization testing is to use the technique of pseudo-localization. This technique simulates the process of localizing products, involving many things a localization center does when localizing a product. To pseudo-localize a product: 
Pseudo-translate message files by inserting a specific prefix and suffix into every message. You can also modify localizable non-message resources, such as font names and colors. Localizable non-message resources should not be translated. 
Also, other files that may be localized should be modified in some way, such as help, text, html and graphics files. Install the pseudo-translated message files, as well as all other pseudo translated or modified files, in the locale of your choice, at the proper location in the product. In certain cases, such as for Java resource bundles, you must name the files with a locale-specific suffix and install them in the same location as other locale-specific message files. 
Run the product from this locale. The messages and GUI labels should display the prefixes and suffixes you added, and not the English default messages. You should also see the behavior of the modified, localizable non-messages, and other files that were modified, like help, text, html and graphics files, will show the modified versions of these files, when run in this locale. 
This approach allows you to use the product, including its menus and other GUI objects, without needing to know another language or fully translate the message files. Many of the sections that follow take this approach. 

Software Testing Common Terms

Ad hoc Testing:
Ad hoc testing is a commonly used term for software testing performed without planning and documentation. Software Testing portal

The tests are intended to be run only once, unless a defect is discovered. Ad hoc testing is a part of exploratory testing, being the least formal of test methods. In this view, ad hoc testing has been criticized because it isn't structured, but this can also be a strength: important things can be found quickly. It is performed with improvisation, the tester seeks to find bugs with any means that seem appropriate. It contrasts to regression testing that looks for a specific issue with detailed reproduction steps, and a clear expected result. Ad hoc testing is most often used as a complement to other types of testing.

Exploratory Testing:
Exploratory testing is the tactical pursuit of software faults and defects driven by challenging assumptions. It is an approach in software testing with simultaneous learning, test design and test execution. While the software is being tested, the tester learns things that together with experience and creativity generates new good tests to run. In general, exploratory testing is a black box testing technique.