Tuesday, September 21, 2010

Adding support for html elements in WATIR

Any HTML element or tag can be to WATIR framework by updating non_control_elements.rb in watir framework.

1. Go to C:\ruby\lib\ruby\gems\1.8\gems\watir-1.6.5\lib\watir
2. Open non_control_elements.rb and add tags which are not there in the list and you wish to validate

class Ul < NonControlElement
    TAG = 'UL'
  end
  class H1 < NonControlElement
    TAG = 'H1'
  end
  class H2 < NonControlElement
    TAG = 'H2'
  end
class LEGEND < NonControlElement
    TAG = 'LEGEND'
  end
  class TH < NonControlElement
    TAG = 'TH'
  end

This can be then used to validate any text/links/listboxes etc on the html page.

No comments:

Post a Comment