OK. I ran a sample and have some benchmarks for a simple table look up In the sample below I have a simple table with 30 row of 8 columns. The test measure the time to find the matching row (the sample is row 30) There are two methods. One uses if comparisons of the tables columns within the row. The second method intersects the data to find with an array of each row. The time was quite dramatic.
Using the If statements the time was about 25 seconds to find matching table row 30 Using the intersect method for arrray comparisons the table match was immediate (zero seconds) Script Code =============================================== require 'rubygems' require 'watir-webdriver' #require 'win32ole' require 'uri' require 'date' def Method_OpenBrowser(sURL,sBrowserType) puts '* Method_OpenBrowser' puts ' - Browser type: ' + sBrowserType.to_s puts ' - URL: ' + sURL.to_s ie=0 ie = Watir::Browser.new(sBrowserType) ie.window.maximize() ie.goto(sURL) sleep 2 puts ' - Return ' + ie.to_s return ie end # -------------------------------------------------------------------- # Hash values are fetched and compared using ifs with each row column # A complete match outputs the time delta # -------------------------------------------------------------------- def Method_CheckTableUsingIfs(ie,myHash) puts '* Method_CheckTableUsingIfs' puts ' - # of Column values to match: ' + myHash.length().to_s obj = ie.table(:id,'table1').tbody(:id,'tbody1') iDataRows = obj.rows.length() - 1 iRowIndex = 1 startTime = Time.now iDataRows.times do if myHash.fetch('col1') == obj.tr(:index => iRowIndex).td(:index => 0).text.to_s then if myHash.fetch('col2') == obj.tr(:index => iRowIndex).td(:index => 1).text.to_s then if myHash.fetch('col3') == obj.tr(:index => iRowIndex).td(:index => 2).text.to_s then if myHash.fetch('col4') == obj.tr(:index => iRowIndex).td(:index => 3).text.to_s then if myHash.fetch('col5') == obj.tr(:index => iRowIndex).td(:index => 4).text.to_s then if myHash.fetch('col6') == obj.tr(:index => iRowIndex).td(:index => 5).text.to_s then if myHash.fetch('col7') == obj.tr(:index => iRowIndex).td(:index => 6).text.to_s then if myHash.fetch('col8') == obj.tr(:index => iRowIndex).td(:index => 7).text.to_s then puts ' - All columns matched. Return the delta time to main. Click this row: ' + iRowIndex.to_s endTime = Time.now - startTime puts ' - Time to match: ' + endTime.to_s puts ' - Return: ' + endTime.to_s STDOUT.flush() return endTime.to_s end end end end end end end end iRowIndex = iRowIndex + 1 end puts ' - No Match in table. ' puts ' - Return: -1' return -1 end # -------------------------------------------------------------------- # The Hash is converted to an array (array = hash.values). # The array is matched using intersection of the table's row array # A complete match outputs the time delta # -------------------------------------------------------------------- def Method_CheckTableUsingRowArray(ie,myArray) puts '* Method_CheckTableUsingRowArray' puts ' - # of Column values to match: ' + myArray.length().to_s obj = ie.table(:id,'table1').tbody(:id,'tbody1') myTableArray = obj.to_a #Array the table puts ' - Table Length (Rows): ' + myTableArray.length().to_s iRowIndex=0 startTime = Time.now myTableArray.each do |e| case (e & myArray).length() when 8 puts ' - All columns matched. Return the delta time to main. Click this row: ' + iRowIndex.to_s endTime = Time.now - startTime puts ' - Time to match: ' + endTime.to_s puts ' - Return: ' + endTime.to_s STDOUT.flush() return endTime.to_s else # do nothing end iRowIndex=iRowIndex+1 end puts ' - No Match in table. ' puts ' - Return: -1' return -1 end ########################################################################### # Main ########################################################################### # Make some data to use ie=0 sBrowserType = :chrome #symbolic # Localize and encode the html test url puts ' Current Dir: ' + Dir.getwd.to_s sURL = "file:///" + URI.escape(Dir.getwd) + '/columns.html' myHash = { 'col1' => 'Row30 Content1', 'col2' => 'Row30 Content2', 'col3' => 'Row30 Content3', 'col4' => 'Row30 Content4', 'col5' => 'Row30 Content5', 'col6' => 'Row30 Content6', 'col7' => 'Row30 Content7', 'col8' => 'Row30 Content8' } # Display some messages puts 'Check Speed Of Table Parse' puts ' - Test URL: ' + sURL.to_s puts ' - Browser type: ' + sBrowserType.to_s STDOUT.flush # Begin the test ie = Method_OpenBrowser(sURL,sBrowserType) Method_CheckTableUsingIfs(ie,myHash) Method_CheckTableUsingRowArray(ie,myHash.values) ie.close puts '* Test completed' STDOUT.flush() # End OUTPUT ======================= Check Speed Of Table Parse - Test URL: file:///C:/Documents%20and%20Settings/kpetry/Desktop/WATIR-TR-Civicorp/Automation%20Test%20Strut/columns.html - Browser type: chrome * Method_OpenBrowser - Browser type: chrome - URL: file:///C:/Documents%20and%20Settings/kpetry/Desktop/WATIR-TR-Civicorp/Automation%20Test%20Strut/columns.html - Return #<Watir::Browser:0xd051f8> * Method_CheckTableUsingIfs - # of Column values to match: 8 - All columns matched. Return the delta time to main. Click this row: 30 - Time to match: 23.587861 - Return: 23.587861 * Method_CheckTableUsingRowArray - # of Column values to match: 8 - Table Length (Rows): 31 - All columns matched. Return the delta time to main. Click this row: 30 - Time to match: 0.0 - Return: 0.0 * Test completed Tool completed successfully HTML TEST FILE Columns.html ================== <html> <head> </head> <body> <h1>Table Test Page</h1> <p>Purpose: Test watir/ruby methods for the fastest way to parse a normal table</p> <table id="table1" border="1"> <tbody id="tbody1"> <tr> <th>Col1</th> <th>Col2</th> <th>Col3</th> <th>Col4</th> <th>Col5</th> <th>Col6</th> <th>Col7</th> <th>Col8</th> </tr> <tr> <td>Row1 Content1</td> <td>Row1 Content2</td> <td>Row1 Content3</td> <td>Row1 Content4</td> <td>Row1 Content5</td> <td>Row1 Content6</td> <td>Row1 Content7</td> <td>Row1 Content8</td> </tr> <tr> <td>Row2 Content1</td> <td>Row2 Content2</td> <td>Row2 Content3</td> <td>Row2 Content4</td> <td>Row2 Content5</td> <td>Row2 Content6</td> <td>Row2 Content7</td> <td>Row2 Content8</td> </tr> <tr> <td>Row3 Content1</td> <td>Row3 Content2</td> <td>Row3 Content3</td> <td>Row3 Content4</td> <td>Row3 Content5</td> <td>Row3 Content6</td> <td>Row3 Content7</td> <td>Row3 Content8</td> </tr> <tr> <td>Row4 Content1</td> <td>Row4 Content2</td> <td>Row4 Content3</td> <td>Row4 Content4</td> <td>Row4 Content5</td> <td>Row4 Content6</td> <td>Row4 Content7</td> <td>Row4 Content8</td> </tr> <tr> <td>Row5 Content1</td> <td>Row5 Content2</td> <td>Row5 Content3</td> <td>Row5 Content4</td> <td>Row5 Content5</td> <td>Row5 Content6</td> <td>Row5 Content7</td> <td>Row5 Content8</td> </tr> <tr> <td>Row6 Content1</td> <td>Row6 Content2</td> <td>Row6 Content3</td> <td>Row6 Content4</td> <td>Row6 Content5</td> <td>Row6 Content6</td> <td>Row6 Content7</td> <td>Row6 Content8</td> </tr> <tr> <td>Row7 Content1</td> <td>Row7 Content2</td> <td>Row7 Content3</td> <td>Row7 Content4</td> <td>Row7 Content5</td> <td>Row7 Content6</td> <td>Row7 Content7</td> <td>Row7 Content8</td> </tr> <tr> <td>Row8 Content1</td> <td>Row8 Content2</td> <td>Row8 Content3</td> <td>Row8 Content4</td> <td>Row8 Content5</td> <td>Row8 Content6</td> <td>Row8 Content7</td> <td>Row8 Content8</td> </tr> <tr> <td>Row9 Content1</td> <td>Row9 Content2</td> <td>Row9 Content3</td> <td>Row9 Content4</td> <td>Row9 Content5</td> <td>Row9 Content6</td> <td>Row9 Content7</td> <td>Row9 Content8</td> </tr> <tr> <td>Row10 Content1</td> <td>Row10 Content2</td> <td>Row10 Content3</td> <td>Row10 Content4</td> <td>Row10 Content5</td> <td>Row10 Content6</td> <td>Row10 Content7</td> <td>Row10 Content8</td> </tr> <tr> <td>Row11 Content1</td> <td>Row11 Content2</td> <td>Row11 Content3</td> <td>Row11 Content4</td> <td>Row11 Content5</td> <td>Row11 Content6</td> <td>Row11 Content7</td> <td>Row11 Content8</td> </tr> <tr> <td>Row12 Content1</td> <td>Row12 Content2</td> <td>Row12 Content3</td> <td>Row12 Content4</td> <td>Row12 Content5</td> <td>Row12 Content6</td> <td>Row12 Content7</td> <td>Row12 Content8</td> </tr> <tr> <td>Row13 Content1</td> <td>Row13 Content2</td> <td>Row13 Content3</td> <td>Row13 Content4</td> <td>Row13 Content5</td> <td>Row13 Content6</td> <td>Row13 Content7</td> <td>Row13 Content8</td> </tr> <tr> <td>Row14 Content1</td> <td>Row14 Content2</td> <td>Row14 Content3</td> <td>Row14 Content4</td> <td>Row14 Content5</td> <td>Row14 Content6</td> <td>Row14 Content7</td> <td>Row14 Content8</td> </tr> <tr> <td>Row15 Content1</td> <td>Row15 Content2</td> <td>Row15 Content3</td> <td>Row15 Content4</td> <td>Row15 Content5</td> <td>Row15 Content6</td> <td>Row15 Content7</td> <td>Row15 Content8</td> </tr> <tr> <td>Row16 Content1</td> <td>Row16 Content2</td> <td>Row16 Content3</td> <td>Row16 Content4</td> <td>Row16 Content5</td> <td>Row16 Content6</td> <td>Row16 Content7</td> <td>Row16 Content8</td> </tr> <tr> <td>Row17 Content1</td> <td>Row17 Content2</td> <td>Row17 Content3</td> <td>Row17 Content4</td> <td>Row17 Content5</td> <td>Row17 Content6</td> <td>Row17 Content7</td> <td>Row17 Content8</td> </tr> <tr> <td>Row18 Content1</td> <td>Row18 Content2</td> <td>Row18 Content3</td> <td>Row18 Content4</td> <td>Row18 Content5</td> <td>Row18 Content6</td> <td>Row18 Content7</td> <td>Row18 Content8</td> </tr> <tr> <td>Row19 Content1</td> <td>Row19 Content2</td> <td>Row19 Content3</td> <td>Row19 Content4</td> <td>Row19 Content5</td> <td>Row19 Content6</td> <td>Row19 Content7</td> <td>Row19 Content8</td> </tr> <tr> <td>Row20 Content1</td> <td>Row20 Content2</td> <td>Row20 Content3</td> <td>Row20 Content4</td> <td>Row20 Content5</td> <td>Row20 Content6</td> <td>Row20 Content7</td> <td>Row20 Content8</td> </tr> <tr> <td>Row21 Content1</td> <td>Row21 Content2</td> <td>Row21 Content3</td> <td>Row21 Content4</td> <td>Row21 Content5</td> <td>Row21 Content6</td> <td>Row21 Content7</td> <td>Row21 Content8</td> </tr> <tr> <td>Row22 Content1</td> <td>Row22 Content2</td> <td>Row22 Content3</td> <td>Row22 Content4</td> <td>Row22 Content5</td> <td>Row22 Content6</td> <td>Row22 Content7</td> <td>Row22 Content8</td> </tr> <tr> <td>Row23 Content1</td> <td>Row23 Content2</td> <td>Row23 Content3</td> <td>Row23 Content4</td> <td>Row23 Content5</td> <td>Row23 Content6</td> <td>Row23 Content7</td> <td>Row23 Content8</td> </tr> <tr> <td>Row24 Content1</td> <td>Row24 Content2</td> <td>Row24 Content3</td> <td>Row24 Content4</td> <td>Row24 Content5</td> <td>Row24 Content6</td> <td>Row24 Content7</td> <td>Row24 Content8</td> </tr> <tr> <td>Row25 Content1</td> <td>Row25 Content2</td> <td>Row25 Content3</td> <td>Row25 Content4</td> <td>Row25 Content5</td> <td>Row25 Content6</td> <td>Row25 Content7</td> <td>Row25 Content8</td> </tr> <tr> <td>Row26 Content1</td> <td>Row26 Content2</td> <td>Row26 Content3</td> <td>Row26 Content4</td> <td>Row26 Content5</td> <td>Row26 Content6</td> <td>Row26 Content7</td> <td>Row26 Content8</td> </tr> <tr> <td>Row27 Content1</td> <td>Row27 Content2</td> <td>Row27 Content3</td> <td>Row27 Content4</td> <td>Row27 Content5</td> <td>Row27 Content6</td> <td>Row27 Content7</td> <td>Row27 Content8</td> </tr> <tr> <td>Row28 Content1</td> <td>Row28 Content2</td> <td>Row28 Content3</td> <td>Row28 Content4</td> <td>Row28 Content5</td> <td>Row28 Content6</td> <td>Row28 Content7</td> <td>Row28 Content8</td> </tr> <tr> <td>Row29 Content1</td> <td>Row29 Content2</td> <td>Row29 Content3</td> <td>Row29 Content4</td> <td>Row29 Content5</td> <td>Row29 Content6</td> <td>Row29 Content7</td> <td>Row29 Content8</td> </tr> <tr> <td>Row30 Content1</td> <td>Row30 Content2</td> <td>Row30 Content3</td> <td>Row30 Content4</td> <td>Row30 Content5</td> <td>Row30 Content6</td> <td>Row30 Content7</td> <td>Row30 Content8</td> </tr> </tbody> </table> </body> </hmtl> -- -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com --- You received this message because you are subscribed to the Google Groups "Watir General" group. To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.