Class: TestCentricity::Radio

Inherits:
UIElement show all
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

Attributes inherited from UIElement

#alt_locator, #context, #locator, #locator_type, #name, #original_style, #parent, #type

Instance Method Summary collapse

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, #get_siebel_object_type, #height, #hidden?, #hover, #hover_at, #inspect, #invoke_siebel_dialog, #obscured?, #right_click, #role, #scroll_to, #send_keys, #set, #set_alt_locator, #set_locator_type, #style, #tabindex, #title, #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, proxy = nil) ⇒ Radio

Returns a new instance of Radio.



5
6
7
8
9
10
11
12
13
14
# File 'lib/testcentricity_web/web_elements/radio.rb', line 5

def initialize(name, parent, locator, context, proxy = nil)
  @name        = name
  @parent      = parent
  @locator     = locator
  @context     = context
  @alt_locator = nil
  @proxy       = proxy
  @type        = :radio
  set_locator_type
end

Instance Attribute Details

#proxyObject

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

#disabled?Boolean

Is radio button disabled (not enabled)?

Examples:

accept_terms_radio.disabled?

Returns:

  • (Boolean)


55
56
57
58
59
60
# File 'lib/testcentricity_web/web_elements/radio.rb', line 55

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?

Examples:

accept_terms_radio.exists?

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/testcentricity_web/web_elements/radio.rb', line 22

def exists?
  obj, = find_object(:all)
  obj != nil
end

#get_valueBoolean

Return radio button caption

Examples:

accept_terms_radio.get_value

Returns:

  • (Boolean)


68
69
70
# File 'lib/testcentricity_web/web_elements/radio.rb', line 68

def get_value
  @proxy.nil? ? super : @proxy.get_value
end

#highlight(duration = 1) ⇒ Object

Highlight a radio button with a 3 pixel wide, red dashed border for the specified wait time. If wait time is zero, then the highlight will remain until the page is refreshed

Examples:

accept_terms_radio.highlight(3)

Parameters:

  • duration (Integer or Float) (defaults to: 1)

    wait time in seconds



114
115
116
# File 'lib/testcentricity_web/web_elements/radio.rb', line 114

def highlight(duration = 1)
  @proxy.nil? ? super : @proxy.highlight(duration)
end

#selectObject

Set the selected state of a radio button object.

Examples:

accept_terms_radio.select


94
95
96
# File 'lib/testcentricity_web/web_elements/radio.rb', line 94

def select
  set_selected_state(true)
end

#selected?Boolean

Is radio button selected?

Examples:

accept_terms_radio.selected?

Returns:

  • (Boolean)


33
34
35
36
37
# File 'lib/testcentricity_web/web_elements/radio.rb', line 33

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.

Examples:

accept_terms_radio.set_selected_state(true)

Parameters:

  • state (Boolean)

    true = selected / false = unselected



78
79
80
81
82
83
84
85
86
87
# File 'lib/testcentricity_web/web_elements/radio.rb', line 78

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
    @proxy.click unless state == obj.checked?
  end
end

#unhighlightObject

Restore a highlighted radio button's original style

Examples:

accept_terms_radio.unhighlight


123
124
125
# File 'lib/testcentricity_web/web_elements/radio.rb', line 123

def unhighlight
  @proxy.nil? ? super : @proxy.unhighlight
end

#unselectObject

Unselect a radio button object.

Examples:

accept_terms_radio.unselect


103
104
105
# File 'lib/testcentricity_web/web_elements/radio.rb', line 103

def unselect
  set_selected_state(false)
end

#visible?Boolean

Is radio button visible?

Examples:

accept_terms_radio.visible?

Returns:

  • (Boolean)


45
46
47
# File 'lib/testcentricity_web/web_elements/radio.rb', line 45

def visible?
  @proxy.nil? ? super : @proxy.visible?
end