Sha256: d9057c426b312d2a9349e922b48ddac32658c01638c6103f1475a1d444cd20d0

Contents?: true

Size: 869 Bytes

Versions: 9

Compression:

Stored size: 869 Bytes

Contents

# encoding: utf-8
module Watir
  class CheckBox < Input
    identifier :type => 'checkbox'

    container_method  :checkbox
    collection_method :checkboxes

    #
    # Set this checkbox to the given value
    #
    # Example:
    #
    #   checkbox.set?        #=> false
    #   checkbox.set
    #   checkbox.set?        #=> true
    #   checkbox.set(false)
    #   checkbox.set?        #=> false
    #

    def set(bool = true)
      assert_exists
      assert_enabled

      if @element.selected?
        @element.click unless bool
      else
        @element.click if bool
      end
    end

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

    def set?
      assert_exists
      @element.selected?
    end

    #
    # Unset this checkbox.
    #
    # Same as +set(false)+
    #

    def clear
      set false
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
watir-webdriver-0.0.6 lib/watir-webdriver/elements/checkbox.rb
watir-webdriver-0.0.5 lib/watir-webdriver/elements/checkbox.rb
watir-webdriver-0.0.4 lib/watir-webdriver/elements/checkbox.rb
watir-webdriver-0.0.3 lib/watir-webdriver/elements/checkbox.rb
watir-webdriver-0.0.2 lib/watir-webdriver/elements/checkbox.rb
watir-webdriver-0.0.1 lib/watir-webdriver/elements/checkbox.rb
watir-webdriver-0.0.1.dev7 lib/watir-webdriver/elements/checkbox.rb
watir-webdriver-0.0.1.dev6 lib/watir-webdriver/elements/checkbox.rb
watir-webdriver-0.0.1.dev5 lib/watir-webdriver/elements/checkbox.rb