Driver Script

 Driver Script
Generally in Keyword Driven Framework Driver Script is the only QTP Script, remaining all are Vb Script files (.vbs) 
Driver script organizes Tests execution and stores Test logs in the specified file/folder

Sample Driver Script
'adding sheets to runtime data table
datatable.AddSheet ("Module")
datatable.AddSheet ("Testcase")
datatable.AddSheet ("Teststep")

'Importing sheets from an external excel file
datatable.ImportSheet "C:\Documents and Settings\gcreddy\Desktop\flights\test data\inputdata.xls",1,"Module"
datatable.ImportSheet "C:\Documents and Settings\gcreddy\Desktop\flights\test data\inputdata.xls",2,"Testcase"
datatable.ImportSheet "C:\Documents and Settings\gcreddy\Desktop\flights\test data\inputdata.xls",3,"Teststep"

Mrowcount=datatable.GetSheet("Module").getrowcount
For i=1 to Mrowcount step 1
    datatable.SetCurrentRow(i)
    Mexe=datatable.Value(3,"Module")
    If ucase(Mexe)="Y"  Then
        ModuleId= datatable.Value (1,"Module")

        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 "C:\Documents and Settings\gcreddy\Desktop\flights\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 "C:\Flight\Testscripts\Driver"
qtApp.Test.Run
qtApp.Quit

5 comments:

Thanks a lot. Your blog is helping me a lot to learn QTP

Thank you Mr Reddy. Your blog is very good for the beginners.

You r explaining each and every point clearly....ofcourse slowly but the way u r explaining is very good

the blog is very helpful..thanks a lot Mr. Reddy.

Hi Reddy
i did the same function like the one that you have for triggering qtp but i want to run multpile test. The function execute right but it fails to read/call the second script. Check below::

strBatchPath="Q:\Test Batch Runner\Final Format\CRM Regression Pack.xls"
strCalculateNoOfRows = ColumArray(strBatchPath,"Scripts Path")
TotalNumberofRowsInArray=ubound(strCalculateNoOfRows)

For i=0 To TotalNumberofRowsInArray
Set app = CreateObject("QuickTest.Application")
app.Launch
app.Visible = True
app.WindowState = "Maximized"
app.ActivateView "ExpertView"
app.Open strCalculateNoOfRows(i),True
'Opens the test in editable mode
app.test.Run , True
app.test.Close
app.Quit

Next

Post a Comment