Class: TestCentricity::TextField
- Defined in:
- lib/testcentricity_web/web_elements/textfield.rb
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_checked?, #aria_colcount, #aria_describedby, #aria_disabled?, #aria_expanded?, #aria_haspopup?, #aria_hidden?, #aria_invalid?, #aria_label, #aria_labelledby, #aria_live, #aria_pressed?, #aria_readonly?, #aria_required?, #aria_rowcount, #aria_selected?, #aria_sort, #clear_alt_locator, #click, #click_at, #count, #disabled?, #displayed?, #double_click, #drag_and_drop, #drag_by, #enabled?, #exists?, #get_attribute, #get_locator, #get_locator_type, #get_name, #get_native_attribute, #get_object_type, #get_siebel_object_type, #get_value, #height, #hidden?, #highlight, #hover, #hover_at, #inspect, #invoke_siebel_dialog, #obscured?, #right_click, #role, #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
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/testcentricity_web/web_elements/textfield.rb', line 89 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.
64 65 66 67 68 69 |
# File 'lib/testcentricity_web/web_elements/textfield.rb', line 64 def get_max obj, = find_element object_not_found_exception(obj, nil) max = obj.native.attribute('max') max.to_i unless max.blank? 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 |
# 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') min.to_i unless min.blank? 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.
77 78 79 80 81 82 |
# File 'lib/testcentricity_web/web_elements/textfield.rb', line 77 def get_step obj, = find_element object_not_found_exception(obj, nil) step = obj.native.attribute('step') step.to_i unless step.blank? 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 |