SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Dec 2007
    Posts
    88
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Checking if the column is sorted

    Dim CurrentRow, RowCount
    RowCount = DataTable.GetSheet("Global").GetRowCount
    For CurrentRow = 1 to RowCount
    DataTable.GlobalSheet.SetCurrentRow(CurrentRow)
    Browser("SERVICE REQUEST").Page("SERVICE REQUEST").Link("name:=.* " & DataTable.Value("A", dtGlobalSheet)).Click
    Dim objTable
    Dim intCol1, intCol2
    Dim intRow, intFirstDataRow, intRowCount
    Dim arrCol1(), arrSorted
    Set objTable = Browser("dev").Page("dev_2").WebTable("INSTANCE")
    intRowCount = objTable.RowCount
    intFirstDataRow = 2
    intCol1 = 1
    intCol2 = 2


    For intRow = intFirstDataRow to intRowCount
    ReDim Preserve arrCol1(intRow-2)
    arrCol1(intRow-2) = objTable.GetCellData(intRow, intCol1)

    Next


    arrSorted = arrCol1
    insertionSort(arrSorted)


    If (ArraysAreEqual(arrCol1, arrSorted) = True) Then
    Reporter.ReportEvent micPass, "Column1", "Sorted"
    Else
    Reporter.ReportEvent micPass, "Column1", "Unsorted"
    End If

    Next



    Browser("SERVICE REQUEST").Page("SERVICE REQUEST").Sync
    Browser("SERVICE REQUEST").Close


    '================================================= ====================================
    Function insertionSort( ByRef arr() )
    Dim arr_size, i , j, index
    arr_size = UBound( arr ) + 1
    For i = 1 To arr_size - 1
    index = arr( i )
    j =i
    Do while j >0
    If arr(j-1) > index Then
    arr(j) = arr(j-1)
    j =j -1
    End If
    Loop
    arr(j) = index
    Next
    End Function

    Public Function ArraysAreEqual(ByVal arr1, ByVal arr2)
    If(Join(arr1, ";") = Join(arr2, ";")) Then
    ArraysAreEqual = True
    Else
    ArraysAreEqual = False
    End If
    End Function


    I am actually trying to check if the first column is sorted or not. But when I run this code in QTP. Just keeps running forever. Am i doing something wrong?

  2. #2
    Moderator
    Join Date
    Jan 2007
    Location
    Pittsburgh, PA
    Posts
    2,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Checking if the column is sorted

    Check this thread for sorting an array help.

  3. #3
    Member
    Join Date
    Dec 2007
    Posts
    88
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Checking if the column is sorted

    When I check for the columns with with alphas even though not sorted it gives as sorted. Please advise. Is there something wrong with the function whether I am checking whether the arrays are equal. I used the sorting technique from the given thread. I did something like this

    arrSorted = Sort_ListItems(arrSorted)



    If (ArraysAreEqual(arrCol1, arrSorted) = True) Then
    Reporter.ReportEvent micPass, "Column1", "Sorted"
    Else
    Reporter.ReportEvent micFail, "Column1", "Unsorted"
    End If

  4. #4
    Member
    Join Date
    Dec 2007
    Posts
    88
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Checking if the column is sorted

    Actually works fine. Thanks a bunch. Sorry about the earlier post.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 01:36 AM.

Copyright BetaSoft Inc.