Class: TestCentricity::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
-
#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, #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, #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, #inspect, #obscured?, #right_click, #role, #scroll_to, #send_keys, #set, #set_alt_locator, #set_locator_type, #style, #tabindex, #title, #unhighlight, #verify_value, #wait_until_exists, #wait_until_gone, #wait_until_hidden, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible, #width, #x, #y
Constructor Details
#initialize(name, parent, locator, context) ⇒ Radio
Returns a new instance of Radio.
6 7 8 9 10 11 12 13 14 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 6 def initialize(name, parent, locator, context) super @type = :radio radio_spec = { proxy: nil, label: nil } define_custom_elements(radio_spec) end |
Instance Attribute Details
#label ⇒ Object
Returns the value of attribute label.
4 5 6 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 4 def label @label end |
#proxy ⇒ Object
Returns the value of attribute proxy.
3 4 5 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 3 def proxy @proxy end |
Instance Method Details
#define_custom_elements(element_spec) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 16 def define_custom_elements(element_spec) element_spec.each do |element, value| case element 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)?
68 69 70 71 72 73 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 68 def disabled? visibility = @proxy.nil? ? true : :all obj, type = find_element(visibility) object_not_found_exception(obj, type) obj.disabled? end |
#exists? ⇒ Boolean
Does radio button object exists?
35 36 37 38 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 35 def exists? obj, = find_object(:all) obj != nil end |
#get_value ⇒ Boolean Also known as: value , ,
Return radio button caption
81 82 83 84 85 86 87 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 81 def get_value if @label.nil? @proxy.nil? ? super : page.find(:css, @proxy).text else page.find(:css, @label).text end end |
#select ⇒ Object
Set the selected state of a radio button object.
115 116 117 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 115 def select set_selected_state(true) end |
#selected? ⇒ Boolean
Is radio button selected?
46 47 48 49 50 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 46 def selected? obj, = find_element(:all) object_not_found_exception(obj, 'Radio') obj.checked? end |
#set_selected_state(state) ⇒ Object
Set the select state of a radio button object.
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 99 def set_selected_state(state) obj, = find_element(:all) object_not_found_exception(obj, 'Radio') invalid_object_type_exception(obj, 'radio') if @proxy.nil? obj.set(state) else page.find(:css, @proxy).click unless state == obj.checked? end end |
#unselect ⇒ Object
Unselect a radio button object.
124 125 126 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 124 def unselect set_selected_state(state = false) end |
#visible? ⇒ Boolean
Is radio button visible?
58 59 60 |
# File 'lib/testcentricity_web/web_elements/radio.rb', line 58 def visible? @proxy.nil? ? super : page.find(:css, @proxy).visible? end |