Module: Appium::Core::Waitable

Included in:
Base::Driver, Driver
Defined in:
lib/appium_lib_core/common/wait.rb

Overview

module Wait

Instance Method Summary collapse

Instance Method Details

#wait_until(timeout: nil, interval: nil, message: nil, ignored: nil, &block) ⇒ Object Also known as: wait

Check every interval seconds to see if yield doesn’t raise an exception. Give up after timeout seconds.

If only a number is provided then it’s treated as the timeout value.

Examples:

With core instance


@core.wait { @driver.find_element :accessibility_id, 'something' }
@core.wait(timeout: 30, interval: 2) { @driver.find_element :accessibility_id, 'something' }

@core.wait_until { @driver.find_element :accessibility_id, 'something' }
@core.wait_until(timeout: 30, interval: 2) { @driver.find_element :accessibility_id, 'something' }

With driver instance


@driver.wait { @driver.find_element :accessibility_id, 'something' }
@driver.wait(timeout: 30, interval: 2) { @driver.find_element :accessibility_id, 'something' }

@driver.wait_until { |d| d.find_element :accessibility_id, 'something' }
@driver.wait_until(timeout: 30, interval: 2) { |d| d.find_element :accessibility_id, 'something' }

Parameters:

  • timeout (Integer) (defaults to: nil)

    Seconds to wait before timing out. Set default by appium_wait_timeout (30).

  • interval (Integer) (defaults to: nil)

    Seconds to sleep between polls. Set default by appium_wait_interval (0.5).

  • message (String) (defaults to: nil)

    Exception message if timed out.

  • ignored (Array, Exception) (defaults to: nil)

    Exceptions to ignore while polling (default: Exception)



192
193
194
195
196
197
198
199
# File 'lib/appium_lib_core/common/wait.rb', line 192

def wait_until(timeout: nil, interval: nil, message: nil, ignored: nil, &block)
  Wait.until(timeout: timeout || @wait_timeout,
             interval: interval || @wait_interval,
             message: message,
             ignored: ignored,
             object: self,
             &block)
end

#wait_until_true(timeout: nil, interval: nil, message: nil, ignored: nil, &block) ⇒ Object Also known as: wait_true

Check every interval seconds to see if yield returns a truthy value. Note this isn’t a strict boolean true, any truthy value is accepted. false and nil are considered failures. Give up after timeout seconds.

If only a number is provided then it’s treated as the timeout value.

Examples:

With core instance


@core.wait_true { @driver.find_element :accessibility_id, 'something' }
@core.wait_true(timeout: 30, interval: 2) { @driver.find_element :accessibility_id, 'something' }

@core.wait_until_true { @driver.find_element :accessibility_id, 'something' }
@core.wait_until_true(timeout: 30, interval: 2) { @driver.find_element :accessibility_id, 'something' }

With driver instance


@driver.wait_true { |d| d.find_element :accessibility_id, 'something' }
@driver.wait_true(timeout: 30, interval: 2) { |d| driver.find_element :accessibility_id, 'something' }

@driver.wait_until_true { |d| d.find_element :accessibility_id, 'something' }
@driver.wait_until_true(timeout: 30, interval: 2) { |d| driver.find_element :accessibility_id, 'something' }

Parameters:

  • timeout (Integer) (defaults to: nil)

    Seconds to wait before timing out. Set default by appium_wait_timeout (30).

  • interval (Integer) (defaults to: nil)

    Seconds to sleep between polls. Set default by appium_wait_interval (0.5).

  • message (String) (defaults to: nil)

    Exception message if timed out.

  • ignored (Array, Exception) (defaults to: nil)

    Exceptions to ignore while polling (default: Exception)



156
157
158
159
160
161
162
163
# File 'lib/appium_lib_core/common/wait.rb', line 156

def wait_until_true(timeout: nil, interval: nil, message: nil, ignored: nil, &block)
  Wait.until_true(timeout: timeout || @wait_timeout,
                  interval: interval || @wait_interval,
                  message: message,
                  ignored: ignored,
                  object: self,
                  &block)
end