QTP Driver Script

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



Driver script is mainly useful to organize the Tests Execution 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
SHARE

About அமரகோசம்

    Blogger Comment
    Facebook Comment

1 comments:

  1. Your site is soo helpful.
    Could you please leave comments what each step does? it will be more helpful.

    ReplyDelete