Blog to understand automation concepts in QTP, Selenium Webdriver and Manual Testing concepts

Component Testing – First Testing in the Project

The first phase is testing the smallest testing unit developed in the Project. A unit can be defined as an isolated piece of code which can be tested independently.Let us take an example, suppose we have to develop an application for an e-commerce site with following requirement.

  • Login into System.
  • Home Page is displayed.
  • Selecting any product and adding to my cart.
  • Paying for the Product.

So In this example, we can divide the project development into following components or units.
  • Login Module.
  • Home Page Module.
  • Transaction Page.
  • View Cart Module.
  • Payment Module.

Before discussing on different testing type. Let us discuss how the development flow takes place. 
  • Development team will develop different modules or units of code.
  • The modules should be integrated successfully with rest of the modules
  • The System developed should be integrated with third party components or existing components.
  • The system should work as per requirement document.

As one of the principle of software testing, defects should be captured as early as possible in the software development life cycle. Since the first step in testing is testing the individual module developed. If the individual module has defect, fixing the same can be painful if captured in later stages of SDLC.Unit testing searches for defects in the testable unit or module as discussed. We need to focus on testing the functional features as well as non-functional characteristics.


Let us take the example of unit testing the login module. A login Page needs to be tested as shown below.

The functional test case for the unit will include:
  • Error Message on providing invalid username or Password.
  • Error Message for minimum and maximum allowed characters.
  • On providing successful username/Password, Home Page is displayed. 
  • Since Home Page is not yet created, we will use stubs and drivers to dummy for home Page.

The above are examples of functional test cases for components.
.

Component testing also includes non-functional characteristics including memory leaks, and structural testing for code coverage. Component testing is done mainly by Developers and is mostly white box testing specially for verification of non-functional validation. Defects are fixed as they are found as is mostly development defect uncovered during dev testing itself.


There are various tools and framework available for unit testing. Junit, testNG are example of framework available for unit testing. Another framework is Test Driven Framework, in which test scripts are prepared before coding. The tests are expected to fail before coding phase. Once Coding is done, all the unit tests are expected to pass. In case, test failing post development, code needs to be fixed until all the tests created for component passed.

Summarizing, all we discussed so far.


Component testing is testing the unit or component or module as an independent unit.
Component Testing is the first testing performed in the project.Component testing is performed mainly by developers.Component testing is more of white box testing on the code.Different Unit testing frameworks are available in the project.


Some Excellent reference article for detailed understanding of Component testing are as follows:


Functional and Non Functional Testing - Difference with Real life example

It is common in testing project to scope of testing in the project is to perform functional as well as non-functional testing in the project. It is important to understand the difference between the two to define strategies for each testing. Let me try to explain this with a simple example in daily life. Suppose I have to test the functional and non-functional requirement of a restaurant.
The functional requirement can be following

When a user enters the restaurant, he will be welcomed by the Staff.  User will place the order; Order will be delivered to User. Once user completes the dinner/lunch, he will pay either by cash or credit card. Staff will say goodbye to user once user exits from the restaurant.
The above is an example of functional requirement in real price, similar in software can be compared to an online e-commerce site.

The functional requirement will be broken down into functional test scenarios which can further be broken down into test cases ensuring all the requirement are covered using RTM (Requirement traceability matrix).

Now coming to the same example, Let us talk about the non-functional requirement in the same example.User will be very much influenced by time it takes from the time he places the order to time order reaches him. This is related to performance and efficiency aspect of requirement.

Similarly there can be security compromise, suppose I pay my bill by credit card and the staff instead of returning the bill with credit card to me, give it to some other customer, and the customer exits with my credit card and spends money from my card. This is an example of Security testing.

Let us take another example, suppose I ordered a dish which needs long cooking, Suppose the food is undercooked. Although I received what I ordered, the food is such that, if I eat it, It will take me one week to recover from its after effect. This is an example of usability testing.

As we see in the example, Non-Functional features (features that were not a part of functional requirement) are very important and needs to be properly tested to ensure the business success.
As in above example, If any one of the performance, security and usability of the restaurant does not meet the customer requirement, There is high probability, the customer will never visit the restaurant again, which will be a business loss to the restaurant.

The same example can be easily reciprocated in software projects. Therefore non-functional testing should be given proper priorities before releasing a project. How much to spend on non functional testing depends on which non-performance parameters are critical.

For e.g in a trading site, security testing should be preference, while in a search engine, e.g. google, the performance, load, stress testing are more important.


Some examples of Non functional includes:

  • Usability Testing
  • Security Testing
  • Performance testing
  • Load Testing
  • Stress testing
  • Scalability Testing
  • Data Integrity Testing
  • Interoperability Testing

Automating Mouse and Keyboard Interaction using Selenium Webdriver

Using Interactions. Action class, we can automate various mouse and keyboard operations using Selenium Webdriver. We can also create a series of operation using Actions class, build the operations and perform the action in series.

Suppose we visit a shopping site, there can be main categories in the header of the Page, on hovering over a main category, sub categories can be displayed, and we can click on the sub categories.
There are three main steps which should be performed.
  •  Identify the series of actions to be performed. This can be an individual action e.g. hovering over a link to a series of event, e.g. pressing up Key in Keyboard, hovering over a link, click on a sub menu.
  • Once we have identified the series of event we need to build the action.
  • Once we have built the action, we need to perform the action.

This can be explained in code below:

//Import following class libraries
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;

Together with this, all the other class libraries for object identification needs to be imported, We assume we have set up for selenium in the machine and knows object Identification using Selenium as this is an advance concept in Selenium.If you want to learn more on basic concepts in Selenium, refer to previous posts in Selenium in this blog or visit the Selenium official website for required knowledge.

//define an object act of Actions class
Actions act = new Actions(driver);
// define the main link in the Page.
WebElement ElemElec = driver.findElement(By.linkText("Electronics"));
// define an object mousehover1 of action class. In action mousehover1, define the flow of event. Example in below case, we define series of events, hovering on the main menu, followed by submenu and then clicking the link.
Action mousehover1 = act.moveToElement(ElemElec).moveToElement(driver.findElement(By.linkText("Access"))).click().build();
mousehover1.perform();

This was an example of using action/ actions to identifying an element in the page using mouse operation and performing action on the same similarly we can automate keyboard actions using Interactions class.

Some of the useful methods of Acton/Actions class are:

  • click() or click(WebElement) – clicks on current mouse location or in the middle of the webElement.

  • doubleClick() or doubleClick(WebElement) – clicks on current mouse location or in the middle of the webElement.

  • dragAndDrop(WebElement src, WebElement tgt) - performs click-and-hold at the location of the source element, releases the mouse at  target location.

  • movetoElement(() or movetoElement(WebElement) – hovers at current location or Element identified by the webElement.

  • SendKeys, KeyUp, and KeyDown – Used to perform keyboard operation by sending keys

  • Build() – Once we have defined the sequence of action to be performed, we use build() to build the sequence of operations to be performed.

  • Perform() – Executing an action.


Details of all the methods of the action or actions class are explained in the Google code site for Selenium.
Please refer http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/interactions/Actions.html for further details on the topic.



In the end, this is 100th Post of this blog. I would like to thanks all readers of the blog for supporting the effort.