module Watir::EventuallyPresent
Convenience methods for things that eventually become present.
Includers should implement a public present? and a (possibly private) selector_string method.
Public Instance Methods
wait_until_present(timeout = nil)
click to toggle source
Waits until the element is present.
@example
browser.text_field(name: "new_user_first_name").wait_until_present
@param [Fixnum] timeout seconds to wait before timing out
@see Watir::Wait
@see Watir::Element#present?
# File lib/watir-webdriver/wait.rb, line 223 def wait_until_present(timeout = nil) timeout ||= Watir.default_timeout message = "waiting for #{selector_string} to become present" Watir::Wait.until(timeout, message) { present? } end
wait_while_present(timeout = nil)
click to toggle source
Waits while the element is present.
@example
browser.text_field(name: "abrakadbra").wait_while_present
@param [Fixnum] timeout seconds to wait before timing out
@see Watir::Wait
@see Watir::Element#present?
# File lib/watir-webdriver/wait.rb, line 241 def wait_while_present(timeout = nil) timeout ||= Watir.default_timeout message = "waiting for #{selector_string} to disappear" Watir::Wait.while(timeout, message) { present? } rescue Selenium::WebDriver::Error::StaleElementReferenceError # it's not present end
when_enabled(timeout = nil) { |self| ... }
click to toggle source
Waits until the element is enabled.
@example
browser.button(name: "new_user_button_2").when_enabled.click
@param [Fixnum] timeout seconds to wait before timing out
@see Watir::Wait
@see Watir::Element#enabled?
# File lib/watir-webdriver/wait.rb, line 199 def when_enabled(timeout = nil) timeout ||= Watir.default_timeout message = "waiting for #{selector_string} to become enabled" if block_given? Watir::Wait.until(timeout, message) { enabled? } yield self else WhenEnabledDecorator.new(self, timeout, message) end end
when_present(timeout = nil) { |self| ... }
click to toggle source
Waits until the element is present.
@example
browser.text_field(name: "new_user_first_name").when_present.click browser.text_field(name: "new_user_first_name").when_present { |field| field.set "Watir" } browser.text_field(name: "new_user_first_name").when_present(60).text
@param [Fixnum] timeout seconds to wait before timing out
@see Watir::Wait
@see Watir::Element#present?
# File lib/watir-webdriver/wait.rb, line 175 def when_present(timeout = nil) timeout ||= Watir.default_timeout message = "waiting for #{selector_string} to become present" if block_given? Watir::Wait.until(timeout, message) { present? } yield self else WhenPresentDecorator.new(self, timeout, message) end end