Sha256: 4a3bbe2b6d199c08d527f2b9d2d240427b6940ba85f4a3e18e45c17717f65172
Contents?: true
Size: 1.36 KB
Versions: 10
Compression:
Stored size: 1.36 KB
Contents
# encoding: utf-8 module Watir class CheckBox < Input def self.from(parent, element) if element.attribute(:type) != "checkbox" raise TypeError, "expected type=checkbox for #{element.inspect}" end super end # # 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 # 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 def element_class CheckBox end end # CheckBoxCollection end
Version data entries
10 entries across 10 versions & 2 rubygems