title: Watir, looking for a more elegant solution for HTML element checking
body: <p>I'm looking for a more elegant solution to check that a range of HTML elements are visible in the browser.</p>
  
  <p>I had the idea of creating a CSV file with element type and IDs, reading it into an array and using that to check the elements are present in the browser.</p>
  
  <p>So the CSV file/array would look something like this,</p>
  
  <pre><code>"select","srch-op-select"
  "text_field","srch-filter"
  "button","srch-button"
  "image","srch-showhide-icon"
  "div","srch-showhide"
  </code></pre>
  
  <p>I then thought I could use case statement to do the checking, something like this,</p>
  
  <pre><code>        myElements.each do |row|
          type = row[0]
          id = row[1]
          case type
            when "button"   : assert(browser.button(:id,id).exists?)
            when "checkbox" : assert(browser.checkbox(:id,id).exists?)
            when "div"      : assert(browser.div(:id,id).exists?)
            when "image"    : assert(browser.image(:id,id).exists?)
            when "label"    : assert(browser.label(:id,id).exists?)
            when "link"     : assert(browser.link(:id,id).exists?)
            when "radio"    : assert(browser.radio(:id,id).exists?)
            when "select"   : assert(browser.select_list(:id,id).exists?)
            when "span"     : assert(browser.span(:id,id).exists?)
            when "table"    : assert(browser.table(:id,id).exists?)
            else $log.debug "---Unsupported element type "+type
          end
      end
  </code></pre>
  
  <p>Obviously this case statement would be come large and unwieldy if you wanted to cover all supported element types or factor in the different methods of selecting a HTML element.</p>
  
  <p>Can anyone suggest a more elegant and flexible solution? </p>