Class: TestCentricity::TextField
- Defined in:
- lib/testcentricity_web/web_elements/textfield.rb
Direct Known Subclasses
Constant Summary
Constants inherited from UIElement
UIElement::CSS_SELECTORS, UIElement::XPATH_SELECTORS
Instance Attribute Summary
Attributes inherited from UIElement
#alt_locator, #context, #locator, #locator_type, #name, #original_style, #parent, #type
Instance Method Summary collapse
-
#clear ⇒ Object
Clear the contents of a text field.
-
#get_max ⇒ Integer
Return max attribute of a number type text field.
-
#get_max_length ⇒ Integer
Return maxlength character count of a text field.
-
#get_min ⇒ Integer
Return min attribute of a number type text field.
-
#get_placeholder ⇒ String
Return placeholder text of a text field.
-
#get_step ⇒ Integer
Return step attribute of a number type text field.
-
#initialize(name, parent, locator, context) ⇒ TextField
constructor
A new instance of TextField.
-
#read_only? ⇒ Boolean
Is text field set to read-only?.
Methods inherited from UIElement
#aria_autocomplete, #aria_busy?, #aria_checked?, #aria_colcount, #aria_controls, #aria_describedby, #aria_disabled?, #aria_expanded?, #aria_haspopup?, #aria_hidden?, #aria_invalid?, #aria_keyshortcuts, #aria_label, #aria_labelledby, #aria_live, #aria_modal?, #aria_multiline?, #aria_multiselectable?, #aria_orientation, #aria_pressed?, #aria_readonly?, #aria_required?, #aria_roledescription, #aria_rowcount, #aria_selected?, #aria_sort, #aria_valuemax, #aria_valuemin, #aria_valuenow, #aria_valuetext, #clear_alt_locator, #click, #click_at, #content_editable?, #count, #disabled?, #displayed?, #double_click, #drag_and_drop, #drag_by, #enabled?, #exists?, #find_element, #focused?, #get_attribute, #get_locator, #get_locator_type, #get_name, #get_native_attribute, #get_object_type, #get_value, #height, #hidden?, #highlight, #hover, #hover_at, #inspect, #obscured?, #right_click, #role, #scroll_to, #send_keys, #set, #set_alt_locator, #set_locator_type, #style, #tabindex, #title, #unhighlight, #verify_value, #visible?, #wait_until_exists, #wait_until_gone, #wait_until_hidden, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible, #width, #x, #y
Constructor Details
#initialize(name, parent, locator, context) ⇒ TextField
Returns a new instance of TextField.
3 4 5 6 |
# File 'lib/testcentricity_web/web_elements/textfield.rb', line 3 def initialize(name, parent, locator, context) super @type = :textfield end |
Instance Method Details
#clear ⇒ Object
Clear the contents of a text field
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/testcentricity_web/web_elements/textfield.rb', line 113 def clear case get_native_attribute('tagName').downcase.to_sym when :textarea set('') sleep(0.5) send_keys(:tab) when :div set('') else length = get_value.length length.times do send_keys(:backspace) end sleep(0.5) if get_value.length > 0 set('') sleep(0.5) send_keys(:tab) end end end |
#get_max ⇒ Integer
Return max attribute of a number type text field.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/testcentricity_web/web_elements/textfield.rb', line 72 def get_max obj, = find_element object_not_found_exception(obj, nil) max = obj.native.attribute('max') unless max.blank? if max.is_int? max.to_i elsif max.is_float? max.to_f else max end end end |
#get_max_length ⇒ Integer
Return maxlength character count of a text field.
26 27 28 29 30 31 |
# File 'lib/testcentricity_web/web_elements/textfield.rb', line 26 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_min ⇒ Integer
Return min attribute of a number type text field.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/testcentricity_web/web_elements/textfield.rb', line 51 def get_min obj, = find_element object_not_found_exception(obj, nil) min = obj.native.attribute('min') unless min.blank? if min.is_int? min.to_i elsif min.is_float? min.to_f else min end end end |
#get_placeholder ⇒ String
Return placeholder text of a text field.
39 40 41 42 43 |
# File 'lib/testcentricity_web/web_elements/textfield.rb', line 39 def get_placeholder obj, = find_element object_not_found_exception(obj, nil) obj.native.attribute('placeholder') end |
#get_step ⇒ Integer
Return step attribute of a number type text field.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/testcentricity_web/web_elements/textfield.rb', line 93 def get_step obj, = find_element object_not_found_exception(obj, nil) step = obj.native.attribute('step') unless step.blank? if step.is_int? step.to_i elsif step.is_float? step.to_f else step end end end |
#read_only? ⇒ Boolean
Is text field set to read-only?
14 15 16 17 18 |
# File 'lib/testcentricity_web/web_elements/textfield.rb', line 14 def read_only? obj, = find_element object_not_found_exception(obj, nil) !!obj.native.attribute('readonly') end |