Sha256: c759d2b84117cd3605589812ac6da3fea43b52abcca0afd0eee06837f01222f1

Contents?: true

Size: 1.12 KB

Versions: 13

Compression:

Stored size: 1.12 KB

Contents

module Watir
  class CheckBox < Input
    #
    # Sets checkbox to the given value.
    #
    # @example
    #   checkbox = browser.checkbox(id: 'new_user_interests_cars')
    #   checkbox.set?        #=> false
    #   checkbox.set
    #   checkbox.set?        #=> true
    #   checkbox.set(false)
    #   checkbox.set?        #=> false
    #
    # @param [Boolean] bool
    #

    def set(bool = true)
      set? == bool ? assert_enabled : click
    end
    alias check set

    #
    # Returns true if the element is checked
    # @return [Boolean]
    #

    def set?
      element_call { @element.selected? }
    end
    alias checked? set?

    #
    # Unsets checkbox.
    #

    def clear
      set false
    end
    alias uncheck clear
  end # CheckBox

  module Container
    def checkbox(*args)
      CheckBox.new(self, extract_selector(args).merge(tag_name: 'input', type: 'checkbox'))
    end

    def checkboxes(*args)
      CheckBoxCollection.new(self, extract_selector(args).merge(tag_name: 'input', type: 'checkbox'))
    end
  end # Container

  class CheckBoxCollection < InputCollection
  end # CheckBoxCollection
end # Watir

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
watir-6.19.1 lib/watir/elements/checkbox.rb
watir-6.19.0 lib/watir/elements/checkbox.rb
watir-6.18.0 lib/watir/elements/checkbox.rb
watir-6.17.0 lib/watir/elements/checkbox.rb
watir-6.16.5 lib/watir/elements/checkbox.rb
watir-6.16.4 lib/watir/elements/checkbox.rb
watir-6.16.3 lib/watir/elements/checkbox.rb
watir-6.16.2 lib/watir/elements/checkbox.rb
watir-6.16.1 lib/watir/elements/checkbox.rb
watir-6.16.0 lib/watir/elements/checkbox.rb
watir-6.15.1 lib/watir/elements/checkbox.rb
watir-6.15.0 lib/watir/elements/checkbox.rb
watir-6.14.0 lib/watir/elements/checkbox.rb