Validation of Sorting a Web-table

1,770 views
Skip to first unread message

lokesh vinu

unread,
Jun 22, 2011, 6:35:34 AM6/22/11
to mercu...@googlegroups.com
Hi All,

I'm trying to validate the sorting order of in webtable.I need to verify the column, is sorted in descending order.
Have anyone faced similar kind of scenario. Please let me know how to work on this.
Note: The columns fields are DATE
Thanks in advance.

Lokesh K

jaimin

unread,
Jun 22, 2011, 7:53:48 AM6/22/11
to QTP - HP Quick Test Professional - Automated Software Testing

1. Click on Date column which sort the date in ascending order.
2. Get first row and second row date value form Date column
3. Check first row date should be less than or equal to second row
date.
4. Get second row and third row date value.
5. Check second row date should be less than or equal to third row
date value.
6. Same way check untill end of row using For Loop.
7. In the case if you got false result while comparison two row you
need to break the for loop and show the fail result......


For i =1 to TableRowcount -1
GET CurrRow = TableObject.GetcellData(i,<Column>)
GET NextRow = = TableObject.GetcellData(i+1,<Column>)
If cstr(sCompareVal) > cstr(sNextCompareVal) Then
sFlage = 1
Exit For
End If

End


Thanks & Regards,
Jaimin Shah.

jaimin

unread,
Jun 22, 2011, 8:02:50 AM6/22/11
to QTP - HP Quick Test Professional - Automated Software Testing
Updated code..

For i =1 to TableRowcount -1
dtmCurrRow = TableObject.GetcellData(i,<Column>)
dtmNextRow = = TableObject.GetcellData(i+1,<Column>)
If NOT cdate(dtmCurrRow) <= cdate(dtmNextRow) Then
Flage = 1
Exit For
End If
End

If Flage <> 1 than
Result Pass
Else
Result Fail
End if

Let me know if you have query..

Thanks

lokesh vinu

unread,
Jun 23, 2011, 12:08:40 AM6/23/11
to mercu...@googlegroups.com
Hi Jaimin,

Thanks for your reply.

When I try running your code I'm getting type mismatch error in the line ( If  NOT cdate(dtmCurrRow) <=  cdate(dtmNextRow) Then)
any suggestion how to overcome this.

Lokesh

--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

lokesh vinu

unread,
Jun 27, 2011, 1:00:38 AM6/27/11
to mercu...@googlegroups.com

Hi All,

I need to validate the sorting order  of these day. which is in a Webtable I tried using for loop as mentioned below but it doesnt workout, Please provide any solution for the same.

rc = Browser("").Page("").WebTable("").GetROProperty("rows")

    For rowFirst= 1 to rc
        For rowSecond = 2 to rc
            ADate =  Browser("").Page("").WebTable("").GetCellData(rowFirst,colno)
            BDate =  Browser("").Page("").WebTable("").GetCellData(rowSecond,colno)

        If ADate < BDate then
              Reporter.ReportEvent micPass, "Validation","The dates are sorted correctly"
          ElseIf BDate = ADate then
                 Reporter.ReportEvent micPass, "Validation","The dates are sorted correctly"
          ElseIf BDate > ADate then
                Reporter.ReportEvent micFail,"Validation","The dates are NOT sorted correctly"
            Else
                Reporter.ReportEvent micWarning, "Validation","The dates are NOT sorted correctly"
            End If
            If rowSecond = rc then
                Exit For
            End If
        Next
    Next




Thanks! in Advance for the help.

Lokesh K
Dates.png

Sreedhar

unread,
Jun 27, 2011, 8:19:52 AM6/27/11
to mercu...@googlegroups.com

Try using the .net code for this..which is a easy way…but .net framework needs to be installed on your PC to run the below code

 

Set ObjDate = CreateObject("System.Collections.ArrayList")

 

'add getcelldata to this object

ObjDate.Add output

ObjDate.Add output

 

ObjDate.Sort() ' after sorting compare both the lists...

 

Set ObjDate = Nothing

 

Sreedhar Mallipeddi

Audubon Village,

5830 Memorial Highway,

Tampa, FL - 33615

Mobile: 813-334-0327

Home: 214-257-0599


No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1388 / Virus Database: 1513/3728 - Release Date: 06/26/11

jaimin

unread,
Jun 27, 2011, 8:27:53 AM6/27/11
to QTP - HP Quick Test Professional - Automated Software Testing
Hi Lokesh,

First verify that weather your code get row cell data. ?
You can use print or msgbox keyword to verify..

Code should look like below.. I have used one for loop instead of
two..

rc = Browser("").Page("").WebTable("").GetROProperty("rows")

For rowFirst= 1 to rc-1
ADate =
trim(Browser("").Page("").WebTable("").GetCellData(rowFirst,colno))
BDate =
trim(Browser("").Page("").WebTable("").GetCellData(rowFirst+1,colno))

If Not cdate(ADate) <= cdate(BDate) then
Flag = 1
Exit For
End If
Next

if Flag = 1 then
result fail
else
result pass
end if

Thanks & Regards,
Jaimin Shah


On Jun 27, 10:00 am, lokesh vinu <lokesh.v...@gmail.com> wrote:
> Hi All,
>
> Thanks! in Advance for the help.
>
> Lokesh K
>
>
>
>
>
>
>
> On Thu, Jun 23, 2011 at 9:38 AM, lokesh vinu <lokesh.v...@gmail.com> wrote:
> > Hi Jaimin,
>
> > Thanks for your reply.
>
> > When I try running your code I'm getting type mismatch error in the line (
> > If  NOT cdate(dtmCurrRow) <=  cdate(dtmNextRow) Then)
> > any suggestion how to overcome this.
>
> > Lokesh
>
>  Dates.png
> 5KViewDownload
Reply all
Reply to author
Forward
0 new messages