Sha256: 771fe253707c53d7f7b531546dcc8b309b0d27024ca35f23a3a27fe30a24a4d1

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module RAutomation
  class Button
    # This constructor is meant to be accessed only through RAutomation::Window#button method.
    def initialize(window, locators) #:nodoc:
      @window = window
      @locators = locators
      @button = @window.button(@locators)
    end

    # Performs a click on the Button.
    #
    # Raises an UnknownButtonException if the Button itself doesn't exist.
    def click
      assert_exists
      @button.click
    end

    # Retrieves the value of the Button, usually the visible text.
    #
    # Raises an UnknownButtonException if the Button itself doesn't exist.
    def value
      assert_exists
      @button.value
    end

    # Returns true if Button exists, false otherwise.
    def exists?
      @button.exists?
    end

    alias_method :exist?, :exists?

    private

    def assert_exists
      raise UnknownButtonException.new("Button '#{@locators.inspect}' doesn't exist on window '#{@window.locators.inspect}'!") unless exists?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rautomation-0.0.3 lib/rautomation/button.rb
rautomation-0.0.2 lib/rautomation/button.rb
rautomation-0.0.1 lib/rautomation/button.rb