Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Comparision Of whole 1 webtable to another
#4
Not Solved
Anand:

I am including two subs which will find all cells that are different between the two web tables. I have hard coded the number of rows and columns. You will need to modify those values.

Both programs will print which rows and cells are different.

Method 1 using the standard OR technique. Method 2 uses the DOM technique. The article that caused me to work with DOM is http://qtpprashanth.blogspot.com/2011/03...h-qtp.html.

In my experiments the web tables had 20 rows and 6 columns. The OR technique took around 100 sec while the DOM method took around 5 sec.

hth,

Parke

Code:
Sub Compares_rows_of_two_web_tables
    startTime = timer
    Dim table1_arr(21)
    str = ""
    For nrow = 1 to 21
        For ncol = 1 to 6
            str = str & ";:" & Browser("Browser").Page("Page").Frame("frSheet").WebTable("1").GetCellData(nrow,ncol)
        Next
        table1_arr(nrow) = str
        str = ""
    Next
    
    'For i = lbound(table1_arr) to ubound(table1_arr)
    '    print "row " & i  & " is " & table1_arr(i)
    'Next
    
    Dim table2_arr(21)
    str = ""
    For nrow = 1 to 21
        For ncol = 1 to 6
            str = str & ";:" & Browser("Browser_2").Page("Page").Frame("frSheet").WebTable("1").GetCellData(nrow,ncol)
        Next
        table2_arr(nrow) = str
        str = ""
    Next
    
    'For i = lbound(table2_arr) to ubound(table2_arr)
    '    print "row " & i  & " is " & table2_arr(i)
    'Next
    
    For rowNum = 1 to UBound(table1_arr)
        If table1_arr(rowNum) <> table2_arr(rowNum) Then
            print "row " & rowNum & " are not the same"
        End If
    Next
    
    For rowNum = 0 to UBound(table1_arr)
        If table1_arr(rowNum) <> table2_arr(rowNum) Then
            print "row " & rowNum + 1 & " are not the same"
            tabl1_row_arr = split(table1_arr(rowNum),";:")
            tabl2_row_arr = split(table2_arr(rowNum),";:")
            For k = LBound(tabl1_row_arr) to UBound(tabl1_row_arr)
                If tabl1_row_arr(k) <> tabl2_row_arr(k) Then
                    print "for row, " & rowNum & ", cell " & k & " are not the same in the two tables."
                end If
            Next
        End If
    Next
    
    endtime = timer
    runTime = endTime - startTime
    print "runTime = " & runTime

End Sub    ''// Compares_rows_of_two_web_tables
Code:
Sub Compares_rows_of_two_web_tables_DOM_2
    
    Set oTable = Browser("Browser").Page("Page").Frame("frSheet").WebTable("1")
    'innertext =  oTable.Object.rows(3).cells(2).innertext
    'print innertext
    
    Dim table1_arr(20)
    str = ""
    For nrow = 0 To 20    
        For ncol = 0 to 5
            str = str & ";:" & oTable.Object.rows(nrow).cells(ncol).innertext
        Next
        startTime = timer
        table1_arr(nrow) = str
        str = ""
    Next
    
    Set oTable2 = Browser("Browser_2").Page("Page").Frame("frSheet").WebTable("1")
    'innertext =  oTable2.Object.rows(3).cells(5).innertext
    'print innertext
    
    Dim table2_arr(20)
    str = ""
    For nrow = 0 To 20    
        For n = 0 to 5
            str = str & ";:" & oTable2.Object.rows(nrow).cells(CInt(n)).innertext
        Next
        table2_arr(nrow) = str
        str = ""
    Next
    
    For rowNum = 0 to UBound(table1_arr)
        If table1_arr(rowNum) <> table2_arr(rowNum) Then
            print "row " & rowNum + 1 & " are not the same"
        End If
    Next
    
    'endtime = timer
    'runTime = endTime - startTime
    'print "runTime = " & runTime
    
    For rowNum = 0 to UBound(table1_arr)
        If table1_arr(rowNum) <> table2_arr(rowNum) Then
            print "row " & rowNum + 1 & " are not the same"
            tabl1_row_arr = split(table1_arr(rowNum),";:")
            tabl2_row_arr = split(table2_arr(rowNum),";:")
            For k = LBound(tabl1_row_arr) to UBound(tabl1_row_arr)
                If tabl1_row_arr(k) <> tabl2_row_arr(k) Then
                    print "for row, " & rowNum + 1 & ", cell " & k & " are not the same in the two tables."            
                End If
            Next
        End If
    Next
    
    endtime = timer
    runTime = endTime - startTime
    print "runTime = " & runTime

End Sub  ''// Compares_rows_of_two_web_tables_DOM_2
Reply


Messages In This Thread
RE: Comparision Of whole 1 webtable to another - by Parke - 10-10-2013, 07:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Genaralised code for checking the comparision of two xml files having child nodes. Ganta 4 3,834 11-18-2009, 07:26 PM
Last Post: Ganta

Forum Jump:


Users browsing this thread: 1 Guest(s)