page-object 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,12 @@
1
+ === Version 0.8.3 / 2013-1-22
2
+ * Enhancements
3
+ * Updated to use the latest selenium-webdriver 2.29
4
+ * Added :using_params parameter to both on_page and if_page methods
5
+ * Fixes
6
+ * Fixed issue where has_expected_title? displays misleading error message (X Zhang)
7
+ * Fixed issue when getting basic Element element when using Selenium
8
+ * Fixed issue when using plural class methods multiple times on same object
9
+
1
10
  === Version 0.8.2 / 2013-1-13
2
11
  * Enhancements
3
12
  * Updated expected_element to ue the global default element wait by default
@@ -60,8 +60,9 @@ module PageObject
60
60
  #
61
61
  def expected_title(expected_title)
62
62
  define_method("has_expected_title?") do
63
- has_expected_title = expected_title === title
64
- raise "Expected title '#{expected_title}' instead of '#{title}'" unless has_expected_title
63
+ page_title = title
64
+ has_expected_title = (expected_title === page_title)
65
+ raise "Expected title '#{expected_title}' instead of '#{page_title}'" unless has_expected_title
65
66
  has_expected_title
66
67
  end
67
68
  end
@@ -1168,8 +1169,8 @@ module PageObject
1168
1169
  define_method(method_name) do |name, *identifier, &block|
1169
1170
  define_method("#{name}_elements") do
1170
1171
  return call_block(&block) unless block.nil?
1171
- method_name = (method_name == :checkboxes) ? 'checkboxs_for' : "#{method_name.to_s}_for"
1172
- platform.send method_name, identifier.first.clone
1172
+ platform_method = (method_name == :checkboxes) ? 'checkboxs_for' : "#{method_name.to_s}_for"
1173
+ platform.send platform_method, identifier.first.clone
1173
1174
  end
1174
1175
  end
1175
1176
  end
@@ -38,15 +38,15 @@ module PageObject
38
38
  # Create and navigate to a page object. The navigation will only work if the
39
39
  # 'page_url' method was call on the page object.
40
40
  #
41
- # @param [PageObject, String] a class that has included the PageObject module or a string containing the name of the class
41
+ # @param [PageObject, String] a class that has included the
42
+ # PageObject module or a string containing the name of the class
43
+ # @param Hash values that is pass through to page class a
44
+ # available in the @params instance variable.
42
45
  # @param an optional block to be called
43
46
  # @return [PageObject] the newly created page object
44
47
  #
45
48
  def visit_page(page_class, params={:using_params => {}}, &block)
46
- page_class = class_from_string(page_class) if page_class.is_a? String
47
- merged = page_class.params.merge(params[:using_params])
48
- page_class.instance_variable_set("@merged_params", merged) unless merged.empty?
49
- on_page page_class, true, &block
49
+ on_page page_class, params, true, &block
50
50
  end
51
51
 
52
52
  # Support 'visit' for readability of usage
@@ -56,12 +56,16 @@ module PageObject
56
56
  # Create a page object.
57
57
  #
58
58
  # @param [PageObject, String] a class that has included the PageObject module or a string containing the name of the class
59
+ # @param Hash values that is pass through to page class a
60
+ # available in the @params instance variable.
59
61
  # @param [Boolean] a boolean indicating if the page should be visited? default is false.
60
62
  # @param [block] an optional block to be called
61
63
  # @return [PageObject] the newly created page object
62
64
  #
63
- def on_page(page_class, visit=false, &block)
65
+ def on_page(page_class, params={:using_params => {}}, visit=false, &block)
64
66
  page_class = class_from_string(page_class) if page_class.is_a? String
67
+ merged = page_class.params.merge(params[:using_params])
68
+ page_class.instance_variable_set("@merged_params", merged) unless merged.empty?
65
69
  @current_page = page_class.new(@browser, visit)
66
70
  block.call @current_page if block
67
71
  @current_page
@@ -74,13 +78,15 @@ module PageObject
74
78
  # Create a page object if and only if the current page is the same page to be created
75
79
  #
76
80
  # @param [PageObject, String] a class that has included the PageObject module or a string containing the name of the class
81
+ # @param Hash values that is pass through to page class a
82
+ # available in the @params instance variable.
77
83
  # @param [block] an optional block to be called
78
84
  # @return [PageObject] the newly created page object
79
85
  #
80
- def if_page(page_class, &block)
86
+ def if_page(page_class, params={:using_params => {}},&block)
81
87
  page_class = class_from_string(page_class) if page_class.is_a? String
82
88
  return @current_page unless @current_page.class == page_class
83
- on_page(page_class, false, &block)
89
+ on_page(page_class, params, false, &block)
84
90
  end
85
91
 
86
92
  # Support 'if' for readability of usage
@@ -977,7 +977,7 @@ module PageObject
977
977
  # See PageObject::Accessors#element
978
978
  #
979
979
  def element_for(tag, identifier)
980
- find_selenium_element(identifier, Elements::FileField, tag.to_s)
980
+ find_selenium_element(identifier, Elements::Element, tag.to_s)
981
981
  end
982
982
 
983
983
  #
@@ -985,7 +985,7 @@ module PageObject
985
985
  # See PageObject::Accessors#elements
986
986
  #
987
987
  def elements_for(tag, identifier)
988
- find_selenium_elements(identifier, Elements::FileField, tag.to_s)
988
+ find_selenium_elements(identifier, Elements::Element, tag.to_s)
989
989
  end
990
990
 
991
991
  private
@@ -1,4 +1,4 @@
1
1
  module PageObject
2
2
  # @private
3
- VERSION = "0.8.2"
3
+ VERSION = "0.8.3"
4
4
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
 
22
22
  s.add_dependency 'watir-webdriver', '>= 0.6.2'
23
- s.add_dependency 'selenium-webdriver', '>= 2.27.2'
23
+ s.add_dependency 'selenium-webdriver', '>= 2.29.0'
24
24
 
25
25
  s.add_development_dependency 'rspec', '>= 2.12.0'
26
26
  s.add_development_dependency 'cucumber', '>= 1.2.0'
@@ -188,7 +188,7 @@ describe PageObject::Accessors do
188
188
  end
189
189
 
190
190
  it "should raise error when it does not have expected title" do
191
- watir_browser.should_receive(:title).twice.and_return("Not Expected")
191
+ watir_browser.should_receive(:title).once.and_return("Not Expected")
192
192
  expect { watir_page_object.has_expected_title? }.to raise_error
193
193
  end
194
194
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page-object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-13 00:00:00.000000000 Z
12
+ date: 2013-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir-webdriver
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 2.27.2
37
+ version: 2.29.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 2.27.2
45
+ version: 2.29.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rspec
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -381,7 +381,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
381
381
  version: '0'
382
382
  segments:
383
383
  - 0
384
- hash: 2877571143837407410
384
+ hash: -1401660757405095936
385
385
  required_rubygems_version: !ruby/object:Gem::Requirement
386
386
  none: false
387
387
  requirements:
@@ -390,7 +390,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
390
390
  version: '0'
391
391
  segments:
392
392
  - 0
393
- hash: 2877571143837407410
393
+ hash: -1401660757405095936
394
394
  requirements: []
395
395
  rubyforge_project: page-object
396
396
  rubygems_version: 1.8.24