class Wrapybara::Checkbox

Public Class Methods

new(identifier, scope = default_scope, how = default_how) click to toggle source
# File lib/wrapybara/elements/checkbox.rb, line 5
def initialize(identifier, scope = default_scope, how = default_how)
        @identifier = identifier
        @how = how
        @scope = scope
        xpath = XPath::HTML.checkbox(identifier)
        @element = get_element(xpath, scope)
end

Public Instance Methods

check() click to toggle source
# File lib/wrapybara/elements/checkbox.rb, line 27
def check
        self.set(true)
end
checked?() click to toggle source
# File lib/wrapybara/elements/checkbox.rb, line 35
def checked?
        self.should_exist
        # Capybara method
        @element.checked?
end
set(state) click to toggle source
# File lib/wrapybara/elements/checkbox.rb, line 21
def set(state)
        self.should_exist
        # Capybara method
        @element.set(state)
end
should_be_checked() click to toggle source
# File lib/wrapybara/elements/checkbox.rb, line 41
def should_be_checked
        raise UnmetExpectation, "Expected a checkbox #{self.element_identifier} to be checked" unless self.checked?
end
should_exist() click to toggle source
Calls superclass method Wrapybara::Element#should_exist
# File lib/wrapybara/elements/checkbox.rb, line 13
def should_exist
        super "Expected a checkbox #{self.element_identifier} to exist"
end
should_not_be_checked() click to toggle source
# File lib/wrapybara/elements/checkbox.rb, line 45
def should_not_be_checked
        raise UnmetExpectation, "Did not expect a checkbox #{self.element_identifier} to be checked" if self.checked?
end
should_not_exist() click to toggle source
Calls superclass method Wrapybara::Element#should_not_exist
# File lib/wrapybara/elements/checkbox.rb, line 17
def should_not_exist
        super "Did not expect a checkbox #{self.element_identifier}' to exist"
end
uncheck() click to toggle source
# File lib/wrapybara/elements/checkbox.rb, line 31
def uncheck
        self.set(false)
end