Module: Watir::EventuallyPresent
Overview
Convenience methods for things that eventually become present.
Includers should implement a public #present? and a (possibly private) #selector_string method.
Instance Method Summary collapse
-
#wait_until_present(timeout = nil) ⇒ Object
Waits until the element is present.
-
#wait_while_present(timeout = nil) ⇒ Object
Waits while the element is present.
-
#when_enabled(timeout = nil) ⇒ Object
Waits until the element is enabled.
-
#when_present(timeout = nil) ⇒ Object
Waits until the element is present.
Instance Method Details
#wait_until_present(timeout = nil) ⇒ Object
Waits until the element is present.
220 221 222 223 224 |
# File 'lib/watir-webdriver/wait.rb', line 220 def wait_until_present(timeout = nil) timeout ||= Watir.default_timeout = "waiting for #{selector_string} to become present" Watir::Wait.until(timeout, ) { present? } end |
#wait_while_present(timeout = nil) ⇒ Object
Waits while the element is present.
238 239 240 241 242 243 244 |
# File 'lib/watir-webdriver/wait.rb', line 238 def wait_while_present(timeout = nil) timeout ||= Watir.default_timeout = "waiting for #{selector_string} to disappear" Watir::Wait.while(timeout, ) { present? } rescue Selenium::WebDriver::Error::StaleElementReferenceError # it's not present end |
#when_enabled(timeout = nil) ⇒ Object
Waits until the element is enabled.
196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/watir-webdriver/wait.rb', line 196 def when_enabled(timeout = nil) timeout ||= Watir.default_timeout = "waiting for #{selector_string} to become enabled" if block_given? Watir::Wait.until(timeout, ) { enabled? } yield self else WhenEnabledDecorator.new(self, timeout, ) end end |
#when_present(timeout = nil) ⇒ Object
Waits until the element is present.
172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/watir-webdriver/wait.rb', line 172 def when_present(timeout = nil) timeout ||= Watir.default_timeout = "waiting for #{selector_string} to become present" if block_given? Watir::Wait.until(timeout, ) { present? } yield self else WhenPresentDecorator.new(self, timeout, ) end end |