module Symbiont module Generators # This method allows for a url_is() method in definitions that will # define a direct means of accessing a resource. The most common # example will be a URL for a web page, but any URI is valid. The # URL provided can be navigated to using the generated view() method # on a definition instance. # # @param [String] url the resource identifier to access # @return [Nil] def url_is(url) define_method("view") do @platform.visit(url) end end # This method allows for a begin_at() method in definitions. The # URL provided can be navigated to using the generated start() # method on a definition instance. # # @see Symbiont::Generators#url_is # @param [String] url the resource identifier to access # @return [Nil] def begin_at(url) define_method("start") do @platform.visit(url) end end # Definition method for links. Methods for the following actions will # be created: # * reference a link (identifier_object, identifier_link) # * click a link (identifier) # @param [Symbol] identifier the friendly name of the web object # @param [optional, Hash] locator the key/values that identify the object # @return [Object] instance of Symbiont::WebObjects::Link def link(identifier, locator) define_method("#{identifier}_object") do @platform.get_link_for(locator.clone) end alias_method "#{identifier}_link".to_sym, "#{identifier}_object".to_sym define_method(identifier) do @platform.click_link_for(locator.clone) end end # Definition method for buttons. Methods for the following actions will # be created: # * reference a button (identifier_object, identifier_button) # * click a button (identifier) # @param [Symbol] identifier the friendly name of the web object # @param [optional, Hash] locator the key/values that identify the object # @return [Object] instance of Symbiont::WebObjects::Button def button(identifier, locator) define_method("#{identifier}_object") do @platform.get_button_for(locator.clone) end alias_method "#{identifier}_button".to_sym, "#{identifier}_object".to_sym define_method(identifier) do @platform.click_button_for(locator.clone) end end # Definition method for text fields. Methods for the following actions # will be created: # * reference a text field (identifier_object, identifier_button) # * get text from a text field (identifier) # * set text in a text field (identifier=) # @param [Symbol] identifier the friendly name of the web object # @param [optional, Hash] locator the key/values that identify the object # @return [Object] instance of Symbiont::WebObjects::TextField def text_field(identifier, locator) define_method("#{identifier}_object") do @platform.get_text_field_for(locator.clone) end alias_method "#{identifier}_text_field".to_sym, "#{identifier}_object".to_sym define_method(identifier) do @platform.get_text_field_value_for(locator.clone) end define_method("#{identifier}=") do |value| @platform.set_text_field_value_for(locator.clone, value) end end end # module: Generators end # module: Symbiont