awetestlib 0.1.28 → 0.1.29pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitattributes +22 -22
- data/.gitignore +69 -69
- data/.yardopts +7 -7
- data/README.md +108 -108
- data/awetestlib.gemspec +57 -57
- data/awetestlib.windows.gemspec +41 -41
- data/awetestlib_notes.txt +4 -4
- data/awetestlib_osx.gemspec +47 -48
- data/bin/awetestlib +99 -99
- data/bin/awetestlib-android-setup.rb +26 -26
- data/bin/awetestlib-cucumber-setup.rb +28 -28
- data/bin/awetestlib-driver-setup.rb +21 -21
- data/bin/awetestlib-helpers.rb +41 -41
- data/bin/awetestlib-mobile-app-setup.rb +31 -31
- data/bin/awetestlib-netbeans-setup.rb +58 -58
- data/bin/awetestlib-regression-setup.rb +15 -15
- data/bin/awetestlib-rubymine-setup.rb +39 -39
- data/drivers/chromedriver.exe +0 -0
- data/ext/Rakefile +1 -1
- data/ext/mkrf_conf.rb +27 -27
- data/lib/awetestlib/html_report.rb +142 -142
- data/lib/awetestlib/logging.rb +366 -366
- data/lib/awetestlib/regression/browser.rb +1380 -1375
- data/lib/awetestlib/regression/drag_and_drop.rb +421 -420
- data/lib/awetestlib/regression/find.rb +345 -345
- data/lib/awetestlib/regression/legacy.rb +1187 -1187
- data/lib/awetestlib/regression/page_data.rb +191 -191
- data/lib/awetestlib/regression/runner.rb +307 -307
- data/lib/awetestlib/regression/tables.rb +627 -619
- data/lib/awetestlib/regression/user_input.rb +576 -576
- data/lib/awetestlib/regression/utilities.rb +1046 -988
- data/lib/awetestlib/regression/validations.rb +1093 -1074
- data/lib/awetestlib/regression/waits.rb +470 -470
- data/lib/awetestlib/runner.rb +18 -18
- data/lib/awetestlib.rb +41 -41
- data/lib/patches/README +2 -2
- data/lib/patches/firewatir.rb +106 -106
- data/lib/patches/watir.rb +175 -175
- data/lib/version.rb +2 -2
- data/license.txt +13 -13
- data/netbeans_setup.md +29 -29
- data/rdoc_test.bat +1 -1
- data/rubymine_setup.md +23 -23
- data/setup_samples/sample_android/features/dk.mejer.hansen.control.FlyingColorsPlayerAidActivity.apk +0 -0
- data/setup_samples/sample_android/features/sample_android.feature +5 -5
- data/setup_samples/sample_android/features/step_definitions/calabash_steps.rb +1 -1
- data/setup_samples/sample_android/features/support/app_installation_hooks.rb +36 -36
- data/setup_samples/sample_android/features/support/app_life_cycle_hooks.rb +14 -14
- data/setup_samples/sample_android/features/test_servers/8ba795a0288381ae346b67867b586881_0.3.2.apk +0 -0
- data/setup_samples/sample_cucumber/features/step_definitions/predefined_steps.rb +76 -76
- data/setup_samples/sample_cucumber/features/yahoo_mail.feature +11 -11
- data/setup_samples/sample_mobile_app/features/my_first.feature +14 -14
- data/setup_samples/sample_mobile_app/features/step_definitions/predefined_webview_steps.rb +80 -80
- data/setup_samples/sample_mobile_app/features/support/env.rb +2 -2
- data/setup_samples/sample_netbeans/demo.rb +86 -86
- data/setup_samples/sample_netbeans/nbproject/configs/Demo.properties +2 -2
- data/setup_samples/sample_netbeans/nbproject/private/config.properties +1 -1
- data/setup_samples/sample_netbeans/nbproject/private/configs/Demo.properties +2 -2
- data/setup_samples/sample_netbeans/nbproject/private/private.properties +2 -2
- data/setup_samples/sample_netbeans/nbproject/project.properties +5 -5
- data/setup_samples/sample_netbeans/nbproject/project.xml +13 -13
- data/setup_samples/sample_rubymine/.idea/encodings.xml +5 -5
- data/setup_samples/sample_rubymine/.idea/misc.xml +5 -5
- data/setup_samples/sample_rubymine/.idea/modules.xml +9 -9
- data/setup_samples/sample_rubymine/.idea/sample_rubymine.iml +9 -9
- data/setup_samples/sample_rubymine/.idea/scopes/scope_settings.xml +4 -4
- data/setup_samples/sample_rubymine/.idea/vcs.xml +7 -7
- data/setup_samples/sample_rubymine/.idea/workspace.xml +213 -213
- data/setup_samples/sample_rubymine/demo.rb +86 -86
- data/test/create_zoho.rb +66 -66
- data/test/create_zoho_account1.rb +68 -68
- data/test/create_zoho_account2.rb +72 -72
- data/test/demo.rb +87 -87
- data/test/google_search1.rb +16 -16
- data/test/google_search2.rb +19 -19
- data/test/login_1.rb +37 -37
- data/test/login_1a.rb +37 -37
- data/test/login_2.rb +32 -32
- data/test/zoho_exercise.rb +21 -21
- data/test/zoho_util.rb +487 -487
- data/tmp/placeholder.html +71 -71
- metadata +18 -49
| @@ -1,619 +1,627 @@ | |
| 1 | 
            -
            module Awetestlib
         | 
| 2 | 
            -
              module Regression
         | 
| 3 | 
            -
                # Methods for handling Tables, Rows, and Cells
         | 
| 4 | 
            -
                # Rdoc work in progress
         | 
| 5 | 
            -
                module Tables
         | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
                  def get_index_for_column_head(panel, table_index, strg, desc = '')
         | 
| 9 | 
            -
                    table = panel.tables[table_index]
         | 
| 10 | 
            -
                    get_column_index(table, strg, desc, true)
         | 
| 11 | 
            -
                  end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                  def get_column_index(table, strg, desc = '', header = false)
         | 
| 14 | 
            -
                    msg1 = " header" if header
         | 
| 15 | 
            -
                    msg = build_message("Get index of ", msg1, " column containing #{strg}. ", desc)
         | 
| 16 | 
            -
                    rgx = Regexp.new(strg)
         | 
| 17 | 
            -
                    row_idx = 0
         | 
| 18 | 
            -
                    index   = -1
         | 
| 19 | 
            -
                    found   = false
         | 
| 20 | 
            -
                    table.each do |row|
         | 
| 21 | 
            -
                      row_idx += 1
         | 
| 22 | 
            -
                      if row.text =~ rgx
         | 
| 23 | 
            -
                        col_idx = 1
         | 
| 24 | 
            -
                        row.each do |cell|
         | 
| 25 | 
            -
                          if cell.text =~ rgx
         | 
| 26 | 
            -
                            index = col_idx
         | 
| 27 | 
            -
                            found = true
         | 
| 28 | 
            -
                            break
         | 
| 29 | 
            -
                          end
         | 
| 30 | 
            -
                          col_idx += 1
         | 
| 31 | 
            -
                        end
         | 
| 32 | 
            -
                      end
         | 
| 33 | 
            -
                      break if found or header
         | 
| 34 | 
            -
                    end
         | 
| 35 | 
            -
                    if found
         | 
| 36 | 
            -
                      passed_to_log("#{msg} at index #{index}.")
         | 
| 37 | 
            -
                      index
         | 
| 38 | 
            -
                    else
         | 
| 39 | 
            -
                      failed_to_log("#{msg}")
         | 
| 40 | 
            -
                      nil
         | 
| 41 | 
            -
                    end
         | 
| 42 | 
            -
                  rescue
         | 
| 43 | 
            -
                    failed_to_log("Unable to #{msg} '#{$!}'")
         | 
| 44 | 
            -
                  end
         | 
| 45 | 
            -
             | 
| 46 | 
            -
                  # Return the index of the last row of the specified table.
         | 
| 47 | 
            -
                  # @param [Watir::Table] table A reference to the table in question.
         | 
| 48 | 
            -
                  # @param [Fixnum] pad The number of zeroes to prefix the index to allow correct sorting.
         | 
| 49 | 
            -
                  # @param [Fixnum] every A number indicating which rows in the table actually carry data if
         | 
| 50 | 
            -
                  #   the table is padded with empty rows.  1 = every row, 2 = every other row, 3 = every third
         | 
| 51 | 
            -
                  #   row, and etc.
         | 
| 52 | 
            -
                  # @return [Fixnum]
         | 
| 53 | 
            -
                  def get_index_of_last_row(table, pad = 2, every = 1)
         | 
| 54 | 
            -
                    index = calc_index(table.row_count, every)
         | 
| 55 | 
            -
                    index = index.to_s.rjust(pad, '0')
         | 
| 56 | 
            -
                    #debug_to_log("#{__method__}: index='#{index}' row_count=#{table.row_count} pad=#{pad} every=#{every}")
         | 
| 57 | 
            -
                    index
         | 
| 58 | 
            -
                  end
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                  alias get_index_for_last_row get_index_of_last_row
         | 
| 61 | 
            -
             | 
| 62 | 
            -
                  # Return the index of the last row of the specified table containing *strg*
         | 
| 63 | 
            -
                  # @param [Watir::Table] table A reference to the table in question.
         | 
| 64 | 
            -
                  # @param [String, Regexp] strg A string or regular expression to search for in the table..
         | 
| 65 | 
            -
                  # @param [Fixnum] column_index A number indicating which rows the column to focus the search in.
         | 
| 66 | 
            -
                  # When not supplied, the entire row is searched for *strg*.
         | 
| 67 | 
            -
                  # @return [Fixnum]
         | 
| 68 | 
            -
                  def get_index_of_last_row_with_text(table, strg, column_index = nil)
         | 
| 69 | 
            -
                    debug_to_log("#{__method__}: #{get_callers(5)}")
         | 
| 70 | 
            -
                    msg1 = " in column #{column_index}" if column_index
         | 
| 71 | 
            -
                    msg = build_message("Find last row in table :id=#{table.id} with text '#{strg}'", msg1)
         | 
| 72 | 
            -
                    dbg = build_message("#{__method__}: #{table.id} text by row", msg1)
         | 
| 73 | 
            -
                    index    = 0
         | 
| 74 | 
            -
                    found    = false
         | 
| 75 | 
            -
                    at_index = 0
         | 
| 76 | 
            -
                    #row_count = table.row_count
         | 
| 77 | 
            -
                    table.rows.each do |row|
         | 
| 78 | 
            -
                      cell_count = get_cell_count(row)
         | 
| 79 | 
            -
                      index      += 1
         | 
| 80 | 
            -
                      text       = ''
         | 
| 81 | 
            -
                      if column_index
         | 
| 82 | 
            -
                        col_idx = column_index.to_i
         | 
| 83 | 
            -
                        if cell_count >= col_idx
         | 
| 84 | 
            -
                          text = row[col_idx].text
         | 
| 85 | 
            -
                        end
         | 
| 86 | 
            -
                      else
         | 
| 87 | 
            -
                        text = row.text
         | 
| 88 | 
            -
                      end
         | 
| 89 | 
            -
                      dbg << "\n#{index}. [#{text}]"
         | 
| 90 | 
            -
                      if text =~ /#{strg}/
         | 
| 91 | 
            -
                        found    = true
         | 
| 92 | 
            -
                        at_index = index
         | 
| 93 | 
            -
                      end
         | 
| 94 | 
            -
                    end
         | 
| 95 | 
            -
                    debug_to_log(dbg)
         | 
| 96 | 
            -
                    if found
         | 
| 97 | 
            -
                      passed_to_log("#{msg} at index #{index}.")
         | 
| 98 | 
            -
                      at_index
         | 
| 99 | 
            -
                    else
         | 
| 100 | 
            -
                      failed_to_log("#{msg}")
         | 
| 101 | 
            -
                      nil
         | 
| 102 | 
            -
                    end
         | 
| 103 | 
            -
                  rescue
         | 
| 104 | 
            -
                    failed_to_log("Unable to #{msg}. '#{$!}'")
         | 
| 105 | 
            -
                  end
         | 
| 106 | 
            -
             | 
| 107 | 
            -
                  alias get_index_for_last_row_with_text get_index_of_last_row_with_text
         | 
| 108 | 
            -
             | 
| 109 | 
            -
                  # Return the index of the _first_ row of the specified table containing *strg*
         | 
| 110 | 
            -
                  # @param [Watir::Table] table A reference to the table in question.
         | 
| 111 | 
            -
                  # @param [String, Regexp] strg A string or regular expression to search for in the table..
         | 
| 112 | 
            -
                  # @param [Fixnum] column_index A number indicating which rows the column to focus the search in.
         | 
| 113 | 
            -
                  # When not supplied, the entire row is searched for *strg*.
         | 
| 114 | 
            -
                  # @param [Boolean] fail_if_found If true log a failure if *strg* _is_ found.
         | 
| 115 | 
            -
                  # @ | 
| 116 | 
            -
                   | 
| 117 | 
            -
             | 
| 118 | 
            -
             | 
| 119 | 
            -
             | 
| 120 | 
            -
                     | 
| 121 | 
            -
                      msg = ' | 
| 122 | 
            -
                     | 
| 123 | 
            -
             | 
| 124 | 
            -
                     | 
| 125 | 
            -
                     | 
| 126 | 
            -
                     | 
| 127 | 
            -
                     | 
| 128 | 
            -
                     | 
| 129 | 
            -
                     | 
| 130 | 
            -
             | 
| 131 | 
            -
             | 
| 132 | 
            -
                       | 
| 133 | 
            -
                       | 
| 134 | 
            -
             | 
| 135 | 
            -
             | 
| 136 | 
            -
             | 
| 137 | 
            -
                         | 
| 138 | 
            -
             | 
| 139 | 
            -
                         | 
| 140 | 
            -
                       | 
| 141 | 
            -
             | 
| 142 | 
            -
                       | 
| 143 | 
            -
             | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 148 | 
            -
             | 
| 149 | 
            -
             | 
| 150 | 
            -
             | 
| 151 | 
            -
             | 
| 152 | 
            -
             | 
| 153 | 
            -
             | 
| 154 | 
            -
             | 
| 155 | 
            -
                     | 
| 156 | 
            -
                      if fail_if_found
         | 
| 157 | 
            -
                         | 
| 158 | 
            -
                      else
         | 
| 159 | 
            -
                         | 
| 160 | 
            -
                      end
         | 
| 161 | 
            -
                       | 
| 162 | 
            -
                     | 
| 163 | 
            -
             | 
| 164 | 
            -
             | 
| 165 | 
            -
             | 
| 166 | 
            -
             | 
| 167 | 
            -
             | 
| 168 | 
            -
             | 
| 169 | 
            -
             | 
| 170 | 
            -
                   | 
| 171 | 
            -
             | 
| 172 | 
            -
                   | 
| 173 | 
            -
             | 
| 174 | 
            -
                  #  | 
| 175 | 
            -
                  #  | 
| 176 | 
            -
                  #  | 
| 177 | 
            -
                  # @ | 
| 178 | 
            -
                   | 
| 179 | 
            -
             | 
| 180 | 
            -
             | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 184 | 
            -
             | 
| 185 | 
            -
             | 
| 186 | 
            -
             | 
| 187 | 
            -
             | 
| 188 | 
            -
             | 
| 189 | 
            -
             | 
| 190 | 
            -
             | 
| 191 | 
            -
             | 
| 192 | 
            -
             | 
| 193 | 
            -
             | 
| 194 | 
            -
                       | 
| 195 | 
            -
                         | 
| 196 | 
            -
             | 
| 197 | 
            -
                           | 
| 198 | 
            -
             | 
| 199 | 
            -
             | 
| 200 | 
            -
             | 
| 201 | 
            -
             | 
| 202 | 
            -
                         | 
| 203 | 
            -
             | 
| 204 | 
            -
             | 
| 205 | 
            -
             | 
| 206 | 
            -
                       | 
| 207 | 
            -
             | 
| 208 | 
            -
             | 
| 209 | 
            -
             | 
| 210 | 
            -
             | 
| 211 | 
            -
             | 
| 212 | 
            -
                     | 
| 213 | 
            -
             | 
| 214 | 
            -
             | 
| 215 | 
            -
             | 
| 216 | 
            -
             | 
| 217 | 
            -
             | 
| 218 | 
            -
                   | 
| 219 | 
            -
             | 
| 220 | 
            -
                   | 
| 221 | 
            -
             | 
| 222 | 
            -
             | 
| 223 | 
            -
             | 
| 224 | 
            -
             | 
| 225 | 
            -
             | 
| 226 | 
            -
             | 
| 227 | 
            -
             | 
| 228 | 
            -
             | 
| 229 | 
            -
             | 
| 230 | 
            -
             | 
| 231 | 
            -
             | 
| 232 | 
            -
             | 
| 233 | 
            -
             | 
| 234 | 
            -
             | 
| 235 | 
            -
             | 
| 236 | 
            -
             | 
| 237 | 
            -
             | 
| 238 | 
            -
             | 
| 239 | 
            -
                       | 
| 240 | 
            -
                    end
         | 
| 241 | 
            -
             | 
| 242 | 
            -
             | 
| 243 | 
            -
             | 
| 244 | 
            -
             | 
| 245 | 
            -
             | 
| 246 | 
            -
             | 
| 247 | 
            -
             | 
| 248 | 
            -
                   | 
| 249 | 
            -
             | 
| 250 | 
            -
                   | 
| 251 | 
            -
             | 
| 252 | 
            -
             | 
| 253 | 
            -
             | 
| 254 | 
            -
             | 
| 255 | 
            -
             | 
| 256 | 
            -
             | 
| 257 | 
            -
             | 
| 258 | 
            -
             | 
| 259 | 
            -
             | 
| 260 | 
            -
                     | 
| 261 | 
            -
             | 
| 262 | 
            -
             | 
| 263 | 
            -
             | 
| 264 | 
            -
             | 
| 265 | 
            -
             | 
| 266 | 
            -
             | 
| 267 | 
            -
                     | 
| 268 | 
            -
             | 
| 269 | 
            -
                     | 
| 270 | 
            -
             | 
| 271 | 
            -
             | 
| 272 | 
            -
             | 
| 273 | 
            -
             | 
| 274 | 
            -
             | 
| 275 | 
            -
             | 
| 276 | 
            -
             | 
| 277 | 
            -
             | 
| 278 | 
            -
             | 
| 279 | 
            -
             | 
| 280 | 
            -
             | 
| 281 | 
            -
                         | 
| 282 | 
            -
             | 
| 283 | 
            -
             | 
| 284 | 
            -
             | 
| 285 | 
            -
             | 
| 286 | 
            -
             | 
| 287 | 
            -
             | 
| 288 | 
            -
             | 
| 289 | 
            -
             | 
| 290 | 
            -
             | 
| 291 | 
            -
             | 
| 292 | 
            -
                   | 
| 293 | 
            -
             | 
| 294 | 
            -
                   | 
| 295 | 
            -
             | 
| 296 | 
            -
             | 
| 297 | 
            -
             | 
| 298 | 
            -
             | 
| 299 | 
            -
             | 
| 300 | 
            -
             | 
| 301 | 
            -
             | 
| 302 | 
            -
             | 
| 303 | 
            -
             | 
| 304 | 
            -
             | 
| 305 | 
            -
             | 
| 306 | 
            -
                     | 
| 307 | 
            -
             | 
| 308 | 
            -
             | 
| 309 | 
            -
             | 
| 310 | 
            -
             | 
| 311 | 
            -
             | 
| 312 | 
            -
             | 
| 313 | 
            -
             | 
| 314 | 
            -
             | 
| 315 | 
            -
                     | 
| 316 | 
            -
             | 
| 317 | 
            -
             | 
| 318 | 
            -
             | 
| 319 | 
            -
             | 
| 320 | 
            -
             | 
| 321 | 
            -
             | 
| 322 | 
            -
             | 
| 323 | 
            -
             | 
| 324 | 
            -
             | 
| 325 | 
            -
                         | 
| 326 | 
            -
             | 
| 327 | 
            -
             | 
| 328 | 
            -
             | 
| 329 | 
            -
             | 
| 330 | 
            -
             | 
| 331 | 
            -
             | 
| 332 | 
            -
             | 
| 333 | 
            -
             | 
| 334 | 
            -
                     | 
| 335 | 
            -
             | 
| 336 | 
            -
             | 
| 337 | 
            -
             | 
| 338 | 
            -
             | 
| 339 | 
            -
             | 
| 340 | 
            -
             | 
| 341 | 
            -
                     | 
| 342 | 
            -
                     | 
| 343 | 
            -
             | 
| 344 | 
            -
             | 
| 345 | 
            -
             | 
| 346 | 
            -
             | 
| 347 | 
            -
             | 
| 348 | 
            -
             | 
| 349 | 
            -
             | 
| 350 | 
            -
             | 
| 351 | 
            -
             | 
| 352 | 
            -
             | 
| 353 | 
            -
             | 
| 354 | 
            -
             | 
| 355 | 
            -
                     | 
| 356 | 
            -
                     | 
| 357 | 
            -
             | 
| 358 | 
            -
             | 
| 359 | 
            -
             | 
| 360 | 
            -
             | 
| 361 | 
            -
             | 
| 362 | 
            -
                       | 
| 363 | 
            -
                    end
         | 
| 364 | 
            -
                     | 
| 365 | 
            -
                  end
         | 
| 366 | 
            -
             | 
| 367 | 
            -
                  def  | 
| 368 | 
            -
                     | 
| 369 | 
            -
                     | 
| 370 | 
            -
             | 
| 371 | 
            -
                     | 
| 372 | 
            -
                     | 
| 373 | 
            -
             | 
| 374 | 
            -
             | 
| 375 | 
            -
             | 
| 376 | 
            -
             | 
| 377 | 
            -
             | 
| 378 | 
            -
             | 
| 379 | 
            -
             | 
| 380 | 
            -
             | 
| 381 | 
            -
             | 
| 382 | 
            -
             | 
| 383 | 
            -
             | 
| 384 | 
            -
             | 
| 385 | 
            -
             | 
| 386 | 
            -
             | 
| 387 | 
            -
             | 
| 388 | 
            -
                       | 
| 389 | 
            -
                     | 
| 390 | 
            -
             | 
| 391 | 
            -
                     | 
| 392 | 
            -
                  end
         | 
| 393 | 
            -
             | 
| 394 | 
            -
                  def  | 
| 395 | 
            -
                     | 
| 396 | 
            -
             | 
| 397 | 
            -
                     | 
| 398 | 
            -
             | 
| 399 | 
            -
             | 
| 400 | 
            -
             | 
| 401 | 
            -
             | 
| 402 | 
            -
             | 
| 403 | 
            -
             | 
| 404 | 
            -
             | 
| 405 | 
            -
             | 
| 406 | 
            -
                     | 
| 407 | 
            -
             | 
| 408 | 
            -
             | 
| 409 | 
            -
             | 
| 410 | 
            -
             | 
| 411 | 
            -
             | 
| 412 | 
            -
             | 
| 413 | 
            -
             | 
| 414 | 
            -
             | 
| 415 | 
            -
             | 
| 416 | 
            -
             | 
| 417 | 
            -
             | 
| 418 | 
            -
             | 
| 419 | 
            -
             | 
| 420 | 
            -
             | 
| 421 | 
            -
             | 
| 422 | 
            -
                         | 
| 423 | 
            -
             | 
| 424 | 
            -
                         | 
| 425 | 
            -
             | 
| 426 | 
            -
             | 
| 427 | 
            -
             | 
| 428 | 
            -
             | 
| 429 | 
            -
                           | 
| 430 | 
            -
                        else
         | 
| 431 | 
            -
                           | 
| 432 | 
            -
             | 
| 433 | 
            -
             | 
| 434 | 
            -
             | 
| 435 | 
            -
                         | 
| 436 | 
            -
             | 
| 437 | 
            -
             | 
| 438 | 
            -
             | 
| 439 | 
            -
             | 
| 440 | 
            -
             | 
| 441 | 
            -
             | 
| 442 | 
            -
             | 
| 443 | 
            -
             | 
| 444 | 
            -
             | 
| 445 | 
            -
                     | 
| 446 | 
            -
             | 
| 447 | 
            -
                     | 
| 448 | 
            -
             | 
| 449 | 
            -
                     | 
| 450 | 
            -
             | 
| 451 | 
            -
             | 
| 452 | 
            -
             | 
| 453 | 
            -
             | 
| 454 | 
            -
             | 
| 455 | 
            -
             | 
| 456 | 
            -
             | 
| 457 | 
            -
             | 
| 458 | 
            -
             | 
| 459 | 
            -
             | 
| 460 | 
            -
             | 
| 461 | 
            -
             | 
| 462 | 
            -
             | 
| 463 | 
            -
             | 
| 464 | 
            -
             | 
| 465 | 
            -
             | 
| 466 | 
            -
             | 
| 467 | 
            -
             | 
| 468 | 
            -
             | 
| 469 | 
            -
             | 
| 470 | 
            -
             | 
| 471 | 
            -
                         | 
| 472 | 
            -
             | 
| 473 | 
            -
             | 
| 474 | 
            -
             | 
| 475 | 
            -
             | 
| 476 | 
            -
             | 
| 477 | 
            -
             | 
| 478 | 
            -
             | 
| 479 | 
            -
             | 
| 480 | 
            -
             | 
| 481 | 
            -
             | 
| 482 | 
            -
             | 
| 483 | 
            -
                     | 
| 484 | 
            -
             | 
| 485 | 
            -
                    # | 
| 486 | 
            -
             | 
| 487 | 
            -
             | 
| 488 | 
            -
             | 
| 489 | 
            -
             | 
| 490 | 
            -
             | 
| 491 | 
            -
                     | 
| 492 | 
            -
                     | 
| 493 | 
            -
                     | 
| 494 | 
            -
                     | 
| 495 | 
            -
             | 
| 496 | 
            -
                    # | 
| 497 | 
            -
             | 
| 498 | 
            -
                    # | 
| 499 | 
            -
                     | 
| 500 | 
            -
                     | 
| 501 | 
            -
                     | 
| 502 | 
            -
                     | 
| 503 | 
            -
                    #       | 
| 504 | 
            -
                    # | 
| 505 | 
            -
                    # | 
| 506 | 
            -
                    # | 
| 507 | 
            -
                    # | 
| 508 | 
            -
                    # | 
| 509 | 
            -
                    # | 
| 510 | 
            -
             | 
| 511 | 
            -
             | 
| 512 | 
            -
             | 
| 513 | 
            -
             | 
| 514 | 
            -
                   | 
| 515 | 
            -
                     | 
| 516 | 
            -
                     | 
| 517 | 
            -
             | 
| 518 | 
            -
             | 
| 519 | 
            -
             | 
| 520 | 
            -
             | 
| 521 | 
            -
             | 
| 522 | 
            -
             | 
| 523 | 
            -
                     | 
| 524 | 
            -
             | 
| 525 | 
            -
             | 
| 526 | 
            -
             | 
| 527 | 
            -
                     | 
| 528 | 
            -
             | 
| 529 | 
            -
             | 
| 530 | 
            -
             | 
| 531 | 
            -
             | 
| 532 | 
            -
             | 
| 533 | 
            -
                     | 
| 534 | 
            -
             | 
| 535 | 
            -
             | 
| 536 | 
            -
             | 
| 537 | 
            -
             | 
| 538 | 
            -
             | 
| 539 | 
            -
             | 
| 540 | 
            -
             | 
| 541 | 
            -
             | 
| 542 | 
            -
                     | 
| 543 | 
            -
             | 
| 544 | 
            -
                     | 
| 545 | 
            -
             | 
| 546 | 
            -
             | 
| 547 | 
            -
             | 
| 548 | 
            -
             | 
| 549 | 
            -
             | 
| 550 | 
            -
             | 
| 551 | 
            -
             | 
| 552 | 
            -
                     | 
| 553 | 
            -
             | 
| 554 | 
            -
             | 
| 555 | 
            -
             | 
| 556 | 
            -
             | 
| 557 | 
            -
             | 
| 558 | 
            -
             | 
| 559 | 
            -
             | 
| 560 | 
            -
             | 
| 561 | 
            -
             | 
| 562 | 
            -
                      # | 
| 563 | 
            -
                      # | 
| 564 | 
            -
                      # | 
| 565 | 
            -
                      # | 
| 566 | 
            -
                      # | 
| 567 | 
            -
                      # | 
| 568 | 
            -
                      # | 
| 569 | 
            -
                      # | 
| 570 | 
            -
             | 
| 571 | 
            -
                     | 
| 572 | 
            -
             | 
| 573 | 
            -
             | 
| 574 | 
            -
             | 
| 575 | 
            -
             | 
| 576 | 
            -
                  #  | 
| 577 | 
            -
             | 
| 578 | 
            -
             | 
| 579 | 
            -
                     | 
| 580 | 
            -
             | 
| 581 | 
            -
             | 
| 582 | 
            -
             | 
| 583 | 
            -
             | 
| 584 | 
            -
             | 
| 585 | 
            -
             | 
| 586 | 
            -
                     | 
| 587 | 
            -
                     | 
| 588 | 
            -
             | 
| 589 | 
            -
             | 
| 590 | 
            -
             | 
| 591 | 
            -
             | 
| 592 | 
            -
                     | 
| 593 | 
            -
                       | 
| 594 | 
            -
             | 
| 595 | 
            -
                     | 
| 596 | 
            -
             | 
| 597 | 
            -
             | 
| 598 | 
            -
                   | 
| 599 | 
            -
                     | 
| 600 | 
            -
             | 
| 601 | 
            -
             | 
| 602 | 
            -
             | 
| 603 | 
            -
                     | 
| 604 | 
            -
             | 
| 605 | 
            -
                     | 
| 606 | 
            -
             | 
| 607 | 
            -
             | 
| 608 | 
            -
             | 
| 609 | 
            -
             | 
| 610 | 
            -
             | 
| 611 | 
            -
                     | 
| 612 | 
            -
             | 
| 613 | 
            -
             | 
| 614 | 
            -
             | 
| 615 | 
            -
             | 
| 616 | 
            -
             | 
| 617 | 
            -
             | 
| 618 | 
            -
             | 
| 619 | 
            -
             | 
| 1 | 
            +
            module Awetestlib
         | 
| 2 | 
            +
              module Regression
         | 
| 3 | 
            +
                # Methods for handling Tables, Rows, and Cells
         | 
| 4 | 
            +
                # Rdoc work in progress
         | 
| 5 | 
            +
                module Tables
         | 
| 6 | 
            +
             | 
| 7 | 
            +
             | 
| 8 | 
            +
                  def get_index_for_column_head(panel, table_index, strg, desc = '')
         | 
| 9 | 
            +
                    table = panel.tables[table_index]
         | 
| 10 | 
            +
                    get_column_index(table, strg, desc, true)
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def get_column_index(table, strg, desc = '', header = false)
         | 
| 14 | 
            +
                    msg1 = " header" if header
         | 
| 15 | 
            +
                    msg = build_message("Get index of ", msg1, " column containing #{strg}. ", desc)
         | 
| 16 | 
            +
                    rgx = Regexp.new(strg)
         | 
| 17 | 
            +
                    row_idx = 0
         | 
| 18 | 
            +
                    index   = -1
         | 
| 19 | 
            +
                    found   = false
         | 
| 20 | 
            +
                    table.each do |row|
         | 
| 21 | 
            +
                      row_idx += 1
         | 
| 22 | 
            +
                      if row.text =~ rgx
         | 
| 23 | 
            +
                        col_idx = 1
         | 
| 24 | 
            +
                        row.each do |cell|
         | 
| 25 | 
            +
                          if cell.text =~ rgx
         | 
| 26 | 
            +
                            index = col_idx
         | 
| 27 | 
            +
                            found = true
         | 
| 28 | 
            +
                            break
         | 
| 29 | 
            +
                          end
         | 
| 30 | 
            +
                          col_idx += 1
         | 
| 31 | 
            +
                        end
         | 
| 32 | 
            +
                      end
         | 
| 33 | 
            +
                      break if found or header
         | 
| 34 | 
            +
                    end
         | 
| 35 | 
            +
                    if found
         | 
| 36 | 
            +
                      passed_to_log("#{msg} at index #{index}.")
         | 
| 37 | 
            +
                      index
         | 
| 38 | 
            +
                    else
         | 
| 39 | 
            +
                      failed_to_log("#{msg}")
         | 
| 40 | 
            +
                      nil
         | 
| 41 | 
            +
                    end
         | 
| 42 | 
            +
                  rescue
         | 
| 43 | 
            +
                    failed_to_log("Unable to #{msg} '#{$!}'")
         | 
| 44 | 
            +
                  end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  # Return the index of the last row of the specified table.
         | 
| 47 | 
            +
                  # @param [Watir::Table] table A reference to the table in question.
         | 
| 48 | 
            +
                  # @param [Fixnum] pad The number of zeroes to prefix the index to allow correct sorting.
         | 
| 49 | 
            +
                  # @param [Fixnum] every A number indicating which rows in the table actually carry data if
         | 
| 50 | 
            +
                  #   the table is padded with empty rows.  1 = every row, 2 = every other row, 3 = every third
         | 
| 51 | 
            +
                  #   row, and etc.
         | 
| 52 | 
            +
                  # @return [Fixnum]
         | 
| 53 | 
            +
                  def get_index_of_last_row(table, pad = 2, every = 1)
         | 
| 54 | 
            +
                    index = calc_index(table.row_count, every)
         | 
| 55 | 
            +
                    index = index.to_s.rjust(pad, '0')
         | 
| 56 | 
            +
                    #debug_to_log("#{__method__}: index='#{index}' row_count=#{table.row_count} pad=#{pad} every=#{every}")
         | 
| 57 | 
            +
                    index
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  alias get_index_for_last_row get_index_of_last_row
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  # Return the index of the last row of the specified table containing *strg*
         | 
| 63 | 
            +
                  # @param [Watir::Table] table A reference to the table in question.
         | 
| 64 | 
            +
                  # @param [String, Regexp] strg A string or regular expression to search for in the table..
         | 
| 65 | 
            +
                  # @param [Fixnum] column_index A number indicating which rows the column to focus the search in.
         | 
| 66 | 
            +
                  # When not supplied, the entire row is searched for *strg*.
         | 
| 67 | 
            +
                  # @return [Fixnum]
         | 
| 68 | 
            +
                  def get_index_of_last_row_with_text(table, strg, column_index = nil)
         | 
| 69 | 
            +
                    debug_to_log("#{__method__}: #{get_callers(5)}")
         | 
| 70 | 
            +
                    msg1 = " in column #{column_index}" if column_index
         | 
| 71 | 
            +
                    msg = build_message("Find last row in table :id=#{table.id} with text '#{strg}'", msg1)
         | 
| 72 | 
            +
                    dbg = build_message("#{__method__}: #{table.id} text by row", msg1)
         | 
| 73 | 
            +
                    index    = 0
         | 
| 74 | 
            +
                    found    = false
         | 
| 75 | 
            +
                    at_index = 0
         | 
| 76 | 
            +
                    #row_count = table.row_count
         | 
| 77 | 
            +
                    table.rows.each do |row|
         | 
| 78 | 
            +
                      cell_count = get_cell_count(row)
         | 
| 79 | 
            +
                      index      += 1
         | 
| 80 | 
            +
                      text       = ''
         | 
| 81 | 
            +
                      if column_index
         | 
| 82 | 
            +
                        col_idx = column_index.to_i
         | 
| 83 | 
            +
                        if cell_count >= col_idx
         | 
| 84 | 
            +
                          text = row[col_idx].text
         | 
| 85 | 
            +
                        end
         | 
| 86 | 
            +
                      else
         | 
| 87 | 
            +
                        text = row.text
         | 
| 88 | 
            +
                      end
         | 
| 89 | 
            +
                      dbg << "\n#{index}. [#{text}]"
         | 
| 90 | 
            +
                      if text =~ /#{strg}/
         | 
| 91 | 
            +
                        found    = true
         | 
| 92 | 
            +
                        at_index = index
         | 
| 93 | 
            +
                      end
         | 
| 94 | 
            +
                    end
         | 
| 95 | 
            +
                    debug_to_log(dbg)
         | 
| 96 | 
            +
                    if found
         | 
| 97 | 
            +
                      passed_to_log("#{msg} at index #{index}.")
         | 
| 98 | 
            +
                      at_index
         | 
| 99 | 
            +
                    else
         | 
| 100 | 
            +
                      failed_to_log("#{msg}")
         | 
| 101 | 
            +
                      nil
         | 
| 102 | 
            +
                    end
         | 
| 103 | 
            +
                  rescue
         | 
| 104 | 
            +
                    failed_to_log("Unable to #{msg}. '#{$!}'")
         | 
| 105 | 
            +
                  end
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                  alias get_index_for_last_row_with_text get_index_of_last_row_with_text
         | 
| 108 | 
            +
             | 
| 109 | 
            +
                  # Return the index of the _first_ row of the specified table containing *strg*
         | 
| 110 | 
            +
                  # @param [Watir::Table] table A reference to the table in question.
         | 
| 111 | 
            +
                  # @param [String, Regexp] strg A string or regular expression to search for in the table..
         | 
| 112 | 
            +
                  # @param [Fixnum] column_index A number indicating which rows the column to focus the search in.
         | 
| 113 | 
            +
                  # When not supplied, the entire row is searched for *strg*.
         | 
| 114 | 
            +
                  # @param [Boolean] fail_if_found If true log a failure if *strg* _is_ found.
         | 
| 115 | 
            +
                  # @param [Fixnum] after_index Forces method to accept hit on *strg* only if it occurs
         | 
| 116 | 
            +
                  # after the row indicated by this argument. When omitted, the first hit is accepted.
         | 
| 117 | 
            +
                  # @return [Fixnum] the index of the row containing *strg*
         | 
| 118 | 
            +
                  def get_index_of_row_with_text(table, strg, column_index = nil, fail_if_found = false, after_index = nil)
         | 
| 119 | 
            +
                    debug_to_log("#{__method__}: #{get_callers(5)}")
         | 
| 120 | 
            +
                    if fail_if_found
         | 
| 121 | 
            +
                      msg = 'No '
         | 
| 122 | 
            +
                    else
         | 
| 123 | 
            +
                      msg = 'Find '
         | 
| 124 | 
            +
                    end
         | 
| 125 | 
            +
                    msg << "row in table :id=#{table.id} with text '#{strg}'"
         | 
| 126 | 
            +
                    msg << " in column #{column_index}" if column_index
         | 
| 127 | 
            +
                    dbg = "#{__method__}: #{table.id} text by row "
         | 
| 128 | 
            +
                    dbg << "in column #{column_index}" if column_index
         | 
| 129 | 
            +
                    index = 0
         | 
| 130 | 
            +
                    found = false
         | 
| 131 | 
            +
                    table.rows.each do |row|
         | 
| 132 | 
            +
                      cell_count = row.cells.length
         | 
| 133 | 
            +
                      index      += 1
         | 
| 134 | 
            +
                      text       = ''
         | 
| 135 | 
            +
                      if column_index
         | 
| 136 | 
            +
                        col_idx = column_index.to_i
         | 
| 137 | 
            +
                        if cell_count >= col_idx
         | 
| 138 | 
            +
                          text = row[col_idx].text
         | 
| 139 | 
            +
                        end
         | 
| 140 | 
            +
                      else
         | 
| 141 | 
            +
                        text = row.text
         | 
| 142 | 
            +
                      end
         | 
| 143 | 
            +
                      dbg << "\n#{index}. [#{text}]"
         | 
| 144 | 
            +
                      if text =~ /#{strg}/
         | 
| 145 | 
            +
                        if after_index and index > after_index
         | 
| 146 | 
            +
                          found = true
         | 
| 147 | 
            +
                          break
         | 
| 148 | 
            +
                        else
         | 
| 149 | 
            +
                          found = true
         | 
| 150 | 
            +
                          break
         | 
| 151 | 
            +
                        end
         | 
| 152 | 
            +
                      end
         | 
| 153 | 
            +
                    end
         | 
| 154 | 
            +
                    debug_to_log(dbg)
         | 
| 155 | 
            +
                    if found
         | 
| 156 | 
            +
                      if fail_if_found
         | 
| 157 | 
            +
                        failed_to_log("#{msg} at index #{index}.")
         | 
| 158 | 
            +
                      else
         | 
| 159 | 
            +
                        passed_to_log("#{msg} at index #{index}.")
         | 
| 160 | 
            +
                      end
         | 
| 161 | 
            +
                      index
         | 
| 162 | 
            +
                    else
         | 
| 163 | 
            +
                      if fail_if_found
         | 
| 164 | 
            +
                        passed_to_log("#{msg}")
         | 
| 165 | 
            +
                      else
         | 
| 166 | 
            +
                        failed_to_log("#{msg}")
         | 
| 167 | 
            +
                      end
         | 
| 168 | 
            +
                      nil
         | 
| 169 | 
            +
                    end
         | 
| 170 | 
            +
                  rescue
         | 
| 171 | 
            +
                    failed_to_log("Unable to #{msg}. '#{$!}'")
         | 
| 172 | 
            +
                  end
         | 
| 173 | 
            +
             | 
| 174 | 
            +
                  # Return the index of the _first_ row of the specified table containing *strg* in a text field
         | 
| 175 | 
            +
                  # identified by *how* and *what*.
         | 
| 176 | 
            +
                  # @param [Watir::Table] table A reference to the table in question.
         | 
| 177 | 
            +
                  # @param [String, Regexp] strg A string or regular expression to search for in the table..
         | 
| 178 | 
            +
                  # @param [Symbol] how The element attribute used to identify the specific element.
         | 
| 179 | 
            +
                  #   Valid values depend on the kind of element.
         | 
| 180 | 
            +
                  #   Common values: :text, :id, :title, :name, :class, :href (:link only)
         | 
| 181 | 
            +
                  # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
         | 
| 182 | 
            +
                  # @param [Fixnum] column_index A number indicating which rows the column to focus the search in.
         | 
| 183 | 
            +
                  # When not supplied, the entire row is searched for *strg*.
         | 
| 184 | 
            +
                  # @return [Fixnum] the index of the row containing *strg*
         | 
| 185 | 
            +
                  def get_index_of_row_with_textfield_value(table, strg, how, what, column_index = nil)
         | 
| 186 | 
            +
                    msg = "Find row in table :id=#{table.id} with value '#{strg}' in text_field #{how}=>'#{what} "
         | 
| 187 | 
            +
                    msg << " in column #{column_index}" if column_index
         | 
| 188 | 
            +
                    index = 0
         | 
| 189 | 
            +
                    found = false
         | 
| 190 | 
            +
                    table.rows.each do |row|
         | 
| 191 | 
            +
                      cell_count = get_cell_count(row)
         | 
| 192 | 
            +
                      index      += 1
         | 
| 193 | 
            +
                      text       = ''
         | 
| 194 | 
            +
                      if column_index
         | 
| 195 | 
            +
                        col_idx = column_index.to_i
         | 
| 196 | 
            +
                        if cell_count >= col_idx
         | 
| 197 | 
            +
                          if  row[col_idx].text_field(how, what).exists?
         | 
| 198 | 
            +
                            value = row[col_idx].text_field(how, what).value
         | 
| 199 | 
            +
                          end
         | 
| 200 | 
            +
                        end
         | 
| 201 | 
            +
                      else
         | 
| 202 | 
            +
                        if  row.text_field(how, what).exists?
         | 
| 203 | 
            +
                          value = row.text_field(how, what).value
         | 
| 204 | 
            +
                          sleep(0.25)
         | 
| 205 | 
            +
                        end
         | 
| 206 | 
            +
                      end
         | 
| 207 | 
            +
                      if value and value =~ /#{strg}/
         | 
| 208 | 
            +
                        found = true
         | 
| 209 | 
            +
                        break
         | 
| 210 | 
            +
                      end
         | 
| 211 | 
            +
                    end
         | 
| 212 | 
            +
                    if found
         | 
| 213 | 
            +
                      passed_to_log("#{msg} at index #{index}.")
         | 
| 214 | 
            +
                    else
         | 
| 215 | 
            +
                      failed_to_log("#{msg}")
         | 
| 216 | 
            +
                    end
         | 
| 217 | 
            +
                    index
         | 
| 218 | 
            +
                  rescue
         | 
| 219 | 
            +
                    failed_to_log("Unable to #{msg}. '#{$!}'")
         | 
| 220 | 
            +
                  end
         | 
| 221 | 
            +
             | 
| 222 | 
            +
                  # Return the index of a table in *browser* containing *strg*.  *ordinal* indicates
         | 
| 223 | 
            +
                  # whether it is the first, second, third, etc. table found with the matching text in *strg*
         | 
| 224 | 
            +
                  # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
         | 
| 225 | 
            +
                  # @param [String, Regexp] strg A string or regular expression to search for in the table..
         | 
| 226 | 
            +
                  # @param [Fixnum] ordinal A number indicating which matching table will have its index returned.
         | 
| 227 | 
            +
                  # @return [Fixnum] the index of the table containing *strg*
         | 
| 228 | 
            +
                  def get_index_for_table_containing_text(browser, strg, ordinal = 1)
         | 
| 229 | 
            +
                    msg   = "Get index for table containing text '#{strg}'"
         | 
| 230 | 
            +
                    index = 0
         | 
| 231 | 
            +
                    found = 0
         | 
| 232 | 
            +
                    browser.tables.each do |t|
         | 
| 233 | 
            +
                      index += 1
         | 
| 234 | 
            +
                      if t.text =~ /#{strg}/
         | 
| 235 | 
            +
                        found += 1
         | 
| 236 | 
            +
                        if ordinal > 0 and found == ordinal
         | 
| 237 | 
            +
                          break
         | 
| 238 | 
            +
                        end
         | 
| 239 | 
            +
                      end
         | 
| 240 | 
            +
                    end
         | 
| 241 | 
            +
                    if found
         | 
| 242 | 
            +
                      passed_to_log("#{msg}: #{index}")
         | 
| 243 | 
            +
                      index
         | 
| 244 | 
            +
                    else
         | 
| 245 | 
            +
                      passed_to_log("#{msg}.")
         | 
| 246 | 
            +
                      nil
         | 
| 247 | 
            +
                    end
         | 
| 248 | 
            +
                  rescue
         | 
| 249 | 
            +
                    failed_to_log("Unable to find index of table containing text '#{strg}' '#{$!}' ")
         | 
| 250 | 
            +
                  end
         | 
| 251 | 
            +
             | 
| 252 | 
            +
                  # Return a reference to a table in *browser* containing *strg*.  *ordinal* indicates
         | 
| 253 | 
            +
                  # whether it is the first, second, third, etc. table found with the matching text in *strg*
         | 
| 254 | 
            +
                  # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
         | 
| 255 | 
            +
                  # @param [String, Regexp] strg A string or regular expression to search for in the table..
         | 
| 256 | 
            +
                  # @param [Fixnum] ordinal A number indicating which matching table will have its index returned.
         | 
| 257 | 
            +
                  # @return [Watir::Table] the table containing *strg*
         | 
| 258 | 
            +
                  def get_table_containing_text(browser, strg, ordinal = 1)
         | 
| 259 | 
            +
                    msg   = "Get table #{ordinal} containing text '#{strg}'"
         | 
| 260 | 
            +
                    index = get_index_for_table_containing_text(browser, strg, ordinal)
         | 
| 261 | 
            +
                    if index
         | 
| 262 | 
            +
                      passed_to_log(msg)
         | 
| 263 | 
            +
                      browser.tables[index]
         | 
| 264 | 
            +
                    else
         | 
| 265 | 
            +
                      failed_to_log(msg)
         | 
| 266 | 
            +
                      nil
         | 
| 267 | 
            +
                    end
         | 
| 268 | 
            +
                  rescue
         | 
| 269 | 
            +
                    failed_to_log("Unable to find index of table containing text '#{strg}' '#{$!}' ")
         | 
| 270 | 
            +
                  end
         | 
| 271 | 
            +
             | 
| 272 | 
            +
                  def get_cell_text_from_row_with_string(nc_element, table_index, column_index, strg)
         | 
| 273 | 
            +
                    rgx  = Regexp.new(strg)
         | 
| 274 | 
            +
                    text = ''
         | 
| 275 | 
            +
                    debug_to_log("strg:'#{strg}', rgx:'#{rgx}', table_index:'#{table_index}', column_index:'#{column_index}'")
         | 
| 276 | 
            +
                    nc_element.tables[table_index].each do |row|
         | 
| 277 | 
            +
                      cell_count = get_cell_count(row)
         | 
| 278 | 
            +
                      if cell_count >= column_index
         | 
| 279 | 
            +
                        #TODO this assumes column 1 is a number column
         | 
| 280 | 
            +
                        #        debug_to_log("row:'#{row.cells}'")
         | 
| 281 | 
            +
                        cell_1 = row[1].text
         | 
| 282 | 
            +
                        if cell_1 =~ /\d+/
         | 
| 283 | 
            +
                          row_text = row.text
         | 
| 284 | 
            +
                          if row_text =~ rgx
         | 
| 285 | 
            +
                            text = row[column_index].text
         | 
| 286 | 
            +
                            break
         | 
| 287 | 
            +
                          end
         | 
| 288 | 
            +
                        end
         | 
| 289 | 
            +
                      end
         | 
| 290 | 
            +
                    end
         | 
| 291 | 
            +
                    text
         | 
| 292 | 
            +
                  end
         | 
| 293 | 
            +
             | 
| 294 | 
            +
                  # Return a hash containing a cross reference of the header names and indexes (columns) for the specified table.
         | 
| 295 | 
            +
                  # @example
         | 
| 296 | 
            +
                  #   (need example and usage)
         | 
| 297 | 
            +
                  # @param [Watir::Table] table A reference to the table.
         | 
| 298 | 
            +
                  # @param [Fixnum] header_index The index of the row containing the header names.
         | 
| 299 | 
            +
                  # @return [Hash] Two level hash of hashes. Internal hashes are 'name' which allows look-up of a column index
         | 
| 300 | 
            +
                  # by the header name, and 'index' which allows look-up of the name by the column index.
         | 
| 301 | 
            +
                  def get_table_headers(table, header_index = 1)
         | 
| 302 | 
            +
                    headers          = Hash.new
         | 
| 303 | 
            +
                    headers['index'] = Hash.new
         | 
| 304 | 
            +
                    headers['name']  = Hash.new
         | 
| 305 | 
            +
                    count            = 1
         | 
| 306 | 
            +
                    table[header_index].each do |cell|
         | 
| 307 | 
            +
                      if cell.text.length > 0
         | 
| 308 | 
            +
                        name                    = cell.text.gsub(/\s+/, ' ')
         | 
| 309 | 
            +
                        headers['index'][count] = name
         | 
| 310 | 
            +
                        headers['name'][name]   = count
         | 
| 311 | 
            +
                      end
         | 
| 312 | 
            +
                      count += 1
         | 
| 313 | 
            +
                    end
         | 
| 314 | 
            +
                    #debug_to_log("#{__method__}: headers:\n#{headers.to_yaml}")
         | 
| 315 | 
            +
                    headers
         | 
| 316 | 
            +
                  rescue
         | 
| 317 | 
            +
                    failed_to_log("Unable to get content headers. '#{$!}'")
         | 
| 318 | 
            +
                  end
         | 
| 319 | 
            +
             | 
| 320 | 
            +
                  # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
         | 
| 321 | 
            +
                  def count_rows_with_string(browser, table_index, strg)
         | 
| 322 | 
            +
                    hit = 0
         | 
| 323 | 
            +
                    browser.tables[table_index].each do |row|
         | 
| 324 | 
            +
                      if get_cell_count(row) >= 1
         | 
| 325 | 
            +
                        #        debug_to_log("#{__method__}: #{row.text}")
         | 
| 326 | 
            +
                        #TODO this assumes column 1 is a number column
         | 
| 327 | 
            +
                        if row[1].text =~ /\d+/
         | 
| 328 | 
            +
                          if row.text =~ /#{strg}/i
         | 
| 329 | 
            +
                            hit += 1
         | 
| 330 | 
            +
                            debug_to_log("#{__method__}: #{row.text}")
         | 
| 331 | 
            +
                          end
         | 
| 332 | 
            +
                        end
         | 
| 333 | 
            +
                      end
         | 
| 334 | 
            +
                    end
         | 
| 335 | 
            +
                    debug_to_log("#{__method__}: hit row count: #{hit}")
         | 
| 336 | 
            +
                    hit
         | 
| 337 | 
            +
                  end
         | 
| 338 | 
            +
             | 
| 339 | 
            +
                  def fetch_array_for_table_column(table, column_index, start_row = 2)
         | 
| 340 | 
            +
                    ary       = []
         | 
| 341 | 
            +
                    row_count = 0
         | 
| 342 | 
            +
                    table.each do |row|
         | 
| 343 | 
            +
                      row_count += 1
         | 
| 344 | 
            +
                      if get_cell_count(row) >= column_index
         | 
| 345 | 
            +
                        if row_count >= start_row
         | 
| 346 | 
            +
                          ary << row[column_index].text
         | 
| 347 | 
            +
                        end
         | 
| 348 | 
            +
                      end
         | 
| 349 | 
            +
                    end
         | 
| 350 | 
            +
                    ary
         | 
| 351 | 
            +
                  end
         | 
| 352 | 
            +
             | 
| 353 | 
            +
                  def fetch_hash_for_table_column(table, column_index, start_row = 2)
         | 
| 354 | 
            +
                    hash      = Hash.new
         | 
| 355 | 
            +
                    row_count = 0
         | 
| 356 | 
            +
                    table.each do |row|
         | 
| 357 | 
            +
                      row_count += 1
         | 
| 358 | 
            +
                      if get_cell_count(row) >= column_index
         | 
| 359 | 
            +
                        if row_count >= start_row
         | 
| 360 | 
            +
                          hash[row_count] = row[column_index].text
         | 
| 361 | 
            +
                        end
         | 
| 362 | 
            +
                      end
         | 
| 363 | 
            +
                    end
         | 
| 364 | 
            +
                    hash
         | 
| 365 | 
            +
                  end
         | 
| 366 | 
            +
             | 
| 367 | 
            +
                  def get_row_cells_text_as_array(row)
         | 
| 368 | 
            +
                    ary = []
         | 
| 369 | 
            +
                    row.each do |cell|
         | 
| 370 | 
            +
                      ary << cell.text
         | 
| 371 | 
            +
                    end
         | 
| 372 | 
            +
                    ary
         | 
| 373 | 
            +
                  end
         | 
| 374 | 
            +
             | 
| 375 | 
            +
                  def count_data_rows(container, data_index, column_index)
         | 
| 376 | 
            +
                    cnt   = 0
         | 
| 377 | 
            +
                    #  get_objects(container, :tables, true)
         | 
| 378 | 
            +
                    table = container.tables[data_index]
         | 
| 379 | 
            +
                    dump_table_and_rows(table)
         | 
| 380 | 
            +
                    if table
         | 
| 381 | 
            +
                      table.rows.each do |row|
         | 
| 382 | 
            +
                        if get_cell_count(row) >= column_index
         | 
| 383 | 
            +
                          #TODO this assumes column 1 is a number column
         | 
| 384 | 
            +
                          if row[column_index].text =~ /\d+/
         | 
| 385 | 
            +
                            cnt += 1
         | 
| 386 | 
            +
                          end
         | 
| 387 | 
            +
                        end
         | 
| 388 | 
            +
                      end
         | 
| 389 | 
            +
                    end
         | 
| 390 | 
            +
                    sleep_for(2)
         | 
| 391 | 
            +
                    cnt
         | 
| 392 | 
            +
                  end
         | 
| 393 | 
            +
             | 
| 394 | 
            +
                  def get_cell_count(row)
         | 
| 395 | 
            +
                    if $watir_script
         | 
| 396 | 
            +
                      row.column_count
         | 
| 397 | 
            +
                    else
         | 
| 398 | 
            +
                      row.cells.length
         | 
| 399 | 
            +
                    end
         | 
| 400 | 
            +
                  end
         | 
| 401 | 
            +
             | 
| 402 | 
            +
                  def exercise_sorting(browser, columnList, desc = '')
         | 
| 403 | 
            +
                    #TODO put rescue inside the do loop
         | 
| 404 | 
            +
                    #parameters: browser and a list of column link text values
         | 
| 405 | 
            +
                    #example: exercise_sorting(browser,['Division', 'Payee', 'Date'], 'Sortable columns on this page')
         | 
| 406 | 
            +
                    columnList.each do |column|
         | 
| 407 | 
            +
                      click(browser, :link, :text, column, desc)
         | 
| 408 | 
            +
                    end
         | 
| 409 | 
            +
                  end
         | 
| 410 | 
            +
             | 
| 411 | 
            +
                  alias validate_sorting exercise_sorting
         | 
| 412 | 
            +
             | 
| 413 | 
            +
                  def verify_column_sort(browser, nc_element, strg, table_index, column_index=nil)
         | 
| 414 | 
            +
                    mark_testlevel("Verify Column Sort '#{strg}'", 3)
         | 
| 415 | 
            +
                    if not column_index
         | 
| 416 | 
            +
                      column_index = get_index_for_column_head(nc_element, table_index, strg)
         | 
| 417 | 
            +
                    end
         | 
| 418 | 
            +
             | 
| 419 | 
            +
                    if column_index
         | 
| 420 | 
            +
                      bfr_ary = fetch_array_for_table_column(nc_element, table_index, column_index)
         | 
| 421 | 
            +
                      if strg =~ /date/i
         | 
| 422 | 
            +
                        exp_ary = bfr_ary.sort { |x, y| Date.parse(x) <=> Date.parse(y) }
         | 
| 423 | 
            +
                      else
         | 
| 424 | 
            +
                        exp_ary = bfr_ary.sort { |x, y| x.gsub(',', '') <=> y.gsub(',', '') }
         | 
| 425 | 
            +
                      end
         | 
| 426 | 
            +
             | 
| 427 | 
            +
                      if click_text(browser, strg)
         | 
| 428 | 
            +
                        if column_index
         | 
| 429 | 
            +
                          sleep_for(2.5)
         | 
| 430 | 
            +
                        else
         | 
| 431 | 
            +
                          sleep_for(1)
         | 
| 432 | 
            +
                        end
         | 
| 433 | 
            +
                        act_ary = fetch_array_for_table_column(nc_element, table_index, column_index)
         | 
| 434 | 
            +
             | 
| 435 | 
            +
                        if exp_ary == act_ary
         | 
| 436 | 
            +
                          passed_to_log("Click on column '#{strg}' produces expected sorted list.")
         | 
| 437 | 
            +
                          true
         | 
| 438 | 
            +
                        else
         | 
| 439 | 
            +
                          failed_to_log("Click on column '#{strg}' fails to produce expected sorted list.")
         | 
| 440 | 
            +
                          debug_to_log("Original order ['#{bfr_ary.join("', '")}']")
         | 
| 441 | 
            +
                          debug_to_log("Expected order ['#{exp_ary.join("', '")}']")
         | 
| 442 | 
            +
                          debug_to_log("  Actual order ['#{act_ary.join("', '")}']")
         | 
| 443 | 
            +
                        end
         | 
| 444 | 
            +
                      end
         | 
| 445 | 
            +
                    else
         | 
| 446 | 
            +
                      failed_to_log("Unable to locate column index for '#{strg}' to verify sort.")
         | 
| 447 | 
            +
                    end
         | 
| 448 | 
            +
                  rescue
         | 
| 449 | 
            +
                    failed_to_log("Unable to verify sort on column '#{strg}'. #{$!}")
         | 
| 450 | 
            +
                  end
         | 
| 451 | 
            +
             | 
| 452 | 
            +
                  def verify_column_sort_temp_ff(browser, strg, table_index, column_index=nil)
         | 
| 453 | 
            +
                    mark_testlevel("Verify Column Sort '#{strg}'", 3)
         | 
| 454 | 
            +
             | 
| 455 | 
            +
                    if not column_index
         | 
| 456 | 
            +
                      column_index = get_index_for_column_head(browser, table_index, strg)
         | 
| 457 | 
            +
                    end
         | 
| 458 | 
            +
             | 
| 459 | 
            +
                    if column_index
         | 
| 460 | 
            +
                      bfr_ary = fetch_array_for_table_column(browser, table_index, column_index)
         | 
| 461 | 
            +
                      if strg =~ /date/i
         | 
| 462 | 
            +
                        exp_ary = bfr_ary.sort { |x, y| Date.parse(x) <=> Date.parse(y) }
         | 
| 463 | 
            +
                      else
         | 
| 464 | 
            +
                        exp_ary = bfr_ary.sort { |x, y| x.gsub(',', '') <=> y.gsub(',', '') }
         | 
| 465 | 
            +
                      end
         | 
| 466 | 
            +
             | 
| 467 | 
            +
                      if click_text(browser, strg)
         | 
| 468 | 
            +
                        sleep_for(3)
         | 
| 469 | 
            +
                        act_ary = fetch_array_for_table_column(browser, table_index, column_index)
         | 
| 470 | 
            +
             | 
| 471 | 
            +
                        if exp_ary == act_ary
         | 
| 472 | 
            +
                          passed_to_log("Click on column '#{strg}' produces expected sorted list.")
         | 
| 473 | 
            +
                          true
         | 
| 474 | 
            +
                        else
         | 
| 475 | 
            +
                          failed_to_log("Click on column '#{strg}' fails to produce expected sorted list.")
         | 
| 476 | 
            +
                          debug_to_log("Original order ['#{bfr_ary.join("', '")}']")
         | 
| 477 | 
            +
                          debug_to_log("Expected order ['#{exp_ary.join("', '")}']")
         | 
| 478 | 
            +
                          debug_to_log("  Actual order ['#{act_ary.join("', '")}']")
         | 
| 479 | 
            +
                        end
         | 
| 480 | 
            +
                      end
         | 
| 481 | 
            +
                    else
         | 
| 482 | 
            +
                      failed_to_log("Unable to locate column index for '#{strg}' to verify sort.")
         | 
| 483 | 
            +
                    end
         | 
| 484 | 
            +
                  rescue
         | 
| 485 | 
            +
                    failed_to_log("Unable to verify sort on column '#{strg}'. #{$!}")
         | 
| 486 | 
            +
                  end
         | 
| 487 | 
            +
             | 
| 488 | 
            +
                  # @todo unstub
         | 
| 489 | 
            +
                  # @private
         | 
| 490 | 
            +
                  def verify_column_hidden(browser, panel, table_index, column_name)
         | 
| 491 | 
            +
                    passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
         | 
| 492 | 
            +
                    return true
         | 
| 493 | 
            +
                    #    id = @column_data_display_ids[column_name]
         | 
| 494 | 
            +
                    #    ok = false
         | 
| 495 | 
            +
             | 
| 496 | 
            +
                    #    row = panel.tables[2][3]
         | 
| 497 | 
            +
             | 
| 498 | 
            +
                    #    row.each do |cell|
         | 
| 499 | 
            +
                    ##      strg = cell.to_s
         | 
| 500 | 
            +
                    ##      insp = cell.inspect
         | 
| 501 | 
            +
                    ##      ole  = cell.ole_object
         | 
| 502 | 
            +
                    ##      anId = cell.attribute_value(:id)
         | 
| 503 | 
            +
                    #      text = cell.text
         | 
| 504 | 
            +
                    #      if text =~ /#{id}/
         | 
| 505 | 
            +
                    #        if cell.to_s =~ /hidden/
         | 
| 506 | 
            +
                    #          passed_to_log( "Column '#{column_name}' is hidden.")
         | 
| 507 | 
            +
                    #        else
         | 
| 508 | 
            +
                    #          failed_to_log( "Column '#{column_name}' is not hidden.")
         | 
| 509 | 
            +
                    #        end
         | 
| 510 | 
            +
                    #        ok = true
         | 
| 511 | 
            +
                    #      end
         | 
| 512 | 
            +
                    #    end
         | 
| 513 | 
            +
                    #    if not ok
         | 
| 514 | 
            +
                    #      failed_to_log( "Column '#{column_name}' not found.")
         | 
| 515 | 
            +
                    #    end
         | 
| 516 | 
            +
                    #  rescue
         | 
| 517 | 
            +
                    #    failed_to_log("Unable to verify column '#{column_name}' is hidden: '#{$!}' (#{__LINE__})")
         | 
| 518 | 
            +
                  end
         | 
| 519 | 
            +
             | 
| 520 | 
            +
                  # @todo unstub
         | 
| 521 | 
            +
                  # @private
         | 
| 522 | 
            +
                  def verify_column_hidden_temp_ff(browser, data_index, row_index, column_name)
         | 
| 523 | 
            +
                    passed_to_log("TEST STUBBED: Column '#{column_name}' is hidden.")
         | 
| 524 | 
            +
                    return true
         | 
| 525 | 
            +
             | 
| 526 | 
            +
                    row     = browser.tables[data_index][row_index]
         | 
| 527 | 
            +
                    #    debug_to_log( "#{row.to_a}")
         | 
| 528 | 
            +
                    #TODO cells are all still there in the row.  Need to check for clue to hidden/visible in other tag attributes
         | 
| 529 | 
            +
                    act_ary = get_row_cells_text_as_array(row)
         | 
| 530 | 
            +
             | 
| 531 | 
            +
                    if not act_ary.include?(column_name)
         | 
| 532 | 
            +
                      passed_to_log("Column '#{column_name}' is hidden.")
         | 
| 533 | 
            +
                    else
         | 
| 534 | 
            +
                      failed_to_log("Column '#{column_name}' is not hidden.")
         | 
| 535 | 
            +
                    end
         | 
| 536 | 
            +
                  end
         | 
| 537 | 
            +
             | 
| 538 | 
            +
                  # @todo unstub
         | 
| 539 | 
            +
                  # @private
         | 
| 540 | 
            +
                  def verify_column_visible_temp_ff(browser, data_index, row_index, column_name)
         | 
| 541 | 
            +
                    passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
         | 
| 542 | 
            +
                    return true
         | 
| 543 | 
            +
             | 
| 544 | 
            +
                    row     = browser.tables[data_index][row_index]
         | 
| 545 | 
            +
                    #TODO cells are all still there in the row.  Need to check for clue to hidden/visible in other tag attributes
         | 
| 546 | 
            +
                    act_ary = get_row_cells_text_as_array(row)
         | 
| 547 | 
            +
             | 
| 548 | 
            +
                    if act_ary.include?(column_name)
         | 
| 549 | 
            +
                      passed_to_log("Column '#{column_name}' is visible.")
         | 
| 550 | 
            +
                    else
         | 
| 551 | 
            +
                      failed_to_log("Column '#{column_name}' is not visible.")
         | 
| 552 | 
            +
                    end
         | 
| 553 | 
            +
                  end
         | 
| 554 | 
            +
             | 
| 555 | 
            +
                  # @todo unstub
         | 
| 556 | 
            +
                  # @private
         | 
| 557 | 
            +
                  def verify_column_visible(browser, panel, table_index, column_name)
         | 
| 558 | 
            +
             | 
| 559 | 
            +
                    passed_to_log("TEST STUBBED: Column '#{column_name}' is visible.")
         | 
| 560 | 
            +
                    return true
         | 
| 561 | 
            +
             | 
| 562 | 
            +
                      #    id = @column_data_display_ids[column_name]
         | 
| 563 | 
            +
                      #    ok  = false
         | 
| 564 | 
            +
                      #    row = panel.tables[table_index][1]
         | 
| 565 | 
            +
                      #    row.each do |cell|
         | 
| 566 | 
            +
                      #      if cell.id == id
         | 
| 567 | 
            +
                      #        if not cell.to_s =~ /hidden/
         | 
| 568 | 
            +
                      #          passed_to_log("Column '#{column_name}' is visible.")
         | 
| 569 | 
            +
                      #        else
         | 
| 570 | 
            +
                      #          failed_to_log("Column '#{column_name}' is not visible.")
         | 
| 571 | 
            +
                      #        end
         | 
| 572 | 
            +
                      #        ok = true
         | 
| 573 | 
            +
                      #      end
         | 
| 574 | 
            +
                      #    end
         | 
| 575 | 
            +
                      #    if not ok
         | 
| 576 | 
            +
                      #      failed_to_log("Column '#{column_name}' not found.")
         | 
| 577 | 
            +
                      #    end
         | 
| 578 | 
            +
                  rescue
         | 
| 579 | 
            +
                    failed_to_log("Unable to verify column '#{column_name} is visible': '#{$!}' (#{__LINE__})")
         | 
| 580 | 
            +
                  end
         | 
| 581 | 
            +
             | 
| 582 | 
            +
                  # Verify that a table's columns are in the expected order by header names. The table is identified by its *index*
         | 
| 583 | 
            +
                  # within the container *browser*.
         | 
| 584 | 
            +
                  # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
         | 
| 585 | 
            +
                  def verify_column_order(browser, table_index, header_index, exp_ary)
         | 
| 586 | 
            +
                    mark_testlevel("Begin #{__method__.to_s.titleize}", 0)
         | 
| 587 | 
            +
                    row     = browser.tables[table_index][header_index]
         | 
| 588 | 
            +
                    act_ary = get_row_cells_text_as_array(row)
         | 
| 589 | 
            +
             | 
| 590 | 
            +
                    if exp_ary == act_ary
         | 
| 591 | 
            +
                      passed_to_log("Column order [#{act_ary.join(', ')}] appeared as expected.")
         | 
| 592 | 
            +
                    else
         | 
| 593 | 
            +
                      failed_to_log("Column order [#{act_ary.join(', ')}] not as expected [#{exp_ary.join(', ')}].")
         | 
| 594 | 
            +
                    end
         | 
| 595 | 
            +
                    mark_testlevel("End #{__method__.to_s.titleize}", 0)
         | 
| 596 | 
            +
                  end
         | 
| 597 | 
            +
             | 
| 598 | 
            +
                  def text_in_table?(browser, how, what, expected, desc = '')
         | 
| 599 | 
            +
                    msg = build_message("Table :#{how}=>#{what} contains '#{expected}.", desc)
         | 
| 600 | 
            +
                    if browser.table(how, what).text =~ expected
         | 
| 601 | 
            +
                      passed_to_log(msg)
         | 
| 602 | 
            +
                      true
         | 
| 603 | 
            +
                    else
         | 
| 604 | 
            +
                      failed_to_log(msg)
         | 
| 605 | 
            +
                    end
         | 
| 606 | 
            +
                  rescue
         | 
| 607 | 
            +
                    failed_to_log("Unable to verify that #{msg}': '#{$!}'")
         | 
| 608 | 
            +
                  end
         | 
| 609 | 
            +
             | 
| 610 | 
            +
                  def text_in_table_row_with_text?(table, text, target, desc = '')
         | 
| 611 | 
            +
                    #TODO This needs clarification, renaming
         | 
| 612 | 
            +
                    msg   = build_message("Table :id=>#{table.id} row with text '#{text} also contains '#{target}.", desc)
         | 
| 613 | 
            +
                    index = get_index_of_row_with_text(table, text)
         | 
| 614 | 
            +
                    if table[index].text =~ target
         | 
| 615 | 
            +
                      passed_to_log(msg)
         | 
| 616 | 
            +
                      true
         | 
| 617 | 
            +
                    else
         | 
| 618 | 
            +
                      failed_to_log(msg)
         | 
| 619 | 
            +
                    end
         | 
| 620 | 
            +
                  end
         | 
| 621 | 
            +
             | 
| 622 | 
            +
                  alias verify_text_in_table_with_text text_in_table_row_with_text?
         | 
| 623 | 
            +
             | 
| 624 | 
            +
                end
         | 
| 625 | 
            +
              end
         | 
| 626 | 
            +
            end
         | 
| 627 | 
            +
             |