Professional Documents
Culture Documents
In Key Work Driven Framework the script values will be written in Excel files and QTP will
execute them using Driver Script. Now this will explain how to execute the script which is specified in
Excel Files.
There are majorly two approaches followed to make Keyword Driven Framework.
Approach 1:
Object Class : - Class of the object on which we are going to perform the operation
Please remember that there is no method is available called “SetParent” in QTP. But I am using
this word as a condition to set the parent of the object. I have delimited the Parent Object using “/” and
respectively I have used it for properties.
We can specify properties directly in place of constants. But when you get a failure in the script,
you might not able to identify where exactly the error occurs.
For example, in the above table if the Web Edit step is failed then how do we figure out the failure for
which object in the application by just using “name:=q” property. If we have assigned those properties
to a constant which is having an understandable name then it will be very easy to identify for which
object the failure occurs.
So now we have Excel Keywords and Object Description Constants. We have to write driver script.
In this folder create 3 subfolders with the names “Scripts”, “Constants”,”KeyWords” and
Prepare an excel like how it is available in above table Save the Excel file in the
“C:\KeyWordDrivenSample\KeyWords” folder with the name “ScriptKeywords.xls”
Copy above Object Description Constants in a VBS File and save it in the
“C:\KeyWordDrivenSample\Coanstants” with the name “OR Constants.vbs”
Open a new test in QTP and Save the test in “C:\KeyWordDrivenSample\Scripts” Folder with the name
“Driver Script”
Now you should have the Folder structure like specified below
Now you can save the below script in Driver Script and Run it.
'###################################################################
' Objective : This is a driver script for Sample Keyword Driven Framework
'Updated by :
'###################################################################
dtKeyWords=DataTable.AddSheet("Keywords")
Datatable.ImportSheet "..\..\Keywords\ScriptKeywords.xls","Sheet1","Keywords"
dtRowCount=dtKeyWords.GetRowCountdtColumnCount=dtKeyWords.GetParameterCount
dtKeyWords.SetCurrentRow (dtRow)
strObjClass = DataTable("ObjectClass","Keywords")
strObjProperties = DataTable("ObjectProperties","Keywords")
strOperation = DataTable("Operation","Keywords")
strValue = DataTable("Value","Keywords")
If strOperation="SetParent" Then
oParentObjectArray=Split(strObjClass,"/")
oParentObjectPropArray=Split(strObjProperties,"/")
iParent=oParentObjectArray(iParentCount)
iParentProps=oParentObjectPropArray(iParentCount)
If iParentCount=ubound(oParentObjectArray) Then
strParent=strParent&iParent&"("&""""&eval(iParentProps)&""""&")"
Exit For
End If
strParent=strParent&iParent&"("&""""&eval(iParentProps)&""""&")."
Next
ParentObject=strParent
Else
If strValue<>"" Then
iStrInputDataArray=split(strValue,",")
If iInputValuesCount=UBound(iStrInputDataArray) Then
Next
End If
Execute (oStatement)
End If
Next
------------------------------------------------------------