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

Mind Maps: Add-ins in Unified functional testing

Mind Maps: Add-ins in Unified functional testing

In this article mindmap for Add-ins in UFT is explained:


1. Web Add-in Extensibility extends Web  Add-in to customize how UFT recognizes  and interacts with different types of controls

2. We can add or remove add-ins associated  with test in UFT

3. UFT license enables the use of all UFT add-ins.

4. Add-ins in UFT are broadly classified as web  based and windows based application support

5. UFT add-ins help you to create and run tests  and business components on applications  in a variety of development environments.

6. We can define run and record setting for each  of the environment once the add-in is loaded

Mindmap explaining automation framework

In this mind map, we will discuss on automation framework in QTP explaining:


What is automation framework, what are different types of framework, what are key features of an automation framework and expectations from an automation framework:


Mindmap explaining automation framework

Content in the mindmap:
Automation  Framework in QTP
1. Set of Guidelines
1.1 Coding standards
1.2 Structure of test Data
1.3 Folder structure
1.3.1 Test Scripts
1.3.2 Test Libraries
1.3.3 Test Data
1.3.4 Test results
1.4 Object Repositories


2. Decisions
2.1 Decide automation framework to be used
2.2 Decide object Identification technique
2.3 Decide on set of automation guidelines

3. Framework Types
3.1 Linear
3.1.1 Script created by recording on AUT
3.1.2 Script creation is simple, fast and require minimal knowledge
3.1.3 No reusability of code and  high maintenance cost
3.2 Functional Decomposition
3.2.1 Divide test into logical groups or functions
3.2.2 Reusability of code is better
3.2.3 Scripts cannot be run with multiple set of data
3.3 Data Driven
3.3.1   Test data stored in external files drives automation by executing scripts with multiple sets of data
3.3.2 Covers multiple scenario with same script and change in data does not require change in scripts
3.3.3 Additional effort of creating test data and good knowledge of tool for resource
3.4 Keyword Driven
3.4.1 Object, action and arguments are maintained in an excel sheet in form of keywords
3.4.2 Highly reusable code can be used across applications. Once framework is created, easy to create test scripts.
3.4.3 Initial investment in creating framework is high and understanding framework for new user is comparably difficult
3.5 BPT Framework
3.5.1 BPT Components linked together to create test script using Quality center.
3.5.2 Easier for business users to create scripts
3.5.3 License cost of BPT and dependency on QC
3.6 Hybrid Framework
3.6.1 Uses best features of various frameworks
3.6.2 Highly robust and maintainable if properly implemented
3.6.3 Require skilled automation experts.


4. Great Expectations
4.1 Framework should Support Versioning Controlling for files
4.2 should be executed in different environments
4.3 minimal change in script for object changes
4.4 Robust and easy to interpret reporting system
4.5 Should have strong error handling and recovery scenarios

MindMap: Testing Process in QTP

In this article, we will discuss the mindmap for testing process in QTP (the same approach can be used with other tools also).Below are the steps in the testing process for QTP to be followed:
  • Analyse the application under test
  • Perform a proof of concept for understanding automation feasibility.
  • Design the automation test strategy and automation framework
  • Create test scripts and integrate with external tools like quality center or ALM.
  • Execute test scripts.
  • Define strategy for support and maintenance of automation suite.

Testing process in QTP/ UFT
MindMap explaining testing process in QTP

MindMap for Automation testing

This mind map illustrates the basic information about automation testing. Following information is mapped in the below mind map:

  • What is automation testing
  • What are the different phases in automation process.
  • What are different types of frameworks.
  • What are different automation tools.
  • What are the advantage of Automation testing

Automation testing mindmap


Continuing TestNG test execution post assertion failure

Assertions are used to validate if a condition holds true. In previous article, we discuss on how to create assertion in TestNG.


See: How to work with Assertions in TestNG tests.


Assertion added in previous article were hard assertion, i.e : current test execution stops once an assertion fails and the next test in the test suite is executed while using hard assertions. When we use import org.testng.Assert library, the test execution stops once an error is encountered. This is useful to stop an test execution in case of critical defect in the test, and move to next test in the suite.


Example of creating multiple test in explained in the below TestNG.xml


 <?xml version="1.0" encoding="UTF-8"?>  
 <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">  
 <suite name="Suite1">  
 <test name="Test1">  
 <classes>  
   <class name="testNG.assertionVal"/>  
 </classes>  
 </test>  
 <test name="Test2">  
 <classes>  
   <class name="testNG.NewTest1"/>  
 </classes>  
 </test>  
 </suite>  

There can be scenario where we do not want to stop test execution due to a minor validation defect.  In that scenario we can use the concept of soft assertion, i.e the test case execution will continue although the test will be marked as failed in the final results but will be executed until the test flow is completed or an hard assertion failure condition occurs.


Below points are important to note from current article:

  • There are two types of assertion Hard assertion and soft assertion.
  • Hard assertion use import org.testng.Assert library
  • Soft assertion use import org.testng.asserts.SoftAssert library
  • Step  softas.assertAll() needs to be added to display the validation failure from soft assertion failure


Below code explains how to use soft assertion in the test.


 package testNG;  
 import org.testng.Assert;  
 import org.testng.annotations.Test;  
 //soft assertion will use the below softAssert class  
 import org.testng.asserts.SoftAssert;  
 public class assertionVal {  
      // Create an soft assertion object softas   
      SoftAssert softas = new SoftAssert();  
      @Test  
      public void assertVal()   
      {  
           //Create an assertion similar to hard assertion as shown below   
           softas.assertEquals("aaaa", "bb");  
           softas.assertEquals("aa","aaccc","asserts exists");  
           // this is an example of hard assertion, test will stop execution   
           //at this step in case error is encountered.  
           Assert.assertEquals("aa", "aa");  
           System.out.println("nitin");  
           //This step is very important as without this step,  
           //no soft assertion failure will be reported in test result.  
           softas.assertAll();  
      }  
 }  

How to work with Assertions in TestNG tests

     Assertions are added in TestNG to validate whether a condition is true or false and report in test results the execution state of condition. For example in selenium test for login, we provide valid username and password and login, we expect the title to be displayed correctly in the page. Assertions are used in code, where we need to validate the state of an object properties and fail the test in case expected conditions are not met.


Different type of assertions:


  • Assert.AssertEquals(Expected condition, Actual condition) – This compares the expected condition with actual condition and fails the test in case the assertion fails.Different object types can be compared using Assert.AssertEquals
 
  • Assert.AssetEquals(Expected condition, Actual condition, Message)- This compares the expected condition with actual condition and fails the test in case the assertion fails displaying the message as defined while calling the assertion.
 
  • Assert.assertFalse(Boolean condition) - Asserts that a condition is false
 
  • Assert.assertFalse(Boolean condition, String Message )- Asserts that a condition is false. If it isn't, an Assertion Error, with the given message, is thrown.

  • Assert.assertTrue(Boolean condition, String Message )- Asserts that a condition is true. Assertion fails if condition is not true and string message is displayed.

  • Assert.AssertNull(object) – Validates if a assertion is null.


There are various other assertion which we can add in TestNG test. The issue with assertion is case execution stops in case an assertion fails. So if we do not want to stop a test on failure and continue with test execution, using assert statement will not work, instead we can wrap the assert function to verify the test condition and continue with test execution. We will discuss in future article for how to use soft assertion in the test scripts.


Below code explains how to use different assert in TestNG tests.


 package testNG;  
 import java.io.File;  
 import org.openqa.selenium.WebDriver;  
 import org.openqa.selenium.ie.InternetExplorerDriver;  
 import org.testng.Assert;  
 import org.testng.annotations.BeforeTest;  
 import org.testng.annotations.Test;  
 public class assertionVal {  
      WebDriver driver;  
      @BeforeTest  
      public void setup()   
      {  
           File file = new File("D:\\selenium\\IEDriverServer.exe");  
           System.setProperty("webdriver.ie.driver", file.getAbsolutePath());       
           driver = new InternetExplorerDriver();  
      }  
      @Test  
      public void assertVal()   
      {  
           driver.navigate().to("http://qaautomationqtp.blogspot.com");  
           Assert.assertEquals("Learning Automation Concepts in QTP", driver.getTitle());  
           //Assert to compare two values and reporting a message in case validation fails  
           Assert.assertEquals("aaa", "aaa", "this is the first test and value does not match");  
           //Assert to validate a boolean condition as false   
           Assert.assertFalse(driver.getTitle().contentEquals("Learning Automation Concepts in QTP"));  
           //Assert to validate a boolean condition as true   
           Assert.assertFalse(driver.getTitle().contentEquals("Learning Automation Concepts in QTP"));  
        //Assertion to validate an object is not null.  
        Assert.assertNotNull("driver");  
      }  
 }  

Understanding Parameters in TestNG tests

Parameters can be passed to a method from testNG.xml file. In this article, we will discuss on how to Pass parameter value in the methods.


Focus Area of this article:

  • How to pass a parameter from Testng.xml file to the test method.
  • How to define default value of a parameter in a test method.
  • How to pass multiple parameters through TestNG,xml

How to pass a parameter from Testng.xml file to the test method: 


In the below code, we have defined parameter with name as "Param1". Method mailval has argument test which will accept the value as defined in TestNG.xml file.

package testNG;

import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class NewTestoptionalParameter {
@Test
@Parameters("Param1")

  public void mailval(String Test)
  {
   System.out.println(Test);
  }
}

In the testNG.xml file, we need to provide the parameter with name and a value assigned to the parameter as seen below. So if we execute this test from testNG.xml file, we will get the output as Parameter has name as param 1.

 <?xml version="1.0" encoding="UTF-8"?>  
 <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">  
 <suite name="Suite1">  
 <parameter name="Param1" value="Parameter has name as param 1" />  
 <test name="Test1">  
 <classes>  
   <class name="testNG.NewTestoptionalParameter"/>  
 </classes>  
 </test>  
 </suite>  

Let us assume scenario where we have added a parameter in the Test method, but does not define and provide the value of the parameter in the testNG.xml file as shown in the below xml file code.In this case, on execution of the test, we will get the output as blank.

 <?xml version="1.0" encoding="UTF-8"?>  
 <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">  
 <suite name="Suite1">  
 <test name="Test1">  
 <classes>  
   <class name="testNG.NewTestoptionalParameter"/>  
 </classes>  
 </test>  
 </suite>  

We can assign default value to a parameter using Optional as shown in the code below. Now in case we do not define the parameter in the TestNG.xml file, the argument will work with the assigned default value and will output in console as "testing".

package testNG;

import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class NewTestoptionalParameter {
@Test
@Parameters("Param1")

  public void mailval(@Optional("testing") String Test)
  {
   System.out.println(Test);
  }
}

Next thing, we can define multiple parameters for a method as shown in the code below:

package testNG;

import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class NewTestoptionalParameter {
@Test
@Parameters({"Param1","Param2"})

  public void mailval(@Optional("resting") String Test, String Test1)
  {
   System.out.println(Test);
  }
}

And finally , we can define the test parameter at test level as well as suite level. If a parameter is defined at both test as well as suite level, Parameter value defined at test level is considered. 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite1">
<parameter name="Param1" value="Parameter has name as param 1s" /> 
<test name="Test1">
 <parameter name="Param1" value="Parameter has name as param 1t" /> 
 <parameter name="Param2" value="Parameter has name as param 2t" /> 
<classes>
    <class name="testNG.NewTestoptionalParameter"/>
</classes>
</test>
</suite>