class FireWatir::TextField

Description: Class for Text Field element.

Constants

INPUT_TYPES

Public Instance Methods

append( setThis) click to toggle source

Description:

Append the provided text to the contents of the text field.
Raises ObjectDisabledException if text field is disabled.
Raises ObjectReadOnlyException if text field is read only.

Input:

- setThis - Text to be appended.
# File lib/firewatir/elements/text_field.rb, line 127
def append( setThis)
  assert_exists
  assert_enabled
  assert_not_readonly

  highlight(:set)
  @o.scrollIntoView
  @o.focus
  doKeyPress( setThis )
  highlight(:clear)
end
assert_not_readonly() click to toggle source

Description:

Checks if object is read-only or not.
# File lib/firewatir/elements/text_field.rb, line 43
def assert_not_readonly
  raise ObjectReadOnlyException, "Textfield #{@how} and #{@what} is read only." if self.readonly?
end
clear() click to toggle source

Description:

Clears the contents of the text field.
Raises ObjectDisabledException if text field is disabled.
Raises ObjectReadOnlyException if text field is read only.
# File lib/firewatir/elements/text_field.rb, line 100
def clear
  assert_exists
  assert_enabled
  assert_not_readonly

  highlight(:set)

  @o.scrollIntoView
  @o.focus
  @o.select()
  @o.fireEvent("onSelect")
  @o.value = ""
  @o.fireEvent("onKeyPress")
  @o.fireEvent("onChange")
  @container.wait()
  highlight(:clear)
end
maxLength() click to toggle source
Alias for: maxlength
maxlength() click to toggle source
# File lib/firewatir/elements/text_field.rb, line 13
def maxlength
  maxlength_string.to_i
end
Also aliased as: maxLength
set( setThis ) click to toggle source

Description:

Sets the contents of the text field to the provided text. Overwrite the existing contents.
Raises ObjectDisabledException if text field is disabled.
Raises ObjectReadOnlyException if text field is read only.

Input:

- setThis - Text to be set.
# File lib/firewatir/elements/text_field.rb, line 148
def set( setThis )
  assert_exists
  assert_enabled
  assert_not_readonly

  highlight(:set)
  @o.scrollIntoView
  @o.focus
  @o.select()
  @o.fireEvent("onSelect")
  @o.value = ""
  @o.fireEvent("onKeyPress")
  doKeyPress( setThis )
  highlight(:clear)
  @o.fireEvent("onChange")
  @o.fireEvent("onBlur")
end
to_s() click to toggle source

TODO: Impelement the #to_s method.

# File lib/firewatir/elements/text_field.rb, line 34
def to_s
  assert_exists
  super({"length" => "size","max length" => "maxlength","read only" => "readOnly" })
end
verify_contains( containsThis ) click to toggle source

Description:

Checks if the provided text matches with the contents of text field. Text can be a string or regular expression.

Input:

- containsThis - Text to verify.

Output:

True if provided text matches with the contents of text field, false otherwise.
# File lib/firewatir/elements/text_field.rb, line 57
def verify_contains( containsThis )
  assert_exists
  if containsThis.kind_of? String
    return true if self.value == containsThis
  elsif containsThis.kind_of? Regexp
    return true if self.value.match(containsThis) != nil
  end
  return false
end