Sha256: 6d748bd0c002c370b6c38017531730acca58d723344493fc219678982da3975a

Contents?: true

Size: 1.05 KB

Versions: 19

Compression:

Stored size: 1.05 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

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

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

    #
    # Unsets checkbox.
    #

    def clear
      set false
    end

  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

19 entries across 19 versions & 1 rubygems

Version Path
watir-6.6.3 lib/watir/elements/checkbox.rb
watir-6.6.2 lib/watir/elements/checkbox.rb
watir-6.6.1 lib/watir/elements/checkbox.rb
watir-6.6.0 lib/watir/elements/checkbox.rb
watir-6.5.0 lib/watir/elements/checkbox.rb
watir-6.4.3 lib/watir/elements/checkbox.rb
watir-6.4.2 lib/watir/elements/checkbox.rb
watir-6.4.1 lib/watir/elements/checkbox.rb
watir-6.4.0 lib/watir/elements/checkbox.rb
watir-6.4.0.rc2 lib/watir/elements/checkbox.rb
watir-6.4.0.rc1 lib/watir/elements/checkbox.rb
watir-6.3.0 lib/watir/elements/checkbox.rb
watir-6.2.1 lib/watir/elements/checkbox.rb
watir-6.2.0 lib/watir/elements/checkbox.rb
watir-6.1.0 lib/watir/elements/checkbox.rb
watir-6.0.3 lib/watir/elements/checkbox.rb
watir-6.0.2 lib/watir/elements/checkbox.rb
watir-6.0.1 lib/watir/elements/checkbox.rb
watir-6.0.0 lib/watir/elements/checkbox.rb