How do you test a column weather it is sorted asc or desc in QTP ?

Showing Answers 1 - 9 of 9 Answers

ManjuPillae

  • Mar 26th, 2008
 

'Assumption: The column will be sorted either in Ascending or Descending order.

If you have to test the Column whether it is sorted in ascending or in descending order we can take 2 values in the column one from 1st row and other from 2nd row.

Then compare those 2 values, if 1st value is greater than 2nd than it is in Descending else Ascending order.

  Was this answer useful?  Yes

I’m sure there are several ways to get this done, but right now, this one comes to mind:

 

Since you have to compare different values in a column, let column be a constant; that is:

Const colTarget = 1

Now, rows aren’t constant, since you have to browse through rows to find out if the succeeding value is greater than the previous. You can use GetROProperty to get the number of rows at runtime; something like this:

rowTotal = Browser(“”).Page(“”).WebTable(“”).GetROProperty(“rows”)

Now, you can run a “For” loop and skim over all rows:

Sub compData()

For rowStart = 1 to rowTotal

                For rowSecondary = 2 to rowTotal

sDataA = Browser(“”).Page(“”).WebTable(“”).GetCellData(rowStart,colTarget)

                                sDataB = Browser(“”).Page(“”).WebTable(“”).GetCellData(rowSecondary,colTarget)

                                If sDataB > sDataA

                                                Reporter.ReportEvent micPass, “”,””

                                ElseIf sDataB = sDataA

                                                Reporter.ReportEvent micPass, “”,””

                                ElseIf sDataB < sDataA

                                                Reporter.ReportEvent micFail, “”,””

                                Else

                                                Reporter.ReportEvent micWarning, “”,””

                                End If

                                If rowSecondary = rowTotal

                                                Exit Sub

                                End If

                Next

Next

End Sub

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions