Module: RUTL::Element::StringReaderWriterMixin
- Included in:
- Text
- Defined in:
- lib/rutl/element/string_reader_writer_mixin.rb
Overview
Implement String stuff in a mixin. TODO: Not finished yet. Must be able to
Instance Method Summary collapse
-
#clear ⇒ Object
Talk to the view and set the element’s string to ”.
-
#eql?(other) ⇒ Boolean
(also: #==)
String value equals.
-
#get ⇒ Object
(also: #text, #value, #to_s)
Return the String held by this element.
-
#initialize(element_context, input_value = nil) ⇒ Object
Override BaseElement’s normal initialize method.
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to_missing?(method, flag) ⇒ Boolean
-
#send_keys(string) ⇒ Object
Sends these keystrokes without clearing the field.
-
#set(string) ⇒ Object
(also: #text=, #value=)
I could cut set() and only foo_text= if I change this.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rutl/element/string_reader_writer_mixin.rb', line 59 def method_missing(method, *args, &block) # RuboCop complains unless I fall back to super here # even though that's pretty meaningless. Oh, well, it's harmless. super unless get.respond_to?(method) if args.empty? get.send(method) else get.send(method, *args, &block) end end |
Instance Method Details
#clear ⇒ Object
Talk to the view and set the element’s string to ”.
41 42 43 44 |
# File 'lib/rutl/element/string_reader_writer_mixin.rb', line 41 def clear find_element.clear get end |
#eql?(other) ⇒ Boolean Also known as: ==
String value equals.
47 48 49 |
# File 'lib/rutl/element/string_reader_writer_mixin.rb', line 47 def eql?(other) other == get end |
#get ⇒ Object Also known as: text, value, to_s
Return the String held by this element.
29 30 31 32 33 34 35 |
# File 'lib/rutl/element/string_reader_writer_mixin.rb', line 29 def get found = find_element # This is a clumsy workaround for winappdriver, which gets textfields # as #text even though everything else seems to use #attribute(:value). # If both are false, this is undefined. found.attribute(:value) || found.text end |
#initialize(element_context, input_value = nil) ⇒ Object
Override BaseElement’s normal initialize method.
9 10 11 12 13 |
# File 'lib/rutl/element/string_reader_writer_mixin.rb', line 9 def initialize(element_context, input_value = nil) raise element_context.to_s unless element_context.is_a? ElementContext @context = element_context set input_value unless input_value.nil? end |
#respond_to_missing?(method, flag) ⇒ Boolean
70 71 72 |
# File 'lib/rutl/element/string_reader_writer_mixin.rb', line 70 def respond_to_missing?(method, flag) get.respond_to?(method, flag) end |
#send_keys(string) ⇒ Object
Sends these keystrokes without clearing the field. Returns the whole string in the field, including this input.
54 55 56 57 |
# File 'lib/rutl/element/string_reader_writer_mixin.rb', line 54 def send_keys(string) find_element.send_keys(string) get end |
#set(string) ⇒ Object Also known as: text=, value=
I could cut set() and only foo_text= if I change this. The problem I’m running into is not having the driver in base element to do find_element calls. So I have to change the way drivers are passed into everything or initially have them everywhere, which means rewriting chosen drivers or changing view load. Ick.
21 22 23 24 |
# File 'lib/rutl/element/string_reader_writer_mixin.rb', line 21 def set(string) clear find_element.send_keys(string) end |