Thursday, 12 November 2015

QTP KeyWord Frame work driver script



'===============================================================
' QTP KeyWord Frame work driver script
'===============================================================
'Project Name :-Esources
'Script Name  :-Key Word Frame Work Driver Script
'Author       :-Sumit Raut
'Created Date :-12 Nov 2015
'--------------------------------------------------------------
'Declearing the variables
Option explicit
Dim fname,intmrc,i,mexe,mmid,inttcrc,j,tcmid,tcexe,tctcid,k,inttsrc,tstcid,kwd,strres,resfilnam
'intmrc=rowcount of modules sheet
'mexe=refers to execution flag of modules sheet
'mmid=module id


'Association of environment file,repository and function library
'Environment.LoadFromFile "E:\nareshuft63\automation\environmnet\pbank.xml"
'RepositoriesCollection.Add Environment.Value("rep")&"pbank.tsr"

RepositoriesCollection.Add "C:\Users\Sunshine\Desktop\UFT Again\OR\estotoal.tsr"
'ExecuteFile Environment.Value "C:\Users\Sunshine\Desktop\UFT Again"

ExecuteFile "C:\Users\Sunshine\Desktop\UFT Again\esources.qfl"

'Adding the new sheets to datatable
DataTable.AddSheet("dtmodules")
DataTable.AddSheet ("dttestcases")
DataTable.AddSheet ("dtteststeps")

'Deleting the default sheets of datatable
DataTable.DeleteSheet ("Global")
DataTable.DeleteSheet("Action1")

'Importing the excel sheets data into datatable sheets
fname="C:\Users\Sunshine\Desktop\UFT Again\keyword.xls"
'C:\Users\Sunshine\Desktop\UFT Again\keyword.xls
DataTable.ImportSheet fname,"modules","dtmodules"
DataTable.ImportSheet fname,"testcases","dttestcases"
DataTable.ImportSheet fname,"teststeps","dtteststeps"

'Working with dtmodules sheet of datatable
intmrc=DataTable.GetSheet("dtmodules").GetRowCount
MsgBox "m rowcount="&intmrc
For i = 1 To intmrc Step 1
DataTable.GetSheet("dtmodules").SetCurrentRow (i)
    mexe=DataTable.Value("execution","dtmodules")
    If ucase(trim(cstr(mexe)))="Y" Then
    mmid=DataTable.Value("moduleid","dtmodules")
    MsgBox "module id="&mmid
  
'Working with dttestcases sheet of datatable
    inttcrc=DataTable.GetSheet("dttestcases").GetRowCount
    MsgBox "tc rowcount="&inttcrc
    For j = 1 To inttcrc Step 1
        DataTable.GetSheet("dttestcases").SetCurrentRow (j)
        tcmid=DataTable.Value("moduleid","dttestcases")
        tcexe=DataTable.Value("execution","dttestcases")
        If (trim(cstr(tcmid)))=(trim(cstr(mmid))) and (ucase(trim(cstr(tcexe))))="Y" Then
        tctcid=DataTable.Value("testcaseid","dttestcases")
        MsgBox "tc tcid="&tctcid
          
'Working with dtteststeps sheet of datatable
inttsrc=DataTable.GetSheet("dtteststeps").GetRowCount
MsgBox "ts rowcount="&inttsrc
For k = 1 To inttsrc Step 1
    DataTable.GetSheet("dtteststeps").SetCurrentRow(k)
    tstcid=DataTable.Value("testcaseid","dtteststeps")
    If trim(cstr(tstcid))=trim(cstr(tctcid)) Then
        kwd=DataTable.Value("keyword","dtteststeps")
        MsgBox "Keyword="&kwd
      
'Introducing the select case conditional statement
Select Case kwd
    Case "apl"
    'strres=fnAppLaunch(strurl)
    strres=fnAppLaunch("http://www.esources.co.uk/")
  
    Case "algn"
    'strres=fnAppLogin(strun,strpwd)
    strres=fnAppLogin("estesting2015","testing")  
  
  
    Case "algt"
    strres=fnAppLogout()
  
    Case "apc"
    strres=fnAppClose()
End Select

'Updating the results into the teststeps and testcase sheets of datatable
DataTable.Value("status","dtteststeps")=strres
If DataTable.Value("status","dttestcases")<>"fail" Then
   DataTable.Value("status","dttestcases")=strres
   else
   DataTable.Value("status","dttestcases")="fail"
End If
    End If
Next
else
DataTable.Value("status","dttestcases")="blocked"
        End If
    Next
      
    End If
Next

'Exporting the results of datatable into excel file 
resfilnam=replace(replace(replace(now,"/",""),":","")," ","")
'DataTable.Export Environment.Value("res"filnam&")&reskwdfw.xls"
DataTable.Export "C:\Users\Sunshine\Desktop\UFT Again\keywordresult.xls"




Spring Boot : Exception Handler 14