Class: TestCentricity::Elements::Radio
- Defined in:
- lib/testcentricity_web/web_elements/radio.rb
Constant Summary
Constants inherited from UIElement
UIElement::CSS_SELECTORS, UIElement::XPATH_SELECTORS
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
-
#label ⇒ Object
Returns the value of attribute label.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
Attributes inherited from UIElement
#alt_locator, #base_object, #context, #locator, #locator_type, #mru_driver, #mru_locator, #mru_object, #mru_parent, #name, #original_style, #parent, #type
Instance Method Summary collapse
- #define_custom_elements(element_spec) ⇒ Object
-
#disabled? ⇒ Boolean
Is radio button disabled (not enabled)?.
-
#exists? ⇒ Boolean
Does radio button object exists?.
-
#get_value ⇒ Boolean
(also: #get_caption, #caption, #value)
Return radio button caption.
-
#initialize(name, parent, locator, context) ⇒ Radio
constructor
A new instance of Radio.
-
#select ⇒ Object
Set the selected state of a radio button object.
-
#selected? ⇒ Boolean
Is radio button selected?.
-
#set_selected_state(state) ⇒ Object
Set the select state of a radio button object.
-
#unselect ⇒ Object
Unselect a radio button object.
-
#visible? ⇒ Boolean
Is radio button visible?.
Methods inherited from UIElement
#aria_autocomplete, #aria_busy?, #aria_checked?, #aria_colcount, #aria_controls, #aria_describedby, #aria_disabled?, #aria_expanded?, #aria_haspopup?, #aria_hidden?, #aria_invalid?, #aria_keyshortcuts, #aria_label, #aria_labelledby, #aria_live, #aria_modal?, #aria_multiline?, #aria_multiselectable?, #aria_orientation, #aria_pressed?, #aria_readonly?, #aria_required?, #aria_roledescription, #aria_rowcount, #aria_selected?, #aria_sort, #aria_valuemax, #aria_valuemin, #aria_valuenow, #aria_valuetext, #clear_alt_locator, #click, #click_at, #content_editable?, #count, #crossorigin, #displayed?, #double_click, #drag_and_drop, #drag_by, #enabled?, #find_element, #focused?, #get_attribute, #get_locator, #get_locator_type, #get_name, #get_native_attribute, #get_object_type, #height, #hidden?, #highlight, #hover, #hover_at, #obscured?, #required?, #reset_mru_cache, #right_click, #role, #scroll_to, #send_keys, #set, #set_alt_locator, #set_locator_type, #style, #tabindex, #title, #unhighlight, #verify_value, #wait_until_enabled, #wait_until_exists, #wait_until_gone, #wait_until_hidden, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible, #wait_while_busy, #width, #x, #y
Constructor Details
#initialize(name, parent, locator, context) ⇒ Radio
Returns a new instance of Radio.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 8 def initialize(name, parent, locator, context) super @type = :radio radio_spec = { input: nil, proxy: nil, label: nil } define_custom_elements(radio_spec) end |
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input.
6 7 8 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 6 def input @input end |
#label ⇒ Object
Returns the value of attribute label.
5 6 7 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 5 def label @label end |
#proxy ⇒ Object
Returns the value of attribute proxy.
4 5 6 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 4 def proxy @proxy end |
Instance Method Details
#define_custom_elements(element_spec) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 19 def define_custom_elements(element_spec) element_spec.each do |element, value| case element when :input @input = value when :proxy @proxy = value when :label @label = value else raise "#{element} is not a recognized radio element" end end end |
#disabled? ⇒ Boolean
Is radio button disabled (not enabled)?
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 85 def disabled? if @input.nil? super else @base_object, = find_element(:all) object_not_found_exception(@base_object, 'Radio') rad = find_component(@input, 'radio') rad.disabled? end end |
#exists? ⇒ Boolean
Does radio button object exists?
40 41 42 43 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 40 def exists? obj, = find_object(:all) obj != nil end |
#get_value ⇒ Boolean Also known as: value , ,
Return radio button caption
102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 102 def get_value if @label.nil? if @proxy.nil? super else proxy = find_component(@proxy, 'radio proxy') proxy.text end else label = find_component(@label, 'radio label') label.text end end |
#select ⇒ Object
Set the selected state of a radio button object.
151 152 153 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 151 def select set_selected_state(true) end |
#selected? ⇒ Boolean
Is radio button selected?
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 51 def selected? @base_object, = find_element(:all) object_not_found_exception(@base_object, 'Radio') rad = if @input.nil? @base_object else find_component(@input, 'Radio') end rad.checked? end |
#set_selected_state(state) ⇒ Object
Set the select state of a radio button object.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 126 def set_selected_state(state) @base_object, = find_element(:all) object_not_found_exception(@base_object, 'Radio') proxy = find_component(@proxy, 'radio proxy') unless @proxy.nil? rad = find_component(@input, 'radio') unless @input.nil? if @input.nil? if @proxy.nil? @base_object.click unless state == @base_object.checked? else proxy.click unless state == @base_object.checked? end else if @proxy.nil? @base_object.click unless state == rad.checked? else proxy.click unless state == rad.checked? end end end |
#unselect ⇒ Object
Unselect a radio button object.
160 161 162 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 160 def unselect set_selected_state(state = false) end |
#visible? ⇒ Boolean
Is radio button visible?
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 68 def visible? if @proxy.nil? super else @base_object, = find_element(:all) object_not_found_exception(@base_object, 'Radio') proxy = find_component(@proxy, 'radio proxy') proxy.visible? end end |