32
Thatavarti Technologies Pvt Ltd Independent Testing Company Confidential Thatavarti QTP Architecture Implementation Document Thatavarti’s Training Unit School of Software Testing

Thatavarti QTP Architecture

Embed Size (px)

Citation preview

Page 1: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

Thatavarti QTP ArchitectureImplementation Document

AuthorT.V.RadhaKrishna

Thatavarti’s Training UnitSchool of Software Testing

Page 2: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

About Thatavarti

Thatavarti Technologies Pvt. Ltd (TT) is a next generation cutting-edge enterprise and a leading provider of independent software testing services. We are renowned for executing prestigious projects for global IT giants. The company comprises an outstanding team of highly spirited software testing professionals, who are spread across its offices in India and overseas. They are collectively accelerating the company's growth by providing unparalleled software testing services. TT is uniquely positioned to create value and provide competitive advantages to its customers. Its professional management is driving the company to higher orbits of excellence. It's commitment to help customers maximize the business value of IT and its successful track record of accomplishments over time in delivering competitive advantages is a standing testimony to its capabilities and efficiencies.

Effort Invested: Thatavarti has invested 40 man months effort to understand industry standard application, then design and code the automation architecture that can be implemented across the industry standard automation tools. In this white paper all our examples are 100% implementation friendly in Mercury QTP.

Architecture Diagram

Thatavarti’s Training UnitSchool of Software Testing

Page 3: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

Folder Structure implemented in Architecture:

01. Object Repository (OR)

Learn all the objects related to application. Steps involved are :

1. List the total windows in the current application – add all the windows with descendant objects into OR. (Object Repository <add objects>.

2. Change the window names and object names according to your own naming conventions

3. The above steps will enable you to get the complete grip on OR.

02. Test Scenarios (TS)

Set of test cases is called a test scenario. Test case is a description one action with associated data and what to be tested.

1. Collect all the TS that are applicable for automation and review it twice to check whether all test cases are independent.

2. Add 2 column names i.e WebPage/Window and Objects Map each test case with the respective windows and objects.

3. Add Test Data column and analyze whether the respective case will have data. Need to understand is the data is dynamic or selected from application drop downs

4. List all the preconditions required to execute the respective test scenario – the respective tests should be chosen as Start-up script.

5. Add a column “Repeated” – If a particular test cases or set of test cases are repeated; the choose them as functions. If the functionality is associated with business mark it as a Business Function else Generic Function.

Thatavarti’s Training UnitSchool of Software Testing

Page 4: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

03. Functions All the functions are developed using the Object Oriented Methodology.Business Functions Related to one window are handled in one classGeneric functions like Database connectivity are handled in single class

All the function should be written in notepad and save it as .vbs files. This .vbs files should be executed in Driver script to access the all related functions.

Generic Functions'**********************************************************************' Class Name : DBConnect' Start Date : 28/02/06' End Date : 28/02/06' Author : Thatavarti Technologies Pvt. Ltd' Reviewed By : Thatavarti Technologies Pvt. Ltd' Reviewed Date : 28/02/06'**********************************************************************class DBConnect

Dim objdbConnectionDim objRecordset'****************************************************************' Function Name : getDBConnection' Input Parameters : -Nil-' Description : This Function is used to Establish Database Connection.

'****************************************************************Function getDBConnection() Set objdbConnection = CreateObject("ADODB.Connection") objdbConnection.open "dsn=Syscon_Connect" getDBConnection = objdbConnection.state End Function

'****************************************************************' Function Name : getFieldValue' Input Parameters : strFieldName' Description : This Function is used to Fetch a Record From Database.

'****************************************************************Function getFieldValue(strFieldName)

Set objRecordSet = CreateObject("ADODB.Recordset")objRecordSet.Open "Select " & strFieldName & " From

SysconCronus",objdbConnection,1,1getFieldValue = objRecordSet(0)

End Function

Thatavarti’s Training UnitSchool of Software Testing

Page 5: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

'****************************************************************' Function Name : getLoginValue' Input Parameters : strFieldName' Description : This Function is used to Fetch a Record From Database.

'****************************************************************Function getLoginValue(strFieldName)

Set objRecordSet = CreateObject("ADODB.Recordset")objRecordSet.Open "Select " & strFieldName & " From

UserLogin",objdbConnection,1,1getLoginValue = objRecordSet(0)

End Function

Function ClearItemsdim dbconnectset dbconnect = createobject("ADODB.Connection")dbconnect.open "dsn=cronus; uid=sa;pwd=sa"If (dbConnect.state=1) Then

dbconnect.execute "delete from dbo.allitem where itemcode between '900' and '2000'"'dbconnect.execute "delete from dbo.itemmast where itemcode between '900' and

'2000'"str=true

elsestr=false

End Ifset dbconnect = nothingClearItems=strEnd Function

End Class

Thatavarti’s Training UnitSchool of Software Testing

Page 6: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

Business Functions

' Copyright Thatavarti Technologies

'****************************************************************************' Class Name : ItemMaster' Window It Represents : Item Master' Start Date : 28/8/06 ' End Date : 28/8/06 ' Author : Thatavarti Technologies Pvt. Ltd' Reviewed By : Thatavarti Technologies Pvt. Ltd' Reviewed Date : 28/8/06 '****************************************************************************Class wndItemMaster '***************************************************************************

*******' Procedure Name : setItemCode' Input Parameters : strItemCode' Description : This Procedure is used to Set the ItemCode in the Item Master

window. '***************************************************************************

******* Sub setItemCode(strItemCode) If (vbWindow("ItemMaster").VbComboBox("ItemCode").Exist(20)) Then

If (vbWindow("ItemMaster").VbComboBox("ItemCode").GetROProperty("enabled") = True)Then

vbWindow("ItemMaster").VbComboBox("ItemCode").Type strItemCode End IfEnd If

End Sub '***************************************************************************

*******' Procedure Name : setItem' Input Parameters : strItem' Description : This Procedure is used to Set the Item in the Item Master

window. '***************************************************************************

******* Sub setItem (strItem)

If (vbWindow("ItemMaster").VbComboBox("Item").Exist(20)) Then

If(vbWindow("ItemMaster").VbComboBox("Item").GetROProperty("enabled")=True) ThenvbWindow("ItemMaster").VbComboBox("Item").Type strItemvbWindow("ItemMaster").VbComboBox("Item").Type micreturn

Thatavarti’s Training UnitSchool of Software Testing

Page 7: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

End If End If End Sub '***************************************************************************

******* ' Procedure Name : selectAcceptedBy' Input Parameters : strAcceptedBy' Description : This Procedure is used to Select the AcceptedBy Department in

the Item Master window. '***************************************************************************

******* Sub selectAcceptedBy(strAcceptedBy) If (vbwindow("ItemMaster").VbComboBox("AcceptedBy").Exist(20) )then

If(vbWindow("ItemMaster").VbComboBox("AcceptedBy").GetROProperty("Enabled")= True)ThenvbWindow("ItemMaster").VbComboBox("AcceptedBy").Select strAcceptedBy

End If End If End Sub '***************************************************************************

*******' Procedure Name : selectLocation' Input Parameters : strLocation' Description : This Procedure is used to Select the select Location in the Item

Master window. '***************************************************************************

******* Sub selectLocation(strLocation) If (vbwindow("ItemMaster").VbComboBox("Location").Exist(20) )then

If(vbWindow("ItemMaster").VbComboBox("Location").GetROProperty("Enabled")= True)Then

vbWindow("ItemMaster").VbComboBox("Location").Select strLocation End If End If End Sub '***************************************************************************

*******' Procedure Name : selectGroup' Input Parameters : strGroup' Description : This Procedure is used to Select the select Group in the Item

Master window. '***************************************************************************

******* Sub selectGroup(strGroup) If (vbwindow("ItemMaster").VbComboBox("Group").Exist(20) )then

If(vbWindow("ItemMaster").VbComboBox("Group").GetROProperty("Enabled")= True)Then

vbWindow("ItemMaster").VbComboBox("Group").Select strGroup

Thatavarti’s Training UnitSchool of Software Testing

Page 8: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

End If End If End Sub '***************************************************************************

*******' Procedure Name : selectClass' Input Parameters : strClass' Description : This Procedure is used to Select the select Class in the Item

Master window. '***************************************************************************

******* Sub selectClass(strClass) If (vbwindow("ItemMaster").VbComboBox("Class").Exist(20) )then

If(vbWindow("ItemMaster").VbComboBox("Class").GetROProperty("Enabled")= True)Then

vbWindow("ItemMaster").VbComboBox("Class").Select strClass End If End If End Sub '***************************************************************************

*******' Procedure Name : selectForSales' Input Parameters : strChkBoxVal' Description : This Procedure is used to Click For Sales in the Item Master

window. '***************************************************************************

******* Sub selectForSales(strChkBoxVal) If (vbwindow("ItemMaster").VbCheckBox("ForSales").Exist(20)) then

If(vbWindow("ItemMaster").VbCheckBox("ForSales").GetROProperty("Enabled")= True)Then

vbWindow("ItemMaster").VbCheckBox("ForSales").Set strChkBoxVal End If End If End Sub '***************************************************************************

*******' Procedure Name : selectSalesAccount' Input Parameters : strSalesAccount' Description : This Procedure is used to Select the SalesAccount in the Item

Master window. '***************************************************************************

******* Sub selectSalesAccount(strSalesAccount) If (vbwindow("ItemMaster").VbComboBox("SalesAccount").Exist(20)) then

Thatavarti’s Training UnitSchool of Software Testing

Page 9: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

If(vbWindow("ItemMaster").VbComboBox("SalesAccount").GetROProperty("Enabled")=True)Then

vbWindow("ItemMaster").VbComboBox("SalesAccount").Select strSalesAccount

End If End If End Sub '***************************************************************************

*******' Procedure Name : selectPurchaseAccount' Input Parameters : strPurchaseAct' Description : This Procedure is used to Select the PurchaseAct in the Item

Master window. '***************************************************************************

******* Sub selectPurchaseAccount(strPurchaseAct)

If (vbwindow("ItemMaster").VbComboBox("PurchaseAccount").Exist(20)) ThenIf

(vbwindow("ItemMaster").VbComboBox("PurchaseAccount").GetROProperty("enabled")=True) Then

vbwindow("ItemMaster").VbComboBox("PurchaseAccount").Select strPurchaseActEnd If

End If End Sub '***************************************************************************

*******' Procedure Name : selectForProcurement' Input Parameters : strChkBoxValue' Description : This Procedure is used to Select the ForProcurement in the Item

Master window. '***************************************************************************

******* Sub selectForProcurement(strChkBoxValue) If (vbwindow("ItemMaster").VbCheckBox("ForProcurement").Exist(20)) Then

If (vbwindow("ItemMaster").VbCheckBox("ForProcurement").GetROProperty("enabled")=True) Then

vbwindow("ItemMaster").VbCheckBox("ForProcurement").Set strChkBoxValue

End IfEnd If

End Sub '***************************************************************************

*******' Procedure Name : setFormsPartOfBOM' Input Parameters : strChkBoxVal

Thatavarti’s Training UnitSchool of Software Testing

Page 10: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

' Description : This Procedure is used to setFormsPartOfBOM in the Item Master window.

'**********************************************************************************

Sub setFormsPartOfBOM(strChkBoxVal) If

( vbWindow("ItemMaster").ActiveX("TabsBar").VbCheckBox("Details_FormsAPartOfBOM").Exist(20)) Then

If (vbWindow("ItemMaster").ActiveX("TabsBar").VbCheckBox("Details_FormsAPartOfBOM").GetROProperty("enabled")=True) Then

vbWindow("ItemMaster").ActiveX("TabsBar").VbCheckBox("Details_FormsAPartOfBOM").Set "ON"

End If End If End Sub '***************************************************************************

*******' Procedure Name : selectReceivingUnits ' Input Parameters : strRecUnits' Description : This Procedure is used to Select the Receiving Units in the Item

Master window. '***************************************************************************

******* Sub selectReceivingUnits (strRecUnits) If

(vbWindow("ItemMaster").ActiveX("TabsBar").VbComboBox("Details_ReceivingUnits").Exist(20)) Then

If (vbWindow("ItemMaster").ActiveX("TabsBar").VbComboBox("Details_ReceivingUnits").GetROProperty("enabled")=True) Then

vbWindow("ItemMaster").ActiveX("TabsBar").VbComboBox("Details_ReceivingUnits").Select strRecUnits

End If End If End Sub '***************************************************************************

*******' Procedure Name : selectIssuingUnits ' Input Parameters : strIssueUnits' Description : This Procedure is used to Select the Issuing Units in the Item

Master window. '***************************************************************************

******* Sub selectIssuingUnits (strIssueUnits)

Thatavarti’s Training UnitSchool of Software Testing

Page 11: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

If (vbWindow("ItemMaster").ActiveX("TabsBar").VbComboBox("Details_IssuingUnits").Exist(20)) Then

If (vbWindow("ItemMaster").ActiveX("TabsBar").VbComboBox("Details_IssuingUnits").GetROProperty("enabled")=True) Then

vbWindow("ItemMaster").ActiveX("TabsBar").VbComboBox("Details_IssuingUnits").Select strIssueUnits

End If End If End Sub '***************************************************************************

*******' Procedure Name : setPrice' Input Parameters : strPrice ' Description : This Procedure is used to Set The Price in the Item Master

window. '***************************************************************************

******* Sub setPrice(strPrice) If (vbWindow("ItemMaster").ActiveX("TabsBar").VbEdit("Details_Price").Exist(20)) Then If

(vbWindow("ItemMaster").ActiveX("TabsBar").VbEdit("Details_Price").GetROProperty("enabled")=True) Then

vbWindow("ItemMaster").ActiveX("TabsBar").VbEdit("Details_Price").Set strPrice

End If End If End Sub '***************************************************************************

*******' Procedure Name : setLeadTime' Input Parameters : strLeadTime' Description : This Procedure is used to set the Lead Time in the Item Master

window. '***************************************************************************

******* Sub setLeadTime(strLeadTime) If (vbWindow("ItemMaster").ActiveX("TabsBar").VbEdit("Details_LeadTime").Exist(20))

Then If

(vbWindow("ItemMaster").ActiveX("TabsBar").VbEdit("Details_LeadTime").GetROProperty("enabled")=True) Then

vbWindow("ItemMaster").ActiveX("TabsBar").VbEdit("Details_LeadTime").Set strLeadTime

Thatavarti’s Training UnitSchool of Software Testing

Page 12: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

End If End If End Sub

End Class

Log File Implementation

Dim s,q,k,a,y,w,e,z,filenameDim objfsoDim objfiles=date

k=instr(1,s,"/")If (k>0) Then

q=split(s,"/")a=q(1)&"-"&q(0)&"-"&q(2)

elsea= s

End If y=time

w=split(y,":")e=split(w(2)," ")z=w(0)&"."&w(1)&e(1)filename=a&"@"&zSet objfso=createobject("scripting.filesystemobject")Set objfile=objfso.createtextfile(LOG_FOLDER&filename&".txt",true)objfile.writeline "This is the logfile generated for Item master " &vbcrlfobjfile.writeline "Script executed on "& a & " at " &y &vbcrlf

Constants Declaration

Declare all the constants in .vbs file and attach it as resources to QTP Test Setting resources. All the other .vbs files paths should be assigned to constants to save it in constants.vbs. This will enable you to execute any .vbs file in driver script.

Example: Const ACCEPTEDBY_FINANCE = "FINANCE"

Const CHECKBOX_CHECKED = "ON"Const CHECKBOX_UNCHECKED = "OFF"Const SALES_DOMESTIC = "SALES(DOMESTIC)"Const SALES_EXPORTS = "SALES (EXPORTS)"Const UNITS_OF_MEASUREMENT_NOS = "NOS"

Const UTILITES_PATH = "D:\Syscon Cronus\Utilities\"

Thatavarti’s Training UnitSchool of Software Testing

Page 13: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

Const APP_PATH = "D:\Syscon Cronus\Control\"Const SOURCE_FOLDER = "D:\Thatavarti_SysconQTP)\Business Functions\"const LOG_FOLDER = "D:\Thatavarti_Syscon_Automation(QTP)\Log Files\"const BASE_DRIVE = "D:\Thatavarti_Syscon_Automation(QTP)\Generic Functions\"Const APP_PATH = "D:\Syscon Cronus\Control\"

Driver Script

' Copyright Thatavarti Technologies

'*****************************************************************************************************************************

' Script Name : Defining An Item In Item Master' Test Scenario Name : ' Start Date : ' End Date : ' Author : ' Modified By : --NIL--' Modified Date : --NIL--' Reviewed By : ' Reviewed Date : ' Description : ' PseudoCode : '****************************************************************************

********** 'This statement Ensures that all variables which are used in the script are declared

Option Explicit ' ******************************************************************************************************************************************

' Loading of Executable Files'

******************************************************************************************************************************************

ExecuteFile SOURCE_FOLDER & "wndItemMaster.vbs"ExecuteFile SOURCE_FOLDER & "wndMain.vbs"ExecuteFile SOURCE_FOLDER & "wndStoresLogin.vbs"ExecuteFile BASE_DRIVE & "DBConnect.vbs"ExecuteFile BASE_DRIVE & "SysconCleanup.vbs"'****************************************************************************

**************************************************************' Declaring the Variables

Thatavarti’s Training UnitSchool of Software Testing

Page 14: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

'******************************************************************************************************************************************

Dim blnClicked ' boolean value. returns True or FalseDim objItemMaster ' object to Item MasterDim objwndMainDim objwndStoresLoginDim objCleanupDim strItemCodeValDim strItemValDim arrItemCodeValDim arrItemValDim strLocationValDim strGroupValDim strClassValDim strForSalesValDim strSalesAccountVal Dim strFormsBOMVal Dim strReceivingUnitsValDim strIssuingUnitsVal Dim strPriceValDim strLeadTimeVal Dim objdbConnectionDim blnDBConnectedDim strUserNameDim intNoOfIterationsDim strForProcurementValDim strProcureAccountValDim intCounterDim LoopVar

'******************************************************************************************************************************************

' Setting the Objects to the Classes'****************************************************************************

**************************************************************Set objdbConnection = New DBConnectSet objItemMaster = New wndItemMasterSet objwndMain = New wndMainSet objwndStoresLogin= New wndStoresLoginSet objCleanup= New Cleanup'****************************************************************************

**************************************************************objdbconnection.clearItems

'******************************************************************************************************************************************

Thatavarti’s Training UnitSchool of Software Testing

Page 15: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

' Creating Log File'****************************************************************************

**************************************************************Dim s,q,k,a,y,w,e,z,filenameDim objfsoDim objfiles=date

k=instr(1,s,"/")If (k>0) Then

q=split(s,"/")a=q(1)&"-"&q(0)&"-"&q(2)

elsea= s

End If y=time

w=split(y,":")e=split(w(2)," ")z=w(0)&"."&w(1)&e(1)filename=a&"@"&zSet objfso=createobject("scripting.filesystemobject")Set objfile=objfso.createtextfile(LOG_FOLDER&filename&".txt",true)objfile.writeline "This is the logfile generated for Item master " &vbcrlfobjfile.writeline "Script executed on "& a & " at " &y &vbcrlf

' ******************************************************************************************************************************************

' Connecting to the Database'

******************************************************************************************************************************************

blnDBConnected = objdbConnection.getDBConnection()If (blnDBConnected = 1) Then

Reporter.ReportEvent micPass,"Connection to the Database","Successfully Connected to the Database"

objfile.writeline time &vbtab & "Connection is Established successfully" &vbcrlfElse

Reporter.ReportEvent micFail,"Connection to the Database","Failed to Connect to the Database"

objfile.writeline time &vbtab & "Connection is not Established successfully" &vbcrlf

End If'

******************************************************************************************************************************************

' Fetching Values from Database

Thatavarti’s Training UnitSchool of Software Testing

Page 16: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

' ******************************************************************************************************************************************

strItemCodeVal = objdbConnection.getFieldValue("ItemCode")arrItemCodeVal = Split(strItemCodeVal,",")

strItemVal = objdbConnection.getFieldValue("Item")arrItemVal = Split(strItemVal,",")

If (UBound(arrItemCodeVal,1) <> 0) ThenintNoOfIterations = UBound(arrItemCodeVal,1)

If (UBound(arrItemCodeVal,1) <> UBound(arrItemVal,1)) Then ExitRunEnd If

End IfstrLocationVal = objdbConnection.getFieldValue("Location")strGroupVal = objdbConnection.getFieldValue("Group")strClassVal = objdbConnection.getFieldValue("Classification")strForProcurementVal = objdbConnection.getFieldValue("ForProcurement") strProcureAccountVal = objdbConnection.getFieldValue("PurchaseAccount")strForSalesVal = objdbConnection.getFieldValue("ForSales")strSalesAccountVal = objdbConnection.getFieldValue("SalesAccount")strFormsBOMVal = objdbConnection.getFieldValue("FormsAPartOfBOM")strReceivingUnitsVal = objdbConnection.getFieldValue("ReceivingUnits")strIssuingUnitsVal = objdbConnection.getFieldValue("IssuingUnits")strPriceVal = objdbConnection.getFieldValue("Price")strLeadTimeVal = objdbConnection.getFieldValue("LeadTime")strUserName = objdbConnection.getLoginValue("UserName")'

******************************************************************************************************************************************

' Launching the Application'

******************************************************************************************************************************************

'SystemUtil.Run"\\Thatavartihome2\syscon cronus\Control\Shortcutbar.exe"objwndMain.CreateshortCutbarobjfile.writeline time &vbtab & "ShortCut Bar Invoked Successfully" &vbcrlfobjwndMain.setUserName strUserNameobjfile.writeline time &vbtab & "User Name Entered successfully" &vbcrlfobjfile.writeline time &vbtab & "User Name: " &vbtab & strUserName &vbcrlfblnClicked =objwndMain.clickOK()

If(blnClicked=true) ThenReporter.ReportEvent micPass,"Clicking on OK","Successfully Clicked on OK button

of Main Window"objfile.writeline time &vbtab & "OK button Clicked successfully" &vbcrlf

else

Thatavarti’s Training UnitSchool of Software Testing

Page 17: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

Reporter.ReportEvent micFail,"Clicking on OK","Fail to Click on OK button of Main Window"

objfile.writeline time &vbtab & "OK button Not Clicked" &vbcrlf End If'

******************************************************************************************************************************************

' For Clicking On Stores Button In ShortCut Bar and For Logging'

******************************************************************************************************************************************

vbwindow("frmShortcutBar").ActiveX("Toolbar").VbToolbar("Toolbar").Press 4objfile.writeline time &vbtab & "Stores button Clicked successfully" &vbcrlf

objwndStoresLogin.setUserName strUserNameobjfile.writeline time &vbtab & "UserName Entered Successfully" &vbcrlfobjfile.writeline time &vbtab & "User Name: " &vbtab & strUserName &vbcrlfvbWindow("StoresLogin").VbEdit("Stores_UserId").Type micReturnvbWindow("StoresLogin").VbEdit("Stores_Password").Type micReturnvbWindow("StoresWindow").Type micCtrlDwn + "m" + micCtrlUp '

******************************************************************************************************************************************

' For Creating Items In Item Master'

******************************************************************************************************************************************

'For LoopVar = LOOP_START to LOOP_END For intCounter = 0 To intNoOfIterations

objfile.writeline "------------------------------------------------------------------------------" &vbcrlf

objItemMaster.setItemCode arrItemCodeVal (intCounter)objfile.writeline time &vbtab & "Item Code Entered" &vbcrlfobjfile.writeline time &vbtab & "Item Code: " &vbtab & arrItemCodeVal(intCounter)

&vbcrlf'objItemMaster.setItemCode(strItemCodeVal)'Wait(3)objItemMaster.setItem arrItemVal (intCounter)objfile.writeline time &vbtab & "Item Name Entered " &vbcrlfobjfile.writeline time &vbtab & "Item Name: " &vbtab & arrItemVal(intCounter)

&vbcrlf'objItemMaster.setItem(strItemVal)objItemMaster.selectAcceptedBy ACCEPTEDBY_FINANCEobjfile.writeline time &vbtab & "Acceptedby Selected " &vbcrlfobjfile.writeline time &vbtab & "Acceptede by : " &vbtab &

ACCEPTEDBY_FINANCE &vbcrlfobjItemMaster.selectLocation strLocationVal

Thatavarti’s Training UnitSchool of Software Testing

Page 18: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

objfile.writeline time &vbtab & "Location Selected" &vbcrlfobjfile.writeline time &vbtab & "Location Name: " &vbtab & strLocationVal &vbcrlfwait(5)objItemMaster.selectGroup strGroupValobjfile.writeline time &vbtab & "Group Name Selected" &vbcrlfobjfile.writeline time &vbtab & "Group Name: " &vbtab & strGroupVal &vbcrlfobjItemMaster.selectClass strClassValobjfile.writeline time &vbtab & "Class Name selected" &vbcrlfobjfile.writeline time &vbtab & "Calss Name: " &vbtab & strClassVal &vbcrlfIf (intCounter = intNoOfIterations) Then

objItemMaster.selectForSales strForSalesValobjfile.writeline time &vbtab & "ForSales Selected" &vbcrlfobjfile.writeline time &vbtab & "ForSales: " &vbtab & strForSalesVal &vbcrlfobjItemMaster.selectSalesAccount strSalesAccountValobjfile.writeline time &vbtab & "Sales Account Selected" &vbcrlfobjfile.writeline time &vbtab & "User Name: " &vbtab & strSalesAccountVal

&vbcrlfElse

objItemMaster.selectForProcurement strForProcurementValobjfile.writeline time &vbtab & "For Procurement Selected" &vbcrlfobjfile.writeline time &vbtab & "For Procurement: " &vbtab &

strForProcurementVal &vbcrlfobjItemMaster.selectPurchaseAccount strProcureAccountValobjfile.writeline time &vbtab & "Purchase Account Selected" &vbcrlfobjfile.writeline time &vbtab & "Purchase Account: " &vbtab &

strProcureAccountVal&vbcrlfobjItemMaster.setFormsPartOfBOM strFormsBOMValobjfile.writeline time &vbtab & "Part of BOM Selected" &vbcrlfobjfile.writeline time &vbtab & "Part of BOM : " &vbtab & strFormsBOMVal

&vbcrlfEnd IfobjItemMaster.selectReceivingUnits strReceivingUnitsValobjfile.writeline time &vbtab & "Receiving Units Entered" &vbcrlfobjfile.writeline time &vbtab & "Receiving Units: " &vbtab & strReceivingUnitsVal

&vbcrlfobjItemMaster.selectIssuingUnits strIssuingUnitsValobjfile.writeline time &vbtab & "Issuing Units entered" &vbcrlfobjfile.writeline time &vbtab & "Issuing Units: " &vbtab & strIssuingUnitsVal &vbcrlfvbWindow("ItemMaster").Type micReturnobjItemMaster.setPrice strPriceValobjfile.writeline time &vbtab & "Price Value entered" &vbcrlfobjfile.writeline time &vbtab & "Price:" &vbtab & strPriceVal &vbcrlfobjItemMaster.setLeadTime strLeadTimeValobjfile.writeline time &vbtab & "LeadTime Eneterd" &vbcrlfobjfile.writeline time &vbtab & "Lead Time: " &vbtab & strLeadTimeVal &vbcrlfvbWindow("ItemMaster").Type micAltDwn + "v" + micAltUp

Thatavarti’s Training UnitSchool of Software Testing

Page 19: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

vbWindow("ItemMaster").Type micReturnvbWindow("ItemMaster").Type micReturnvbWindow("ItemMaster").Type micF5Reporter.ReportEvent micPass,"Saving the Item Details","Successfully saved the Item

Details"objfile.writeline time &vbtab & "Item Details Saved Successfully" &vbcrlf

Nextobjfile.writeline "------------------------------------------------------------------------------" &vbcrlf'****************************************************************************

**************************************************************' For Closing The Item Master window'****************************************************************************

**************************************************************vbWindow("ItemMaster").Type micF6Reporter.ReportEvent micPass,"Exiting from the Item Master","Successfully Exited from the

Item Master"objfile.writeline time &vbtab & "Item Master Window Closed " &vbcrlf'****************************************************************************

**************************************************************' For Closing Stores Window'****************************************************************************

**************************************************************vbWindow("StoresWindow").Type micF6Reporter.ReportEvent micPass,"Exiting from the Stores Module","Successfully Exited from

the Stores Module"objfile.writeline time &vbtab & "Stores Module Closed " &vbcrlf'****************************************************************************

**************************************************************' For Closing Short Cut Bar'****************************************************************************

**************************************************************VbWindow("frmShortcutBar").ActiveX("Toolbar").VbToolbar("Toolbar").Press 11objfile.writeline time &vbtab & "ShortCut Bar Closed" &vbcrlf'****************************************************************************

**************************************************************' For CleanUp Script'****************************************************************************

********************************************************************objcleanup.cleanallobjfile.writeline time &vbtab & "Objects De-initialized" &vbcrlf

objfile.writeline time &vbtab & "End of Log File" &vbcrlf Set objcleanup = nothing

Set objfile = nothingSet objfso = nothing

Thatavarti’s Training UnitSchool of Software Testing

Page 20: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

Descriptive Programming Example

systemutil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"msgbox Dialog("Title:=Login").Exist(1)msgbox Dialog("Title:=Login").winedit("Title:=Agent Name:").Exist(0)Dialog("Title:=Login").winedit("Title:=Agent Name:").type "fdkj"msgbox Dialog("Title:=Login").winedit("Title:=Password:").Exist(0)Dialog("Title:=Login").winedit("Title:=Agent Name:").type micTabmsgbox Dialog("Title:=Login").winedit("Title:=Password:").Exist(0)Dialog("Title:=Login").winedit("Title:=Password:").type "mercury"msgbox Dialog("Title:=Login").WinButton("Title:=Ok").Exist(0)Dialog("Title:=Login").winedit("Title:=Password:").type micTabmsgbox Dialog("Title:=Login").WinButton("Title:=Ok").Exist(0) Dialog("Title:=Login").WinButton("Title:=Ok").Click

Calling Re-Usable ActionRunAction "Action1 [Login_Reusable_Action]", oneIterationWindow("Flight Reservation").Activate @@ hightlight id_;_4130170_;_script infofile_;_ZIP::ssf1.xml_;_Window("Flight Reservation").ActiveX("MaskEdBox").Click 0,3 @@ hightlight id_;_4327690_;_script infofile_;_ZIP::ssf2.xml_;_Window("Flight Reservation").ActiveX("MaskEdBox").Type "111111" @@ hightlight id_;_4327690_;_script infofile_;_ZIP::ssf3.xml_;_Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt" @@ hightlight id_;_1443352_;_script infofile_;_ZIP::ssf4.xml_;_Window("Flight Reservation").WinComboBox("Fly To:").Select "Denver" @@ hightlight id_;_2688478_;_script infofile_;_ZIP::ssf5.xml_;_Window("Flight Reservation").WinButton("FLIGHT").Click @@ hightlight id_;_1574440_;_script infofile_;_ZIP::ssf6.xml_;_Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "20122 FRA 08:00 AM DEN 08:45 AM SR $163.00" @@ hightlight id_;_1050876_;_script infofile_;_ZIP::ssf7.xml_;_Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click @@ hightlight id_;_6621024_;_script infofile_;_ZIP::ssf8.xml_;_Window("Flight Reservation").WinEdit("Name:").Set "raju" @@ hightlight id_;_5769156_;_script infofile_;_ZIP::ssf9.xml_;_Window("Flight Reservation").WinButton("Insert Order").Click @@ hightlight id_;_5834586_;_script infofile_;_ZIP::ssf10.xml_;_Window("Flight Reservation").Activate @@ hightlight id_;_4130170_;_script infofile_;_ZIP::ssf11.xml_;_Window("Flight Reservation").Close

Thatavarti’s Training UnitSchool of Software Testing

Page 21: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

Copy of Action

RunAction "Copy of Action1", oneIterationWindow("Flight Reservation").Activate @@ hightlight id_;_3409164_;_script infofile_;_ZIP::ssf1.xml_;_Window("Flight Reservation").ActiveX("MaskEdBox").Type "1111111" @@ hightlight id_;_1640756_;_script infofile_;_ZIP::ssf2.xml_;_Window("Flight Reservation").WinComboBox("Fly From:").Select "London" @@ hightlight id_;_4851048_;_script infofile_;_ZIP::ssf3.xml_;_Window("Flight Reservation").WinComboBox("Fly To:").Select "Denver" @@ hightlight id_;_3933662_;_script infofile_;_ZIP::ssf4.xml_;_Window("Flight Reservation").WinButton("FLIGHT").Click @@ hightlight id_;_3999208_;_script infofile_;_ZIP::ssf5.xml_;_Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click @@ hightlight id_;_3344122_;_script infofile_;_ZIP::ssf6.xml_;_Window("Flight Reservation").Activate @@ hightlight id_;_3409164_;_script infofile_;_ZIP::ssf7.xml_;_Window("Flight Reservation").WinEdit("Name:").Set "chandu" @@ hightlight id_;_6358788_;_script infofile_;_ZIP::ssf8.xml_;_Window("Flight Reservation").WinButton("Insert Order").Click @@ hightlight id_;_8652608_;_script infofile_;_ZIP::ssf9.xml_;_Window("Flight Reservation").Activate @@ hightlight id_;_3409164_;_script infofile_;_ZIP::ssf10.xml_;_Window("Flight Reservation").Close

Optional Step

Optional Step Def : If the specified object is not existing it will ignore and forward to the next step.SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"Dialog("Login").WinEdit("Agent Name:").Set "chandu" @@ hightlight id_;_4589556_;_script infofile_;_ZIP::ssf1.xml_;_Dialog("Login").WinEdit("Password:").SetSecure "44c9ad1be59f087ea70d531a3abde65f322da5b3" @@ hightlight id_;_1443596_;_script infofile_;_ZIP::ssf2.xml_;_msgbox " <Ok> Button is optional "wait(5)OptionalStep.Dialog("Login").WinButton("OK").Click @@ hightlight id_;_4982622_;_script infofile_;_ZIP::ssf3.xml_;_'Dialog("Login").WinButton("OK").Click

Thatavarti’s Training UnitSchool of Software Testing

Page 22: Thatavarti QTP Architecture

Thatavarti Technologies Pvt Ltd Independent Testing CompanyConfidential

Excel Interaction

Set obj=createobject("excel.application")do

For i=5 to 7'i=5

systemutil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4b.exe"

obj.workbooks.open"C:\Documents and Settings\Administrator.THATAVARTIHYD\Desktop\Excel_Login.xls"

var1=obj.activesheet.cells(i,1)var2=obj.activesheet.cells(i,2)

Dialog("Login").WinEdit("Agent Name:").Set var1'wait 2

Dialog("Login").WinEdit("Agent Name:").Type micTabDialog("Login").WinEdit("Password:").SetSecure var2

'wait 2Dialog("Login").WinEdit("Password:").Type micReturn

Window("Flight Reservation").Close'i=i+1

If dialog("Login").Dialog("Flight Reservations").Exist Thenrecovery.Activate

End IfNext

loop until obj.activesheet.cells(8,1)="hari"set obj=nothing

********** The End **********

Thatavarti’s Training UnitSchool of Software Testing