Tuesday, 3 December 2013

QTP Driver Script

Actually we are using VBScript in most of the areas in QTP. But the Driver Script is the only QTP script, remaino all are VBscript files(.VBS).

Driver script is mainly useful to organize the Tests Exection and stores Test Logs in the specified file/folder.

Example:

adding sheets to runtime data table
datatable.AddSheet ("Module")
datatable.AddSheet ("Testcase")
datatable.AddSheet ("Teststep")

'Adding data sheets to runtime data table

Tcrowcount=datatable.GetSheet ("Testcase").getrowcount
        For j=1 to Tcrowcount step 1
           datatable.SetCurrentRow (j)
           moduleid1=datatable.Value(4,"Testcase")
           tcexe=datatable.Value(3,"Testcase")
           If moduleid=moduleid1 and Ucase(tcexe)="Y" Then
               TcId=datatable.Value(1,"Testcase")
               Tsrowcount=datatable.GetSheet("Teststep").getrowcount
               For k= 1 to Tsrowcount step 1
               datatable.SetCurrentRow(k)
               Tcid1=Datatable.Value(5,"Teststep")
                   If TcId= TcId1 Then
                       keyword= datatable.Value(3,"Teststep")
                       Select Case keyword
                       Case "ln"
                       res=Login()
                       datatable.Value(6,"Teststep")=res
                       Case "ca"
                           close_app
                       Case "op"
                           res=Openord()
                           datatable.Value(6,"Teststep")=res
                 
                        End Select
                    End If
                Next
            End If
        Next
    End If
Next
datatable.ExportSheet "D:\Automation\Testlog\results.xls","Teststep"

Sample Initialization Script:

Initialization Script launches QTP Tool and Calls Driver Script, Driver Script execute Tests and Stores Results.
Finally   Initialization Script Closes QTP tool

Option Explicit
Dim qtApp
set qtApp=createobject("QuickTest.Application")
qtApp.Launch
qtApp.Visible=True
qtApp.Open "D:\Automation\Testscripts\Driver"
qtApp.Test.Run
qtApp.Quit

3 comments:

  1. Thanks for your information. QTP provide most precise and independent review about a software application. This automation testing tool is ideal to determine the performance and validity of a software application.Best QTP Training in Chennai | Loadrunner course in Chennai

    ReplyDelete
  2. Thanks for your informative article on software testing. Your post helped me to understand the future and career prospects in software testing. Keep on updating your blog with such awesome articleSoftware testing training|Software training

    ReplyDelete