Sha256: 96358a5c56adab13d0ca066a85695e5c9eb9da37e72b8c576e0b7505374995c7
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
class Object def chain(method_chain, arg = nil) return self if method_chain.empty? method_chain.split('.').inject(self) do |o, m| if arg.nil? o.send(m.intern) else o.send(m.intern, arg) end end end end module Symbiote module DataSetter def using(data) data.each do |key, value| use_data_with(key, value) if object_enabled_for(key) end end alias using_data using alias use_data using alias using_values using alias use_values using private def use_data_with(key, value) element = send(key.to_s) set_and_select(key, element, value) check_and_uncheck(key, element, value) end def set_and_select(key, element, value) chain("#{key}.set", value) if element.class == Watir::TextField chain("#{key}.set") if element.class == Watir::Radio chain("#{key}.select", value) if element.class == Watir::Select end def check_and_uncheck(key, element, value) return chain("#{key}.check") if element.class == Watir::CheckBox && value chain("#{key}.uncheck") if element.class == Watir::CheckBox end def object_enabled_for(key) web_element = send(key.to_s) web_element.enabled? && web_element.visible? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
symbiote-0.2.0 | lib/symbiote/data_setter.rb |