Ron made this helpful comment to a recent feature request:

Comment By: Ron Evans (greatbignoise)
Date: 2005-08-26 19:19

Message:
Try adding this code to the ObjectActions class:

        # This method checks to see if a control is visible or not
        #   raises: UnknownObjectException  if the object is not found
        def visible?
                object_exist_check
                return false if @o.style.visibility == "hidden"
                return true
        end


You can then use an assert like the following:
assert(@ie.text_field(:id, "Text2").visible?)

I just wanted to point out that one of the great things about Ruby is that you can implement suggestions like this without actually changing watir.rb. Thus:

  class ObjectActions
        def visible?
                object_exist_check
                return false if @o.style.visibility == "hidden"
                return true
        end
  end


You can load this code and add the feature right away. You don't have to patch watir.rb or wait for us to include it in a release. (If you look in watir.rb, you'll see that we actually add methods to the String and Regexp classes ourselves.)

This is one of the few features of Ruby that put it way ahead of what you can do in Python. The technical description of this feature is 'classes are always open.' (Actually you *can* freeze classes in Ruby, but i've never seen it done.)

(Also note that the ObjectActions class was renamed as Elements in 1.4)

Bret


_____________________
 Bret Pettichord
 www.pettichord.com

_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to