Class: TestCentricity::AppElements::AppRadio

Inherits:
AppUIElement show all
Defined in:
lib/testcentricity_apps/app_elements/radio.rb

Instance Attribute Summary

Attributes inherited from AppUIElement

#context, #locator, #mru_app_session, #mru_locator, #mru_object, #mru_parent, #name, #parent, #type

Instance Method Summary collapse

Methods inherited from AppUIElement

#clear, #click, #count, #disabled?, #double_tap, #drag_and_drop, #drag_by, #element, #enabled?, #exists?, #get_attribute, #get_caption, #get_locator, #get_name, #get_object_type, #get_value, #height, #hidden?, #hover, #id, #identifier, #long_press, #reset_mru_cache, #scroll_into_view, #send_keys, #set, #swipe_gesture, #tap, #visible?, #wait_until_enabled, #wait_until_exists, #wait_until_gone, #wait_until_hidden, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible, #width, #x_loc, #y_loc

Constructor Details

#initialize(name, parent, locator, context) ⇒ AppRadio

Returns a new instance of AppRadio.



4
5
6
7
# File 'lib/testcentricity_apps/app_elements/radio.rb', line 4

def initialize(name, parent, locator, context)
  super
  @type = :radio
end

Instance Method Details

#selectObject

Set the selected state of a radio button object.

Examples:

unicode_radio.select


31
32
33
# File 'lib/testcentricity_apps/app_elements/radio.rb', line 31

def select
  set_selected_state(true)
end

#selected?Boolean

Is radio selected?

Examples:

unicode_radio.selected?

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
23
24
# File 'lib/testcentricity_apps/app_elements/radio.rb', line 15

def selected?
  obj = element
  object_not_found_exception(obj)
  if Environ.is_macos?
    state = obj.value
    state.to_bool
  else
    obj.selected?
  end
end

#set_selected_state(state) ⇒ Object

Set the selected state of a radio button object.

Examples:

ascii_radio.set_selected_state(true)

Parameters:

  • state (Boolean)

    true = selected / false = unselected



50
51
52
53
54
55
56
57
58
# File 'lib/testcentricity_apps/app_elements/radio.rb', line 50

def set_selected_state(state)
  obj = element
  object_not_found_exception(obj)
  if state
    obj.click unless obj.selected?
  else
    obj.click if obj.selected?
  end
end

#unselectObject

Unselect a radio button object.

Examples:

unicode_radio.unselect


40
41
42
# File 'lib/testcentricity_apps/app_elements/radio.rb', line 40

def unselect
  set_selected_state(false)
end