Wednesday, 29 January 2014

EVAL Using QTP

EVAL 

The below program is to EVAL values using QTP Tool using VBScript Discriptive Language and Excel File

1.  Create an excel file, in the first column add more than one values in the first column using additions, multiplications, substractions .etc. Example:  6*2
2.  In the second column, input the correct results of the first column Example:  First column 6*2. Second column would be 12. (This is your expected results)

3.  Now compare the actual results in column three with expected results in coloumn two
4. If the results match it must show PASSED else FAILED in fourth column

Option explicit
Dim exo, wbo, wso, nor, i, x, y, z
'open excel file sheet using VBScriptSet exo=createobject("excel.application")
Set wbo=exo.workbooks.open("C:\Documents and Settings\qa\Desktop\QTP Practice\PATH FILES\Excel Evaluations.xls")
Set wso=wbo.worksheets("sheet1")
Nor=wso.usedrange.rows.count
Exo.visible=true
'perform reading and writing from columns using VBScript
For i = 2 to nor step 1
X= wso.cells (i, 1)
Y= wso.cells (i, 2)
Z= eval(x)
Wso.cells (i, 3)=z
    If z=y then
        Wso.cells(i, 4) = "Passed"
   Else
        Wso.cells (i, 4) = "Failed"
   End if
Next
'save excel file and close application

Wbo.save
Exo.quit
Set wso=nothing
Set wbo=nothing
Set exo=nothing

No comments:

Post a Comment