class RUTL::Element::NullElement
This fakes all view elements when used with the null driver. It's a dirty way to avoid modeling all of what a driver talks to.
Attributes
context[RW]
Public Class Methods
clear_variables()
click to toggle source
# File lib/rutl/null_driver/null_element.rb, line 12 def self.clear_variables @@variables = {} end
new(context, _type, location)
click to toggle source
# File lib/rutl/null_driver/null_element.rb, line 16 def initialize(context, _type, location) @@variables ||= {} @context = context @location = location end
Public Instance Methods
attribute(attr)
click to toggle source
# File lib/rutl/null_driver/null_element.rb, line 32 def attribute(attr) case attr.to_sym when :value @@variables[@location] || '' else raise ArgumentError, "Attribute unknown: #{attr}" end end
clear()
click to toggle source
# File lib/rutl/null_driver/null_element.rb, line 41 def clear @@variables[@location] = '' end
click()
click to toggle source
Placeholder - NOP Called by RUTL::Element::ClickToChangeStateMixin
like Selenium driver.click
# File lib/rutl/null_driver/null_element.rb, line 52 def click; end
find_element()
click to toggle source
# File lib/rutl/null_driver/null_element.rb, line 45 def find_element self end
send_keys(string)
click to toggle source
@@string is a class variable because this framework creates new instances of each element every time it accesses them. This is good behavior by default because views could change underneath us. For text fields in the null application, though, we want to preserve the values across calls, letting us write and then read.
# File lib/rutl/null_driver/null_element.rb, line 27 def send_keys(string) init = @@variables[@location] || '' @@variables[@location] = init + string end