Class: Watir::Input

Inherits:
HTMLElement show all
Defined in:
lib/watir-webdriver/elements/input.rb,
lib/watir-webdriver/elements/generated.rb,
lib/watir-webdriver/elements/generated.rb

Direct Known Subclasses

CheckBox, FileField, Hidden, Radio, TextField

Constant Summary

Constants inherited from BaseElement

BaseElement::IGNORED_ATTRIBUTES

Instance Method Summary collapse

Methods inherited from BaseElement

attribute_list, #attribute_value, attributes, #click, #double_click, #driver, #element, #exists?, #fire_event, #flash, #focus, #html, #initialize, #inspect, #parent, #right_click, #run_checkers, #send_keys, #style, #tag_name, #text, typed_attributes, #value, #visible?

Methods included from Container

add

Methods included from XpathSupport

#element_by_xpath, #elements_by_xpath

Constructor Details

This class inherits a constructor from Watir::BaseElement

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/watir-webdriver/elements/input.rb', line 7

def enabled?
  !disabled?
end

#to_buttonObject



44
45
46
47
# File 'lib/watir-webdriver/elements/input.rb', line 44

def to_button
  assert_exists
  Watir::Button.new(@parent, :element, @element)
end

#to_checkboxObject

not sure about this

this is mostly useful if you’re using Browser#element_by_xpath, and want to ‘cast’ the returned Input instance to one of the subclasses



34
35
36
37
# File 'lib/watir-webdriver/elements/input.rb', line 34

def to_checkbox
  assert_exists
  Watir::CheckBox.new(@parent, :element, @element)
end

#to_radioObject



39
40
41
42
# File 'lib/watir-webdriver/elements/input.rb', line 39

def to_radio
  assert_exists
  Watir::Radio.new(@parent, :element, @element)
end

#to_select_listObject



49
50
51
52
# File 'lib/watir-webdriver/elements/input.rb', line 49

def to_select_list
  assert_exists
  Watir::SelectList.new(@parent, :element, @element)
end

#typeString

Return the type attribute of the element, or ‘text’ if the attribute is invalid. TODO: discuss.

Returns:



18
19
20
21
22
23
24
25
# File 'lib/watir-webdriver/elements/input.rb', line 18

def type
  assert_exists
  value = @element.attribute("type").to_s

  # we return 'text' if the type is invalid
  # not sure if we really should do this
  TextFieldLocator::NON_TEXT_TYPES.include?(value) ? value : 'text'
end