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, #parent, #type

Instance Method Summary collapse

Methods inherited from UIElement

#clear_alt_locator, #click, #click_at, #disabled?, #displayed?, #double_click, #drag_and_drop, #drag_by, #enabled?, #get_attribute, #get_locator, #get_name, #get_native_attribute, #get_object_type, #get_siebel_object_type, #get_value, #height, #hidden?, #hover, #invoke_siebel_dialog, #right_click, #send_keys, #set, #set_alt_locator, #set_locator_type, #verify_value, #visible?, #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

#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

#selectObject

Set the selected state of a radio button object.

Examples:

accept_terms_radio.select


61
62
63
# File 'lib/testcentricity_web/web_elements/radio.rb', line 61

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



45
46
47
48
49
50
51
52
53
54
# File 'lib/testcentricity_web/web_elements/radio.rb', line 45

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

#unselectObject

Unselect a radio button object.

Examples:

accept_terms_radio.unselect


70
71
72
# File 'lib/testcentricity_web/web_elements/radio.rb', line 70

def unselect
  set_selected_state(false)
end