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



HI, Based On The Information Below Write A Data Driven test Script Edit Box 1 Should take Val..

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

HI, Based On The Information Below Write A Data Driven test Script Edit Box 1 Should take Val..

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

HI, Based On The Information Below Write A Data Driven test Script Edit Box 1 Should take Val..

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

HI, Based On The Information Below Write A Data Driven test Script Edit Box 1 Should take Val..

Answer / kavi

Hi Nath,

its really nice.

thanks a lot.

kavi..

Is This Answer Correct ?    0 Yes 0 No

HI, Based On The Information Below Write A Data Driven test Script Edit Box 1 Should take Val..

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

Post New Answer

More QTP Interview Questions

I want to test advanced Java applications what kind of add- ins I have to install?

1 Answers  


Explain the concept of how QTP identifies object.

5 Answers   Ordain Solutions,


how to capture the run time values of web table.

3 Answers   CTS,


How to handle the exceptions using recovery secnario manager in quicktest professional?

0 Answers  


How do know the number of browsers opened?

0 Answers  


In my application there is a billing thru credit card. how to validate the credit card details(min balance,credit card no,card holder name).if these details are valid then only that booking will be done.how to validate these details thru automation or manual?

1 Answers  


I install .Net Add-Ins in my system. It installed properly. But all the objects are recognizing as window objects only. But it has to recognize as swf objects. In Record and Run setting i selected 'Record and run test on any open browser' and Record and run test on any open Windows-based application' Can any one tell what setting i have to do to recognize objects correctly as swf...? Please give some suggestions..?

1 Answers  


How to write test cases for web applications using QTP.plz write a sample test case to show how to write.urgently needed.thanks in advance..

4 Answers   IBM,


Hi, i am rani ,i am putting 1+years of fake exp ,so pls anyone explain how i get project (in real time) ? how it is tested ex: in banking ,test the number of textboxes in one window

3 Answers  


what is the extension for the test version of the script?

5 Answers   TCS,


object types is used for what?

1 Answers  


Explain the Keyword View ?

2 Answers   Crea,


Categories