Class: TestCentricity::CheckBox
- Defined in:
- lib/testcentricity_web/web_elements/checkbox.rb
Constant Summary
Constants inherited from UIElement
UIElement::CSS_SELECTORS, UIElement::XPATH_SELECTORS
Instance Attribute Summary collapse
-
#proxy ⇒ Object
Returns the value of attribute proxy.
Attributes inherited from UIElement
#alt_locator, #context, #locator, #locator_type, #name, #original_style, #parent, #type
Instance Method Summary collapse
-
#check ⇒ Object
Set the check state of a checkbox object.
-
#checked? ⇒ Boolean
Is checkbox checked?.
-
#disabled? ⇒ Boolean
Is checkbox disabled (not enabled)?.
-
#exists? ⇒ Boolean
Does checkbox object exists?.
-
#get_value ⇒ Boolean
Return checkbox caption.
-
#highlight(duration = 1) ⇒ Object
Highlight a checkbox with a 3 pixel wide, red dashed border for the specified wait time.
-
#indeterminate? ⇒ Boolean
Is checkbox state indeterminate?.
-
#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.
-
#unhighlight ⇒ Object
Restore a highlighted checkbox's original style.
- #verify_check_state(state, enqueue = false) ⇒ Object
-
#visible? ⇒ Boolean
Is checkbox 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?, #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, #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) ⇒ CheckBox
Returns a new instance of CheckBox.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/testcentricity_web/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 set_locator_type end |
Instance Attribute Details
#proxy ⇒ Object
Returns the value of attribute proxy.
3 4 5 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 3 def proxy @proxy end |
Instance Method Details
#check ⇒ Object
Set the check state of a checkbox object.
110 111 112 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 110 def check set_checkbox_state(true) end |
#checked? ⇒ Boolean
Is checkbox checked?
33 34 35 36 37 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 33 def checked? obj, = find_element(:all) object_not_found_exception(obj, 'Checkbox') obj.checked? end |
#disabled? ⇒ Boolean
Is checkbox disabled (not enabled)?
66 67 68 69 70 71 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 66 def disabled? visibility = @proxy.nil? ? true : :all obj, type = find_element(visibility) object_not_found_exception(obj, type) obj.disabled? end |
#exists? ⇒ Boolean
Does checkbox object exists?
22 23 24 25 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 22 def exists? obj, = find_object(:all) obj != nil end |
#get_value ⇒ Boolean
Return checkbox caption
79 80 81 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 79 def get_value @proxy.nil? ? super : @proxy.get_value end |
#highlight(duration = 1) ⇒ Object
Highlight a checkbox 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
151 152 153 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 151 def highlight(duration = 1) @proxy.nil? ? super : @proxy.highlight(duration) end |
#indeterminate? ⇒ Boolean
Is checkbox state indeterminate?
45 46 47 48 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 45 def indeterminate? state = get_attribute('indeterminate') state.boolean? ? state : state == 'true' end |
#set_checkbox_state(state) ⇒ Object
Set the check state of a checkbox object.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 89 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.
136 137 138 139 140 141 142 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 136 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.
119 120 121 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 119 def uncheck set_checkbox_state(false) end |
#unhighlight ⇒ Object
Restore a highlighted checkbox's original style
160 161 162 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 160 def unhighlight @proxy.nil? ? super : @proxy.unhighlight end |
#verify_check_state(state, enqueue = false) ⇒ Object
123 124 125 126 127 128 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 123 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 |
#visible? ⇒ Boolean
Is checkbox visible?
56 57 58 |
# File 'lib/testcentricity_web/web_elements/checkbox.rb', line 56 def visible? @proxy.nil? ? super : @proxy.visible? end |