lib/page-object/accessors.rb in page-object-0.7.4 vs lib/page-object/accessors.rb in page-object-0.7.5
- old
+ new
@@ -1,5 +1,7 @@
+require 'erb'
+
module PageObject
#
# Contains the class level methods that are inserted into your page objects
# when you include the PageObject module. These methods will generate another
# set of methods that provide access to the elements on the web pages.
@@ -8,20 +10,41 @@
# @see PageObject::SeleniumPageObject for the selenium implementation of the platform delegate
#
module Accessors
#
+ # Set some values that can be used withing the class. This is
+ # typically used to provide values that help build dynamic urls in
+ # the page_url method
+ #
+ # @param [Hash] the value to set the params
+ #
+ def params=(the_params)
+ @params = the_params
+ end
+
+ #
+ # Return the params that exist on this page class
+ #
+ def params
+ @params ||= {}
+ end
+
+ #
# Specify the url for the page. A call to this method will generate a
# 'goto' method to take you to the page.
#
# @param [String] the url for the page.
# @param [Symbol] a method name to call to get the url
#
def page_url(url)
define_method("goto") do
url = url.kind_of?(Symbol) ? self.send(url) : url
- platform.navigate_to url
+ erb = ERB.new(%Q{#{url}})
+ merged_params = self.class.instance_variable_get("@merged_params")
+ params = merged_params ? merged_params : self.class.params
+ platform.navigate_to erb.result(binding)
end
end
alias_method :direct_url, :page_url
#
@@ -219,10 +242,11 @@
#
# @param [Symbol] the name used for the generated methods
# @param [Hash] identifier how we find a select list. You can use a multiple paramaters
# by combining of any of the following except xpath. The valid keys are:
# * :class => Watir and Selenium
+ # * :css => Selenium only
# * :id => Watir and Selenium
# * :index => Watir and Selenium
# * :name => Watir and Selenium
# * :text => Watir only
# * :value => Watir only
@@ -435,9 +459,10 @@
#
# @param [Symbol] the name used for the generated methods
# @param [Hash] identifier how we find a div. You can use a multiple paramaters
# by combining of any of the following except xpath. The valid keys are:
# * :class => Watir and Selenium
+ # * :css => Selenium only
# * :id => Watir and Selenium
# * :index => Watir and Selenium
# * :name => Watir and Selenium
# * :text => Watir and Selenium
# * :title => Watir and Selenium