Module: YuiRestClient::Waitable

Included in:
YuiRestClient::Widgets::Base
Defined in:
lib/yui_rest_client/waitable.rb

Instance Method Summary collapse

Instance Method Details

#wait_until(timeout: YuiRestClient.timeout, interval: YuiRestClient.interval, message: nil, &block) ⇒ Waitable

Waits until the block evaluation will return true, raises Error::TimeoutError on timeout.

Examples:

Wait for checkbox to be checked

app.checkbox(id: 'test').wait_until(&:checked?)

Parameters:

  • timeout (Numeric) (defaults to: YuiRestClient.timeout)

    how long to wait (in seconds). Default is YuiRestClient.timeout.

  • interval (Numeric) (defaults to: YuiRestClient.interval)

    time in seconds between attempts. Default is YuiRestClient.interval.

  • message (String) (defaults to: nil)

    message to be sent in case timeout is reached.

Returns:

Raises:

  • Error::TimeoutError



13
14
15
16
17
18
19
20
# File 'lib/yui_rest_client/waitable.rb', line 13

def wait_until(timeout: YuiRestClient.timeout, interval: YuiRestClient.interval, message: nil, &block)
  @timeout = timeout
  @interval = interval
  Wait.until(timeout: timeout, interval: interval, message: message, object: self, &block)
  @timeout = YuiRestClient.timeout
  @interval = YuiRestClient.interval
  self
end

#wait_while(timeout: YuiRestClient.timeout, interval: YuiRestClient.interval, message: nil, &block) ⇒ Waitable

Waits while the block evaluation returns true, raises Error::TimeoutError on timeout.

Examples:

Wait for checkbox to be unchecked

app.checkbox(id: 'test').wait_while(&:checked?)

Parameters:

  • timeout (Numeric) (defaults to: YuiRestClient.timeout)

    how long to wait (in seconds). Default is YuiRestClient.timeout.

  • interval (Numeric) (defaults to: YuiRestClient.interval)

    time in seconds between attempts. Default is YuiRestClient.interval.

  • message (String) (defaults to: nil)

    message to be sent in case timeout is reached.

Returns:

Raises:

  • Error::TimeoutError



30
31
32
33
34
35
36
37
# File 'lib/yui_rest_client/waitable.rb', line 30

def wait_while(timeout: YuiRestClient.timeout, interval: YuiRestClient.interval, message: nil, &block)
  @timeout = timeout
  @interval = interval
  Wait.while(timeout: timeout, interval: interval, message: message, object: self, &block)
  @timeout = YuiRestClient.timeout
  @interval = YuiRestClient.interval
  self
end