module RUTL::Element::StringReaderWriterMixin

Implement String stuff in a mixin. TODO: Not finished yet. Must be able to

Public Class Methods

new(element_context, input_value = nil) click to toggle source

Override BaseElement's normal initialize method.

# 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

Public Instance Methods

==(other)
Alias for: eql?
clear() click to toggle source

Talk to the view and set the element's string to ''.

# File lib/rutl/element/string_reader_writer_mixin.rb, line 41
def clear
  find_element.clear
  get
end
eql?(other) click to toggle source

String value equals.

# File lib/rutl/element/string_reader_writer_mixin.rb, line 47
def eql?(other)
  other == get
end
Also aliased as: ==
get() click to toggle source

Return the String held by this element.

# 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
Also aliased as: text, value, to_s
method_missing(method, *args, &block) click to toggle source
Calls superclass method
# 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
respond_to_missing?(method, flag) click to toggle source
# 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) click to toggle source

Sends these keystrokes without clearing the field. Returns the whole string in the field, including this input.

# File lib/rutl/element/string_reader_writer_mixin.rb, line 54
def send_keys(string)
  find_element.send_keys(string)
  get
end
set(string) click to toggle source

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.

# File lib/rutl/element/string_reader_writer_mixin.rb, line 21
def set(string)
  clear
  find_element.send_keys(string)
end
Also aliased as: text=, value=
text()
Alias for: get
text=(string)
Alias for: set
to_s()
Alias for: get
value()
Alias for: get
value=(string)
Alias for: set