Class: TestCentricity::TextField

Inherits:
UIElement show all
Defined in:
lib/testcentricity_web/elements/textfield.rb

Instance Attribute Summary

Attributes inherited from UIElement

#alt_locator, #context, #locator, #parent, #type

Instance Method Summary collapse

Methods inherited from UIElement

#clear_alt_locator, #click, #click_at, #disabled?, #double_click, #drag_and_drop, #drag_by, #enabled?, #exists?, #get_attribute, #get_locator, #get_native_attribute, #get_object_type, #get_siebel_object_type, #get_value, #hidden?, #hover, #invoke_siebel_dialog, #right_click, #send_keys, #set, #set_alt_locator, #verify_value, #visible?, #wait_until_exists, #wait_until_gone, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible

Constructor Details

#initialize(parent, locator, context) ⇒ TextField

Returns a new instance of TextField.



3
4
5
6
7
8
9
# File 'lib/testcentricity_web/elements/textfield.rb', line 3

def initialize(parent, locator, context)
  @parent  = parent
  @locator = locator
  @context = context
  @type    = :textfield
  @alt_locator = nil
end

Instance Method Details

#get_max_lengthInteger

Return maxlength character count of a text field.

Examples:

max_num_chars = comments_field.get_max_length

Returns:

  • (Integer)


29
30
31
32
33
34
# File 'lib/testcentricity_web/elements/textfield.rb', line 29

def get_max_length
  obj, _ = find_element
  object_not_found_exception(obj, nil)
  max_length = obj.native.attribute('maxlength')
  max_length.to_i unless max_length.blank?
end

#get_placeholderString

Return placeholder text of a text field.

Examples:

placeholder_message = username_field.get_placeholder

Returns:



42
43
44
45
46
# File 'lib/testcentricity_web/elements/textfield.rb', line 42

def get_placeholder
  obj, _ = find_element
  object_not_found_exception(obj, nil)
  obj.native.attribute('placeholder')
end

#read_only?Boolean

Is text field set to read-only?

Examples:

comments_field.read_only?

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/testcentricity_web/elements/textfield.rb', line 17

def read_only?
  obj, _ = find_element
  object_not_found_exception(obj, nil)
  !!obj.native.attribute('readonly')
end