lib/symbiont/web_objects/text_field.rb in symbiont-0.1.7 vs lib/symbiont/web_objects/text_field.rb in symbiont-0.1.8

- old
+ new

@@ -1,22 +1,38 @@ module Symbiont module WebObjects class TextField < WebObject - # Get the value of a text field. - def value - @web_object.value + def initialize(web_object, platform) + @web_object = web_object + include_platform_specifics_for(platform) end - - # Set the value of a text field. - def value=(value) - @web_object.set value - end - - # Append text to a text field. + def append(text) - @web_object.send_keys text + web_object.send_keys text end + + def self.usable_selectors_for_watir + super + [:title, :value, :text, :label] + end + + def self.usable_selectors_for_selenium + super + [:title, :value, :text, :label] + end + + def include_platform_specifics_for(platform) + super + if platform[:platform] == :watir_webdriver + require 'symbiont/platform_watir/web_objects/text_field' + self.class.send :include, Symbiont::Platforms::WatirWebDriver::TextField + elsif platform[:platform] == :selenium_webdriver + require 'symbiont/platform_selenium/web_objects/text_field' + self.class.send :include, Symbiont::Platforms::SeleniumWebDriver::TextField + else + raise ArgumentError, "The platform #{platform[:platform]} appears to be unsupported." + end + end + end # class: TextField ::Symbiont::WebObjects.class_for_type[:text] = ::Symbiont::WebObjects::TextField ::Symbiont::WebObjects.class_for_type[:password] = ::Symbiont::WebObjects::TextField end # module: WebObjects