Class: Watir::CheckBox

Inherits:
InputElement show all
Includes:
RadioCheckCommon
Defined in:
lib/watir-classic/input_elements.rb

Overview

This class is the watir representation of a check box. Normally a user would not need to create this object as it is returned by the Watir::Container#checkbox method

Constant Summary

Constants inherited from Element

Element::TO_S_SIZE

Instance Attribute Summary

Attributes inherited from Element

#container

Attributes included from Container

#activeObjectHighLightColor, #page_container, #type_keys, #typingspeed

Instance Method Summary collapse

Methods included from RadioCheckCommon

#inspect

Methods inherited from InputElement

#locate

Methods inherited from Element

#<=>, #__ole_inner_elements, #activeObjectHighLightColor, #assert_enabled, #assert_exists, #attribute_value, #click, #click!, #create_event, #disabled?, #dispatch_event, #document, #double_click, #enabled?, #exists?, #fire_event, #flash, #focus, #focused?, #initialize, #inspect, #locate, #method_missing, #ole_object, #ole_object=, #parent, #right_click, #send_keys, #style, #tag_name, #text, #to_s, #to_subtype, #type_keys, #typingspeed, #visible?

Methods included from DragAndDropHelper

#drag_and_drop_by, #drag_and_drop_on

Methods included from Container

#__ole_inner_elements, #alert, #locator_for, #modal_dialog, #set_container, support_element, #wait

Methods included from Exception

message_for_unable_to_locate

Methods included from ElementExtensions

#present?, #wait_until_present, #wait_while_present, #when_present

Constructor Details

This class inherits a constructor from Watir::Element

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Watir::Element

Instance Method Details

#clearObject

Clears a check box.

Raises UnknownObjectException if its unable to locate an object
      ObjectDisabledException if the object is disabled


474
475
476
# File 'lib/watir-classic/input_elements.rb', line 474

def clear
  set false
end

#set(value = true) ⇒ Object

This method checks or unchecks the checkbox. With no arguments supplied it sets the checkbox. Setting false argument unchecks/clears the checkbox.

Raises UnknownObjectException if it's unable to locate an object
      ObjectDisabledException if the object is disabled


460
461
462
463
464
465
466
467
468
469
# File 'lib/watir-classic/input_elements.rb', line 460

def set(value=true)
  assert_exists
  assert_enabled
  highlight :set
  current_value = @o.checked
  unless value == current_value
    click
  end
  highlight :clear
end