Sha256: b909afad31ef53b43dc7a4a4adf75bd8728996cfc8b7b79158023098668629ac

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

module Symbiont
  module WebObjects
    
    # This class is designed to provide methods for functionality that is
    # common to all web objects and that may need to be called directly
    # on a web object (as opposed to a web object wrapped up by the
    # platform).
    
    class WebObject
      def initialize(web_object)
        @web_object = web_object
      end
      
      def enabled?
        @web_object.enabled?
      end
      
      def disabled?
        not enabled?
      end
      
      def exists?
        @web_object.exists?
      end
      
      def visible?
        @web_object.visible?
      end
      
      def text
        @web_object.text
      end
      
      def click
        @web_object.click
      end
      
      def attribute(name)
        @web_object.attribute_value(name)
      end
      
      def style(property)
        @web_object.style(property)
      end
      
      def when_actionable(timeout=5)
        @web_object.wait_until_present(timeout)
        self
      end
      
      alias :when_present :when_actionable
      
      def when_visible(timeout=5)
        Object::Watir::Wait.until(timeout, "object not visible within #{timeout} seconds.") do
          visible?
        end
        self
      end
      
      def when_not_visible(timeout=5)
        Object::Watir::Wait.while(timeout, "object still visible after #{timeout} seconds.") do
          visible?
        end
        self
      end
      
      alias :must_be_visible :when_visible
      alias :must_not_be_visible :when_not_visible
      
      def wait_until(timeout, message=nil, &block)
        Object::Watir::Wait.until(timeout, message, &block)
      end
    end # class: WebObject

  end # module: WebObjects
end # module: Symbiont

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
symbiont-0.1.2 lib/symbiont/web_objects/_common.rb
symbiont-0.1.1 lib/symbiont/web_objects/_common.rb