Sha256: a0aa9cfc8debd7c9568a39a6bd02e93a7c6e56a0f9a7755ac9b978198db992e8

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 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?
      assert_exists
      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

8 entries across 8 versions & 2 rubygems

Version Path
watir-webdriver-0.9.9 lib/watir-webdriver/elements/checkbox.rb
watir-6.0.0.beta5 lib/watir/elements/checkbox.rb
watir-6.0.0.beta4 lib/watir/elements/checkbox.rb
watir-6.0.0.beta3 lib/watir/elements/checkbox.rb
watir-6.0.0.beta2 lib/watir/elements/checkbox.rb
watir-6.0.0.beta1 lib/watir/elements/checkbox.rb
watir-webdriver-0.9.3 lib/watir-webdriver/elements/checkbox.rb
watir-webdriver-0.9.2 lib/watir-webdriver/elements/checkbox.rb