Module: WatirRobot::TextField
- Included in:
- KeywordLibrary
- Defined in:
- lib/watir_robot/keywords/text_field.rb
Overview
Functionality related to text fields (+<input>+ of type text and password)
Instance Method Summary collapse
-
#append_to_textfield(loc, text) ⇒ Object
Append text to a given text field’s current value.
-
#clear_textfield(loc) ⇒ Object
Clear the given textfield.
-
#focus_textfield(loc) ⇒ Object
Focus cursor inside a textfield.
-
#get_textfield_value(loc) ⇒ Object
Get value of given text field.
-
#input_password(loc, password) ⇒ Object
Input a password into a password field.
-
#input_text(loc, text) ⇒ Object
Input text into a text field.
-
#textfield_should_be(loc, text) ⇒ Object
Verify that textfield’s text is the value.
-
#textfield_should_contain(loc, text) ⇒ Object
Verify that textfield’s text contains the value.
Instance Method Details
#append_to_textfield(loc, text) ⇒ Object
Append text to a given text field’s current value
64 65 66 |
# File 'lib/watir_robot/keywords/text_field.rb', line 64 def append_to_textfield(loc, text) @browser.text_field(parse_location(loc)).append(text) end |
#clear_textfield(loc) ⇒ Object
Clear the given textfield
47 48 49 |
# File 'lib/watir_robot/keywords/text_field.rb', line 47 def clear_textfield(loc) @browser.text_field(parse_location(loc)).clear end |
#focus_textfield(loc) ⇒ Object
Focus cursor inside a textfield
15 16 17 |
# File 'lib/watir_robot/keywords/text_field.rb', line 15 def focus_textfield(loc) @browser.text_field(parse_location(loc)).focus end |
#get_textfield_value(loc) ⇒ Object
Get value of given text field
55 56 57 |
# File 'lib/watir_robot/keywords/text_field.rb', line 55 def get_textfield_value(loc) @browser.text_field(parse_location(loc)).value end |
#input_password(loc, password) ⇒ Object
Note:
This value will not be logged.
Input a password into a password field.
37 38 39 40 |
# File 'lib/watir_robot/keywords/text_field.rb', line 37 def input_password(loc, password) # This will differ from input_text when logging is implemented @browser.text_field(parse_location(loc)).set password end |
#input_text(loc, text) ⇒ Object
Input text into a text field
25 26 27 |
# File 'lib/watir_robot/keywords/text_field.rb', line 25 def input_text(loc, text) @browser.text_field(parse_location(loc)).set text end |
#textfield_should_be(loc, text) ⇒ Object
Verify that textfield’s text is the value
87 88 89 90 |
# File 'lib/watir_robot/keywords/text_field.rb', line 87 def textfield_should_be(loc, text) raise(Exception::ElementMatchError, "The textfield located at #{loc} does not have text equal to #{text}") unless @browser.text_field(parse_location(loc)).value == text end |
#textfield_should_contain(loc, text) ⇒ Object
Verify that textfield’s text contains the value
76 77 78 79 |
# File 'lib/watir_robot/keywords/text_field.rb', line 76 def textfield_should_contain(loc, text) raise(Exception::ElementMatchError, "The textfield located at #{loc} does not contain the text #{text}") unless @browser.text_field(parse_location(loc)).value.include? text end |