Class: FireWatir::RadioCheckCommon

Inherits:
Element
  • Object
show all
Defined in:
lib/firewatir/elements/radio_check_common.rb

Overview

Description:

Base class for checkbox and radio button elements.

Direct Known Subclasses

CheckBox, Radio

Constant Summary

Constants inherited from Element

Element::FIRST_ORDERED_NODE_TYPE, Element::NUMBER_TYPE, Element::ORDERED_NODE_ITERATOR_TYPE, Element::TO_S_SIZE

Constants included from Container

Container::DEFAULT_HIGHLIGHT_COLOR, Container::MACHINE_IP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Element

#assert_enabled, #assert_exists, #attribute_value, #click, #contains_text, #disabled, #document_var, #element_by_xpath, #element_type, #elements_by_xpath, #enabled?, #exists?, #fire_event, #inspect, #method_missing, #text, #to_s, #visible?, #wait

Methods included from Container

#button, #cell, #checkbox, #dd, #dl, #dt, #file_field, #form, #frame, #hidden, #image, #link, #radio, #row, #select_list, #show_all_objects, #table, #text_field

Methods included from JsshSocket

#js_eval, #js_eval_method, #jssh_socket, #read_socket

Constructor Details

#initialize(container, how, what, value = nil) ⇒ RadioCheckCommon

Description:

Initializes the instance of element object. Element can be checkbox or radio button.

Input:

- how - Attribute to identify the element.
- what - Value of that attribute.
- value - value of the element.


17
18
19
20
21
22
# File 'lib/firewatir/elements/radio_check_common.rb', line 17

def initialize(container, how, what, value = nil)
  @how = how
  @what = what
  @value = value
  @container = container
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class FireWatir::Element

Instance Attribute Details

#element_nameObject

Returns the value of attribute element_name.



7
8
9
# File 'lib/firewatir/elements/radio_check_common.rb', line 7

def element_name
  @element_name
end

Instance Method Details

#clearObject

Description:

Unchecks the radio button or check box element.
Raises ObjectDisabledException exception if element is disabled.


60
61
62
63
64
65
66
# File 'lib/firewatir/elements/radio_check_common.rb', line 60

def clear
  assert_exists
  assert_enabled
  #highlight(:set)
  set_clear_item(false)
  #highlight(:clear)
end

#locateObject

Description:

Locate the element on the page. Element can be a checkbox or radio button.


28
29
30
31
32
33
34
35
36
37
38
# File 'lib/firewatir/elements/radio_check_common.rb', line 28

def locate
  case @how
  when :jssh_name
    @element_name = @what
  when :xpath
    @element_name = element_by_xpath(@container, @what)
  else
    @element_name = locate_tagged_element("input", @how, @what, @type, @value)
  end
  @o = self
end

#setObject

Description:

Checks the radio button or check box element.
Raises ObjectDisabledException exception if element is disabled.


73
74
75
76
77
78
79
# File 'lib/firewatir/elements/radio_check_common.rb', line 73

def set
  assert_exists
  assert_enabled
  #highlight(:set)
  set_clear_item(true)
  #highlight(:clear)
end

#set?Boolean Also known as: getState, checked?, isSet?

Description:

Checks if element i.e. radio button or check box is checked or not.

Output:

True if element is checked, false otherwise.

Returns:

  • (Boolean)


47
48
49
50
# File 'lib/firewatir/elements/radio_check_common.rb', line 47

def set?
  assert_exists
  return @o.checked
end