Class: TestCentricity::CheckBox
- Defined in:
- lib/testcentricity_web/elements/checkbox.rb
Instance Attribute Summary collapse
-
#proxy ⇒ Object
Returns the value of attribute proxy.
Attributes inherited from UIElement
#alt_locator, #context, #locator, #name, #parent, #type
Instance Method Summary collapse
-
#check ⇒ Object
Set the check state of a checkbox object.
-
#checked? ⇒ Boolean
Is checkbox checked?.
-
#exists? ⇒ Boolean
Does checkbox object exists?.
-
#initialize(name, parent, locator, context, proxy = nil) ⇒ CheckBox
constructor
A new instance of CheckBox.
-
#set_checkbox_state(state) ⇒ Object
Set the check state of a checkbox object.
-
#set_siebel_checkbox_state(state) ⇒ Object
Set the check state of a Siebel OUI JCheckBox object.
-
#uncheck ⇒ Object
Uncheck a checkbox object.
- #verify_check_state(state, enqueue = false) ⇒ Object
Methods inherited from UIElement
#clear_alt_locator, #click, #click_at, #disabled?, #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, #hidden?, #hover, #invoke_siebel_dialog, #right_click, #send_keys, #set, #set_alt_locator, #verify_value, #visible?, #wait_until_exists, #wait_until_gone, #wait_until_hidden, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible
Constructor Details
#initialize(name, parent, locator, context, proxy = nil) ⇒ CheckBox
Returns a new instance of CheckBox.
5 6 7 8 9 10 11 12 13 |
# File 'lib/testcentricity_web/elements/checkbox.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 = :checkbox end |
Instance Attribute Details
#proxy ⇒ Object
Returns the value of attribute proxy.
3 4 5 |
# File 'lib/testcentricity_web/elements/checkbox.rb', line 3 def proxy @proxy end |
Instance Method Details
#check ⇒ Object
Set the check state of a checkbox object.
65 66 67 |
# File 'lib/testcentricity_web/elements/checkbox.rb', line 65 def check set_checkbox_state(true) end |
#checked? ⇒ Boolean
Is checkbox checked?
32 33 34 35 36 |
# File 'lib/testcentricity_web/elements/checkbox.rb', line 32 def checked? obj, = find_element(:all) object_not_found_exception(obj, 'Checkbox') obj.checked? end |
#exists? ⇒ Boolean
Does checkbox object exists?
21 22 23 24 |
# File 'lib/testcentricity_web/elements/checkbox.rb', line 21 def exists? obj, = find_object(:all) obj != nil end |
#set_checkbox_state(state) ⇒ Object
Set the check state of a checkbox object.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/testcentricity_web/elements/checkbox.rb', line 44 def set_checkbox_state(state) obj, = find_element(:all) object_not_found_exception(obj, 'Checkbox') invalid_object_type_exception(obj, 'checkbox') if @proxy.nil? if obj.native.attribute('ot') == 'JCheckBox' expected = state.to_bool obj.click unless expected == obj.checked? else obj.set(state) end else @proxy.click unless state == obj.checked? end end |
#set_siebel_checkbox_state(state) ⇒ Object
Set the check state of a Siebel OUI JCheckBox object.
91 92 93 94 95 96 97 |
# File 'lib/testcentricity_web/elements/checkbox.rb', line 91 def set_siebel_checkbox_state(state) obj, = find_element object_not_found_exception(obj, 'Siebel checkbox') raise "UI #{} is not a Siebel CheckBox object" unless get_siebel_object_type == 'JCheckBox' expected = state.to_bool obj.click unless expected == obj.checked? end |
#uncheck ⇒ Object
Uncheck a checkbox object.
74 75 76 |
# File 'lib/testcentricity_web/elements/checkbox.rb', line 74 def uncheck set_checkbox_state(false) end |
#verify_check_state(state, enqueue = false) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/testcentricity_web/elements/checkbox.rb', line 78 def verify_check_state(state, enqueue = false) actual = checked? enqueue ? ExceptionQueue.enqueue_assert_equal(state, actual, "Expected checkbox #{}") : assert_equal(state, actual, "Expected checkbox #{} to be #{state} but found #{actual} instead") end |