In a Web appl, on a page, there are student names & details
listed.On clicking sort button,details are sorted on
Names.How do u verify htat sorting is done by using QTP?

Answer Posted / ankur_jain

you can use this function for comparing the values and if
your records are shown in webtable then you can use code
like this
in blank spaces between " " you have to pass your own
names
set hp=browser(" ").page(" ")
rc=browser(" ").page(" ").webtable(" ").rowcount
For i=2 to rc step 1
If i=rc Then
sone=hp.webtable(" ").getcelldata(i,1)
stwo=hp.webtable("html id:=dgList").getcelldata(i,1)
end if
sone=hp.webtable(" ").getcelldata(i,1)
stwo=hp.webtable(" ").getcelldata(i+1,1)
ret= CompareValues(sone, stwo)
'then on the basis of ret value you can verify that
list is sorted or not

'Using this function you can compare two values.
'Return values are based on three data types -Date,Numeric
or Text
'Return 1 if value1>value2 OR -1 if value1<value2, 0 if
value1=value2

Function CompareValues(sOne, sTwo) '--- as variant
On Error Resume Next

Dim im1,im2, iRtrn

if (isNumeric(Trim(sOne)) AND isNumeric(Trim(sTwo)))
then
im1 = CDbl(Trim(sOne))
im2 = CDbl(Trim(sTwo))
else
if (isDate(Trim(sOne)) AND isDate(Trim(sTwo))) then
im1 = CDate(Trim(sOne))
im2 = CDate(Trim(sTwo))
else
im1 = Trim(CSTR(sOne))
im2 = Trim(CSTR(sTwo))
end if
end if

iRtrn=0
If im1 < im2 then
iRtrn = -1
else
if im1 > im2 then
iRtrn = 1
end if
end if
CompareValues = iRtrn

If Err.Number > 0 then
strErrorMsg = "Error occured in function
CompareValues "
strErrorMsg = strErrorMsg & "Parameter
values passed to the function are: - ( " & sOne & ", " &
sTwo & ")"
Call ErrorHandler(strErrorMsg)
End If

End Function

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Dear sir, i want to perform a QTP automated testing for mechancial engineering software like msc adams, msc nastran this softwares will help for mechanical engineering design analysis>> i know oad runner win runner, test director, QTp>> but i dont know how to use for automation

1692


What is the use of ordinal identifier in qtp?

677


The hybrid framework can be implemented for any application. Is it true?

667


Can QTP be used for GUI testing ?, We are using Java with MySQL and Operating system is Linux. We are NOT using the web.

2015


what is description object?

1698






How the smart identification is used in real time?Please explain with an example

1642


Explain the terms test and business component?

625


Hi All, How to get repeated word in string . Thanks Balaji

1014


How is UFT 11.5 version different from UFT 12.0?

693


What is the syntax to call one script from another?

629


how will load the object during runtime?

1672


How many ways we can parameterize data in quicktest professional?

653


Explain runtime dynamic settings?

2111


what testplan contents and what test strategy contents,what is the diff b/w them

1734


How to define array in qtp?

660