HI,
Based On The Information Below Write A Data Driven test
Script
Edit Box 1 Should take Value From Num1 Column
Edit Box 2 Should take Value From Num2 Column
Click On Add Button,
Get The Value Of Exp res Column,
Get Value From Actual Result Edit Box ,
Compare Two Values, Write Pass / Fail Value Into Result
Column
Thanks In Advance... Kavitha
Input.Xls
Num1 Num2 Exp res Act res Result
10 30 40 40 Pass
50 40 90 90.5 -
- - - - -
- - - - -
- - - - -
Answers were Sorted based on User's Feedback
Answer / saravanaraja
Here A = First Input; B= second Input ; C= Expected Result
D= Actual Result; E= Status
Set ex=createobject("Excel.Application")
Set a=ex.workbooks.open("C:\Documents and
Settings\Administrator\Desktop\cms_code.xls")
Set b=a.worksheets("sheet2")
For i=1 to 13
f=b.cells(i,"A").Value
g=b.cells(i,"B").Value
h=f+g
b.cells(i,"D").Value=h
If b.cells(i,"C").Value= b.cells(i,"D").Value Then
b.cells(i,"E").Value ="Pass"
Else
b.cells(i,"E").Value ="Fail"
End If
Next
a.save
a.close
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / sonia
Set oexObj = CreateObject("Excel.Application")
Set oWb = oexObj.workbooks.open("c:\Input.xls")
Set sheet=oWb.worksheets(1)
row=sheet.usedrange.rows.count
col=sheet.usedrange.columns.count
For i=2 to row step 1
col1=0
For j=1 to col-3 step 1
colvalue = sheet.cells(i,j)
col1= col1+CInt(colvalue)
Next
col1=sheet.cells(i,4)
If CInt(col1) = CInt(sheet.cells(i,3)) Then
sheet.cells(i,5)="Pass"
Reporter.ReportEvent micPass, "Complate", "Expected Result"
&CInt(col1) &vbcrlf&" Actual Result."&vbcrlf& CInt(col1) =
CInt(sheet.cells(i,3))
else
sheet.cells(i,5)="Fail"
End If
Next
oWb.save
oexObj.quit
Set oWb=nothing
Set oexObj=nothing
Use this code it work very fine.
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / nath .t
this example add the first two columns(Example Num1 and
Num2), added value stored in Act res column and take the
Exp res value, compare the two values and put result in
result column as pass or fail.
before execution:
example: Input.Xls
Num1 Num2 Exp res Act res Result
10 30 40 - -
50 40 90 - -
- - - - -
- - - - -
- - - - -
Set oExObj = createobject("Excel.Application")
Set oWb = oExObj.workbooks.open("C:\input.xls")
Set sheet = oWb.worksheets(1)
row = sheet.usedrange.rows.count
col = sheet.usedrange.columns.count
For i = 2 to row step 1
col1 = 0
For j = 1 to col-3 step 1
colvalue = sheet.cells(i, j)
col1 = col1 + cint(colvalue)
Next
sheet.cells(i,4)=col1
If cint(col1) = cint(sheet.cells(i, 3)) Then
sheet.cells(i, 5) = "Pass"
else
sheet.cells(i, 5) = "Fail"
End If
Next
oWb.save
oExObj.quit
Set oWb = nothing
Set oExObj = nothing
after execution:Input.Xls
Num1 Num2 Exp res Act res Result
10 30 40 40 Pass
50 40 100 90 Fail
- - - - -
- - - - -
- - - - -
Kavitha can modify above code as per criteria this is very
helpful for ur scenario.
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / pradeep
DataTable.importSheet"C:\Test.xls"
DataTable.getsheet"Practice"
rowCount=DataTable.getSheet"Practice".Getrowcount
set xls=CreatObject("Excel.application")
set Xbook=xls.Wbook.open("C:\Test.xls")
set Sheet=Xbook.OpenSheet("Practice")
For i=0 to rowCount
'Assigen the values to local variables.
Num1=Trim(cint(DataTable("Input1")))
Num2=Trim(Cint(DataTabel(Input2")))
expNumber=Trim(Cint(DataTable("expResult")
set these values into corresponding edit boxes
and click the button ok
Retrive value form the result box by it property value
called text using GetROProperty method.
Comparison done by following and store into variable called
actualResult
if(expNumber==actualResult)
sheet.cell(i,3)="Pass"
Else
Sheet.cell(i,3)="Failed"
Next
Is This Answer Correct ? | 0 Yes | 0 No |
what is use of optionexplicit in variable declaration
How did u write macros?What is the main importance of VB macros in testing environment?
Plz explain about Virtual object? What is the situation u r using , explain with example?
What ate the Technologies supported by QTP?
i am new QTP... please tell me automation frameworks , types & for whiich type of applications frameworks are used & how to generate script in keyword driven framework
Tell me about userdefined functions ?
I have 3 browsers i want to give facebook url in 2 nd browser using qtp
We have an action attached with the library file in QTP. When I will click on run button,which file is going to be executed first a)Action b)Library
How to record right click of a context menu and click on the selection ?
What is diff. between ordinal identifier INDEX and Location?
Hi, I am new to QTP testing and was exploring the frameworks used for automation. I wanted help in writing various scripts and files for keyword driven automation like 1. Control File 2. Test Case File 3. Startup Script 4. Driver Script 5. Utility Script . etc It would be great if someone can give help in this context ... Thanks
How can i store runtime value through vb script while using qtp