Saturday, September 12, 2015

Testing of webpages

A very common question asked in almost all software testing interviews is:

How will you test a webpage or a website?

There is no one complete and correct answer to this question as this is a highly open-ended question aimed at assessing a candidate's ability to think in different directions and find cases where a particular logic or system can break. Also this question is used to assess a candidate's systematic approach to solving an ambiguous problem.

Let us make an attempt at solving this problem:

Step-1: Gather as much minute details as possible by asking clarifying questions.
The questions that can and should be asked (unless the interviewer has already clarified) are:
1. What is the webpage or website about?
2. Who are the intended customers of the website? What all devices is the webpage supported in?
3. How will the intended customers interact with the various UI elements of the webpage?
  • What all text can customers input in the text-boxes.
  • Which links and images can be clicked.
4. What all UI elements are present in the webpage?
5. What all actionable elements (these are elements like buttons, links, text boxes etc. which can be clicked or edited by the user) are present in the webpage?
6. What is the result of such actions on the UI elements? Do I need to test those results also?
7. Is the webpage meant to be displayed in localized languages?
8. What is the peak load that the webpage should sustain to?
This step can itself give the direction to think in and each question can lead to a set of test-cases.

Step-2: Start thinking and writing functional test-cases for each of the details gathered in Step-1.
Question 1: What is the webpage or website about?
Test-cases can be:
1. Check that the title of the page depicts what the webpage is about?
2. Check that the meta tags of the page depict and contain keywords which accurately describe the content of the webpage. Titles and meta description are SEO techniques that help in improving search engine rankings.
3. Check that the content caters to what the webpage is about. Ask questions like the correctness of the content needs to be specified in the product specifications.
4. Check that the content is grammatically correct and legible.

Question 2: Who are the intended customers of the website? What all devices is the webpage supported in?
Test-cases can be:
1. Check that the layout and content is relevant for all classes of intended customers.
2. Check that the layout is responsive so that the webpage is rendered properly in various screen resolutions.
3. Check that the webpage is loading properly across browsers and OS combinations.
4. Ensure that the webpage handles errors gracefully if it is tried to load in non-supported browsers or OS combinations.

Question 3: How will the intended customers interact with the various UI elements of the webpage?
Test-cases can be:
1. Check that the links are clickable.
2. Check that the buttons are clickable.
3. Check that the images are visible and their loading does not take too much time.
4. Check that the text-boxes are clickable and text can be written into them.
5. Check that the elements are accessible using keyboard tab keys.
6. If there are JavaScript elements involved, then their rendering and loading should be checked.
7. Check that hovering on the right elements show intended messages.

Question 4, 5, 6: Functional verification of individual UI elements.
Test-cases can be:
1. Check that the buttons are rendered properly look and feel wise.
2. Check the size of the text-boxes, hint texts and color and size of the text the user types.
3. Maximum length of string that can be input in the text box.
4. What happens if empty string is passed as input.
5. If it is a password text box, then password should be hidden.
6. If there is a form, then proper input validation should be in place.
7. Links should lead to the right pages.
8. None of the links should lead to 404.

Question 7: Is the webpage meant to be displayed in localized languages?
This is called localization testing. Test-cases can be:
1. Check that the webpage is rendered in the correct language when loaded from the correct location.
This can be done using techniques like IP spoofing etc.
2. There should be an option to translate between languages.
3. Check that the translated text in each language is grammatically correct.

Question 8: What is the peak load that the webpage should sustain to?
This comes under performance testing of webpages. Things to be tested in this are:
1. Simulate multiple users hitting the website at the same time.
There are tools to do this: JMeter, Apache Bench.
In the absence of tools, this can be done using multi-threaded routines which send http requests to the server and record response times.
2. Monitor the memory consumption and CPU utilization on server side over a long time.

Security Testing:
Test-cases can be:
1. Cross-site scripting
2. SQL Injection
3. Denial of Service Attacks
4. All customer sensitive data should be transmitted over SSL channels.
5. There should be no non-secure (http) calls or content in https pages.

Value add test-cases:
1. There should be proper logging on server side, so that it can help in debugging.
2. There should be monitors on the server metrics of memory, CPU utilization, logging errors etc.

2 comments: