Class: Watir::WhenPresentDecorator

Inherits:
Object
  • Object
show all
Defined in:
lib/watir-webdriver/wait.rb

Overview

Wraps an Element so that any subsequent method calls are put on hold until the element is present (exists and is visible) on the page.

Instance Method Summary collapse

Constructor Details

#initialize(element, timeout, message = nil) ⇒ WhenPresentDecorator

Returns a new instance of WhenPresentDecorator.



83
84
85
86
87
# File 'lib/watir-webdriver/wait.rb', line 83

def initialize(element, timeout, message = nil)
  @element = element
  @timeout = timeout
  @message = message
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



93
94
95
96
97
98
99
100
101
# File 'lib/watir-webdriver/wait.rb', line 93

def method_missing(m, *args, &block)
  unless @element.respond_to?(m)
    raise NoMethodError, "undefined method `#{m}' for #{@element.inspect}:#{@element.class}"
  end

  Watir::Wait.until(@timeout, @message) { @element.present? }

  @element.__send__(m, *args, &block)
end

Instance Method Details

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/watir-webdriver/wait.rb', line 89

def respond_to?(*args)
  @element.respond_to?(*args)
end