lib/testcentricity/app_elements/checkbox.rb in testcentricity-2.3.16.1 vs lib/testcentricity/app_elements/checkbox.rb in testcentricity-2.3.17
- old
+ new
@@ -1,26 +1,42 @@
module TestCentricity
class AppCheckBox < AppUIElement
def initialize(name, parent, locator, context)
super
- @type = :checkbox
+ @type = :checkbox
end
def checked?
obj = element
object_not_found_exception(obj)
obj.attribute('checked') == 'true'
end
+ # Set the check state of a checkbox object.
+ #
+ # @example
+ # remember_me_checkbox.check
+ #
def check
- obj = element
- object_not_found_exception(obj)
- obj.click unless obj.attribute('checked') == 'true'
+ set_checkbox_state(true)
end
+ # Uncheck a checkbox object.
+ #
+ # @example
+ # remember_me_checkbox.uncheck
+ #
def uncheck
+ set_checkbox_state(false)
+ end
+
+ def set_checkbox_state(state)
obj = element
object_not_found_exception(obj)
- obj.click if obj.attribute('checked') == 'true'
+ if state
+ obj.click unless obj.attribute('checked') == 'true'
+ else
+ obj.click if obj.attribute('checked') == 'true'
+ end
end
end
end