class RAutomation::Button

Public Class Methods

new(window, locators) click to toggle source

@private This constructor is meant to be accessed only through {Window#button} method.

# File lib/rautomation/button.rb, line 5
def initialize(window, locators)
  @window = window
  @locators = locators
  @button = @window.button(@locators)
end

Public Instance Methods

click() { |self| ... } click to toggle source

Performs a click on the button. By default click is considered successful if the button doesn't exist after clicking (e.g. window has closed) @yield [button] optional block specifying successful clicking condition. @yieldparam [Button] button which is being clicked on. @yieldreturn [Boolean] true if clicking on the button is successful, false otherwise. @raise [UnknownButtonException] if the button doesn't exist.

# File lib/rautomation/button.rb, line 17
def click
  wait_until_exists
  if block_given?
    @button.click {yield self}
  else
    @button.click
  end
end
exist?()
Alias for: exists?
exists?() click to toggle source

Checks if the button exists. @return [Boolean] true if button exists, false otherwise.

# File lib/rautomation/button.rb, line 36
def exists?
  @button.exists?
end
Also aliased as: exist?
method_missing(name, *args) click to toggle source

Allows to execute specific {Adapter} methods not part of the public API.

# File lib/rautomation/button.rb, line 43
def method_missing(name, *args)
  @button.send(name, *args)
end
value() click to toggle source

Retrieves the value (text) of the button, usually the visible text. @return [String] the value (text) of the button. @raise [UnknownButtonException] if the button doesn't exist.

# File lib/rautomation/button.rb, line 29
def value
  wait_until_exists
  @button.value
end

Private Instance Methods

wait_until_exists() click to toggle source
# File lib/rautomation/button.rb, line 49
def wait_until_exists
  WaitHelper.wait_until {exists?}
rescue WaitHelper::TimeoutError
  raise UnknownButtonException, "Button #{@locators.inspect} doesn't exist on window #{@window.locators.inspect}!"
end