Method: Selenium#elements

Defined in:
lib/selenium/selenium.rb

#elements(attrs = {}) ⇒ Object

Public: Gets all elements matching the search criteria.

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 an Array of matching Elements, or nil if no elements matched.



62
63
64
65
66
67
68
69
70
71
# File 'lib/selenium/selenium.rb', line 62

def elements(attrs={})
  elems = (selenium_post('elements', attrs) || {})['elements']
  if elems.nil?
    nil
  elsif attrs.fetch(:info, []).count == 1
    elems.map {|e| Element.new(e)[attrs[:info].first]}
  else
    elems.map {|e| Element.new(e)}
  end
end