Class: Watir::CheckBox
- Inherits:
-
Input
- Object
- BaseElement
- HTMLElement
- Input
- Watir::CheckBox
- Defined in:
- lib/watir-webdriver/elements/checkbox.rb
Constant Summary
Constants inherited from BaseElement
BaseElement::IGNORED_ATTRIBUTES
Instance Method Summary collapse
-
#clear ⇒ Object
Unset this checkbox.
-
#set(bool = true) ⇒ Object
Set this checkbox to the given value.
-
#set? ⇒ Boolean
returns true if the element is checked.
Methods inherited from Input
#enabled?, #to_button, #to_checkbox, #to_radio, #to_select_list, #type
Methods inherited from BaseElement
attribute_list, #attribute_value, attributes, #click, #double_click, #driver, #element, #exists?, #fire_event, #flash, #focus, #html, #initialize, #inspect, #parent, #right_click, #run_checkers, #send_keys, #style, #tag_name, #text, typed_attributes, #value, #visible?
Methods included from Container
Methods included from XpathSupport
#element_by_xpath, #elements_by_xpath
Constructor Details
This class inherits a constructor from Watir::BaseElement
Instance Method Details
#clear ⇒ Object
Unset this checkbox.
Same as set(false)
48 49 50 |
# File 'lib/watir-webdriver/elements/checkbox.rb', line 48 def clear set false end |
#set(bool = true) ⇒ Object
Set this checkbox to the given value
Example:
checkbox.set? #=> false
checkbox.set
checkbox.set? #=> true
checkbox.set(false)
checkbox.set? #=> false
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/watir-webdriver/elements/checkbox.rb', line 21 def set(bool = true) assert_exists assert_enabled if @element.selected? @element.click unless bool else @element.click if bool end end |
#set? ⇒ Boolean
returns true if the element is checked
37 38 39 40 |
# File 'lib/watir-webdriver/elements/checkbox.rb', line 37 def set? assert_exists @element.selected? end |