Method: Selenium#time_to_elements

Defined in:
lib/selenium/selenium.rb

#time_to_elements(attrs = {}) ⇒ Object

Public: Measures time to find any matching elements.

For any String criteria, a Regular Expression may be used by adding the 'regexp:' prefix.

name - String name of the element (default: nil). Corresponds to Android ‘resource-id’ and Ios ‘name’. text - String text of the element (default: nil). Corresponds to Android ‘text’ and Ios ‘value’. type - String type of the element (default: nil). Corresponds to element class/tag. description - String description of the element (default: nil).

Corresponds to Android 'content-desc' and Ios 'label'.

selector - String automation selector (default: nil). is_visible - Boolean indicating whether the element is visible (default: nil).

Corresponds to Ios 'visible'. Always true for Android.

is_on_screen - Boolean indicating whether any part of the element is within screen boundaries (default: nil). is_tappable - Boolean indicating whether the element may be tapped (default: nil).

Corresponds to Android 'clickable'. Android only.

is_password - Boolean indicating whether the element is a password field (default: nil).

Corresponds to Android 'password'. Android only.

is_enabled - Boolean indicating whether the element is enabled (default: nil).

Corresponds to Android and Ios 'enabled'.

is_checked - Boolean indicating whether the element is checked (default: nil).

Corresponds to Android 'checked'. Android only.

is_selected - Boolean indicating whether the element is selected (default: nil).

Corresponds to Android 'selected'.

is_checkable - Boolean indicating whether the element can be checked (default: nil).

Corresponds to Android 'checkable'. Android only.

is_focusable - Boolean indicating whether the element can be focused (default: nil).

Corresponds to Android 'focusable'. Android only.

is_long_pressable - Boolean indicating whether the element can be long-pressed (default: nil).

Corresponds to Android 'long-clickable'. Android only.

is_scrollable - Boolean indicating whether the element can be scrolled (default: nil).

Corresponds to Android 'scrollable'. Android only.

is_recordable - Boolean indicating whether the element can be recorded (default: nil). x - Integer x coordinate of the element (default: nil). y - Integer y coordinate of the element (default: nil). width - Integer width of the element (default: nil). height - Integer height of the element (default: nil). number - Integer channel number (default: nil). Channel elements only. start_time - Integer start time (default: nil). Channel/show elements only. end_time - Integer end time (default: nil). Channel/show elements only. coordinates - Boolean indicating whether absolute coordinates are given (default: false). info - Array of Symbols specifying attributes to retrieve (default: []).

By default, all attributes will be retrieved.

min - Integer minimum number of matching elements to require (default: 0).

By default, no restriction is imposed.

max - Integer maximum number of matching elements to require (default: nil).

By default, no restriction is imposed.

timeout - Integer total milliseconds to allow for element search (default: 30.sec).

Returns the Integer total milliseconds to match any elements, or nil if no elements matched.



175
176
177
178
179
180
181
182
# File 'lib/selenium/selenium.rb', line 175

def time_to_elements(attrs={})
  start_time = Time.now
  if elements?(attrs)
    ((Time.now - start_time) * 1000).round
  else
    nil
  end
end