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 QTP scenario.
Have you used xml check point in your project?
Does quicktest professional is unicode compatible?
how to make connection to a remote mysql database in qtp any one can please provid eme deatail steps.
for a test in QTP i had choose the object repository as shared.after completion of some days i want to conduct the same test again,now the question is HOW TO LOAD THE OBJECT REPOSITORY. is it possible by descriptive programming.could any one tell me how many ways we load it and what is the process?
How do you perform Regreession Testing?
Which function is used to accesses the Properties from Repository Pls anybody can give the answer.. Thanks in advance...
suppose the given string str = {"vamsikrishna%%&%*&**"} count the no of vowels and special characters are repeated
I have 5 save buttons in 5 tabs . The tabs are placed one after the other. My object repository have these added as 5 save buttons with name sav1, save 2, save 3 , save 4, save 5 .all are getting highlighted from OR but they are not getting clicked. After spying each button all the properties are same except First button Index 0 html id:=btnSaveTab1 outerhtml:=<input id=""btnSaveTab1"" class=""Button"" onclick=""document.getElementById('a1').click();"" name=""btnSaveTab1"" value=""Save"" type=""button"">", Second button "html id:=btnSave "outerhtml:=<input id=""btnSave"" class=""Button"" onclick=""document.getElementById('a2').click();"" value=""Save"" type=""button"">", Third button "html id:=", outerhtml:=<input id=""btnSaveTab1"" class=""Button"" onclick=""document.getElementById('a1').click();"" name=""btnSaveTab Fourth button "html id:=btnSave outerhtml:=<input id=""btnSave"" class=""Button"" onclick=""document.getElementById('a2').click();"" value=""Save"" type=""button"" 5th button "html id:=", "outerhtml:=<input class=""Button"" onclick=""document.getElementById('a5').click();"" value=""Save"" type=""button"">",
what is On Error Resume Next ?
Difference between action & Reusable action?
How do you connect to database ,What is the script to connect DATA BASE?