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

Reporting in QTP - Reporter Object

When we run a test in QTP, QTP generates a report based on inbuilt native reporting for steps  defined in QTP. To add user defined results, we have reporter object in QTP.
Below are the properties  and methods  of reporter object which will be described in details below.

Reporter.Filter Property 

Retrieves or sets the current mode for displaying events in the Test Results. You can use this property to completely disable or enable reporting of steps following the statement, or you can indicate that you only want subsequent failed or failed and warning steps to be included in the report.

Reporter.filter = FilterValue.


Filter value can be
·         0 or rfEnableAll – Default , all reporting events are displayed.
·         1 or rfEnableErrorandWarnings – only error and warning events are displayed.
·         2 or rfEnableErrorsOnly – Only errors are displayed.
·         3 or rfDisableAll – No event are displayed in results.

Reporter.ReportEvent Method

Reports an event to the results

Syntax: Reporter.reportEvent  eventstatus, reportStepName, Details,[Image]


EventStatus can have value 0, 1,2,3 or micPass,micFail, micDone, and micwarning.
reportStepName Name of the steps
Details – Details of execution.
Image – Path of imagefile to be attached for event.

Reporter.ReportPath property

 This retrieves the folder Path in which current test results are saved.

Reporter.RunStatus property

Retrieves the run status at the current point of the run session. For tests, it returns the status of current test during the test run.


Working with DataBase in QTP - Understanding Connection and Recordset object

QTP Interacts with database creating an instance of ADODB object using ADO. ADO is a Microsoft technology and stands for ActiveX Data Objects and is a programming interface to interact and access data from a database.

Connection Object


Before a database can be accessed by QTP, An object for database connection has to be established.

Set adocon = createobject(“Adodb.connection”)

Once the object is created, we need to set connection string to connect to the database. We can define a connection string with details of database including database provider, database, and user credentials for access.

Some useful methods and properties of connection object are as follows:


Properties:


adocon.connectionstring – This property sets or returns the details used to create a connection to a data source. Includes details of driver, database,username and password.


Strconnection = "Driver=… "Server=svrnme;uid=username;pwd=password;"
For e.g to connect to a database for excel the strConnection would be like:
 strcon = "Driver={Microsoft Excel Driver (*.xls)};Dbqls="+xfilename +";ReadOnly=0;"

For details of connection strings, see www.connectionstrings.com

adocon.ConnectionTimeout – this defines the time  to wait for a connection to be established.


adocon.provider – This sets or gets connection provider name.


adocon.state – gives status whether connection is on or off.


Methods


adocon.open – opens a database connection based on the connection string provided. 

adocon.Open connectionstring,userID,password,options


adocon.Execute – execute the sql statement provided

adocon.execute “Select * from table”

adocon.close – This closes the adodb connection.


RecordSet Object:

 Once a connection has been established, we can create recordset object to hold a set of record from database. A recorset consists of records and column

Set rs = createobject(“”Adodb.recordset”)

Some useful methods and properties of RecordSet Objects are as follows:

Properties:


BOF property returns True  if the current record position is before the first record in the Recordset,



EOF property returns True if the current record position is after the last record in the Recordset, otherwise it returns False. For a empty recordset,i.e no records in the recordset or empty recordset, value of BOF and EOF is false. So the property can be used in a loop to validate RecordSet does not return any records.


MaxCount Property returns the maximum value of records to be returned in a recordset.
rs.MaxCount = 20 will return 20 rows of data in recordset.


Methods:


rs.cancel – cancels an existing execution.


rs.clone – returns a clone of existing recorset and assigns to an object

set rsclone = rs.clone


rs.Close - closes instance of recordset


rs.open – opens a recordset based on query specified.

rs.open sqlquery, adocon

where sqlquery is query executed and adocon is connection object.

rs.move – moves the pointer in a recordset by specified count as defined in numrec
rs.move numrec, start.

Also  movenext,moveprevious, movefirst, movelast can be used to move to specified location in recordset.


rs.fields.count gives number of items in the fields collection.


rs.field.item(i) returns specified item from the collection.




Guidelines and features of different Automation frameworks in QTP

Definition :

A test automation framework is a set of assumptions, concepts and tools that provide support for automated software testing. An Automation Framework is a set of guidelines that you can follow during test case scripting to achieve successful automation results and high return on investment.

Guidelines in creating the automation framework:


1.  Select the tool to be used for test automation
2.  Select type of automation framework to be implemented in the automation based on project complexity and the tool.
3.  Define folder structure to be used for Object repositories, function libraries, test script, test data and other artifacts to be used for interaction.
4.  Validate proper interaction between various resources used in the framework.
5.   Define a driver script to execute test in batches.
6.   Define proper test results reporting to be used in automation.
7.   Define proper error handling and recovery scenarios to be implemented.
8.   Validate functions are created with proper coding standards and ensure high reusability in the framework.

Salient Features


Salient features of good automation framework are as follows:

  • High reusability of automation framework. Functions, structure used in framework should be reusable and easy to implement during script preparation.
  • Maintenance of the framework should be easy and easy to understand for new user.
  • Framework should ensure minimum effort from end user during script execution.
  • Test Results should be self explanatory.
  • Framework should be be able to run scripts smoothly without any issues and proper error handling should be defined in framework.
  • Automation Framework should be robust with good exceptional handling.
  • Automation Framework should be reliable.
  • Automation framework should be application independent.
  • Return on investment should be high in long run for automation. Framework should be choosen and created in such a manner to ensure high ROI.


Types of Automation Framework


Following are the types of Automation Frameworks.

1. Linear Framework:

     Linear scripts are created with steps written in a linear manner. Steps are recorded in this framework using record- play mechanism. This framework does not require any automation expertise as steps are recorded by record and play method.  This is useful for stable application with only a few tests with the same set of data as data is hard coded in this method.

2. Modular or function decomposition Framework:

In this approach test scripts  are first analyzed to find out the reusable flows. Steps for these flows are grouped together to create functions. Still test data is hard coded in this framework although reusability is improved.

3. Data Driven Framework:

      In Data driven framework data is stored in external files in the form of excel file, text files, database. Test data interacts with code through the external file. Since data is stored in an external file, test can be run with multiple set of data without any change in the code.

4. Keyword Driven Framework: 

      In Keyword Driven Framework we create a set of Keywords & Data Tables, the entire functionality of application gets captured as step by step instructions for every test. We create different keywords and associate different actions with these keywords in this framework. Once framework is prepared, it is much easier to implement using keywords defined.

5. Hybrid Framework:  

      This framework  is created by combining different features of different frameworks  and creating a framework with required features of the framework discuss like creating reusable functions, using data driven techniques and defining keywords all in the same framework.

6. BPT Framework:

      Business process testing framework divides test case flow into multiple Business Components. These business component are reusable and can be used in different tests to create workflow and business tests. This framework is maintained in quality center and requires QC to create framework and execute.