page-object 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 386482bc19d329a8cd1189c91a689fca46fc9a8e
4
- data.tar.gz: cb8e35e8ec52b8b5e776d9122ef7d7e02ce4e14d
3
+ metadata.gz: 8826d6f078421cd039c214d90e20423cb348a223
4
+ data.tar.gz: c17ebadedafc8bd8ef1ad9f9cfc040378d341cc4
5
5
  SHA512:
6
- metadata.gz: b061306394d35e32ca3c44a18b27ee3909c0d8cdd983debbe3d0e0307d55707bf2f4b2b8386cbef267f7becc2da53e83ff78e1e12d56f50f03d116ad552ffe89
7
- data.tar.gz: e8373204c8b363185d094987ffa51e1d2518281b38ffddd6ebd868192e1fa48b07686a0829549db31223bc1086b376823c106c411cd90f33c10903a5897db749
6
+ metadata.gz: 914761fe9b6dcdc4db770bdc2b25e16f616fb9162635037539a8405f887695c4cb3c084c54d3447647a70872e17d1015482d842b1d14ad7ec05dcfb10421f218
7
+ data.tar.gz: 9a24a8127ba2f34183d77018ca89df9ccb7d0c7ed528fcee0040e8712060bbe6823387bdd3d2514d2fbde25e7b2f2c54867325d5898fc7ae829fe90fe4d63306
data/ChangeLog CHANGED
@@ -1,4 +1,10 @@
1
- === Version 1.0.1
1
+ === Version 1.0.2 / 2014-7-21
2
+ * Enhancements
3
+ * Added support to use multiple identifiers when locating nested frames / iframes (Thanks Justin Ko)
4
+ * Fixes
5
+ * Reverted the method name check due to unintended consequences
6
+
7
+ === Version 1.0.1 / 2014-7-19
2
8
  * Enhancements
3
9
  * Checks the name of generated methods to ensure they do not colide with existing page-object methods
4
10
  * Removed old legacy css code and now delegate everything to Watir
@@ -11,11 +11,17 @@ Feature: Handling frames
11
11
  #And I should be able to get the text fields text from frame 2 using "index"
12
12
 
13
13
  @watir_only
14
- Scenario: Accessing elements withing the frame using Regexp
14
+ Scenario: Accessing elements within the frame using Regexp
15
15
  Given I am on the frame elements page
16
16
  When I type "page-object" into the text field for frame 2 using "regex"
17
17
  Then I should verify "page-object" is in the text field for frame 2 using "regex"
18
18
 
19
+ @watir_only
20
+ Scenario: Accessing elements within the frame using multiple identifiers
21
+ Given I am on the iframe elements page
22
+ When I type "page-object" into the text field for frame 2 using "multiple identifiers"
23
+ Then I should verify "page-object" is in the text field for frame 2 using "multiple identifiers"
24
+
19
25
  Scenario: Switching between frames
20
26
  Given I am on the frame elements page
21
27
  When I type "page-object" into the text field for frame 2 using "id"
@@ -52,6 +52,9 @@ class IFramePage
52
52
  text_field(:text_field_1_index, :name => 'senderElement', :frame => frame)
53
53
  end
54
54
 
55
+ in_iframe(:class => 'iframe', :name => 'frame2') do |frame|
56
+ text_field(:text_field_2_multiple_identifiers, :name => 'recieverElement', :frame => frame)
57
+ end
55
58
  end
56
59
 
57
60
 
@@ -66,11 +69,11 @@ Given /^I am on the iframe elements page$/ do
66
69
  end
67
70
 
68
71
  When /^I type "([^\"]*)" into the text field for frame 2 using "([^\"]*)"$/ do |text, arg_type|
69
- @page.send "text_field_2_#{arg_type}=".to_sym, text
72
+ @page.send "text_field_2_#{arg_type.gsub(' ', '_')}=".to_sym, text
70
73
  end
71
74
 
72
75
  Then /^I should verify "([^\"]*)" is in the text field for frame 2 using "([^\"]*)"$/ do |text, arg_type|
73
- result = @page.send "text_field_2_#{arg_type}".to_sym
76
+ result = @page.send "text_field_2_#{arg_type.gsub(' ', '_')}".to_sym
74
77
  result.should == text
75
78
  end
76
79
 
@@ -79,11 +82,11 @@ end
79
82
  #end
80
83
 
81
84
  When /^I type "([^\"]*)" into the text field from frame 1 using "([^\"]*)"$/ do |text, arg_type|
82
- @page.send "text_field_1_#{arg_type}=".to_sym, text
85
+ @page.send "text_field_1_#{arg_type.gsub(' ', '_')}=".to_sym, text
83
86
  end
84
87
 
85
88
  Then /^I should verify "([^\"]*)" is in the text field for frame 1 using "([^\"]*)"$/ do |text, arg_type|
86
- result = @page.send "text_field_1_#{arg_type}".to_sym
89
+ result = @page.send "text_field_1_#{arg_type.gsub(' ', '_')}".to_sym
87
90
  result.should == text
88
91
  end
89
92
 
@@ -1,6 +1,6 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib'))
2
2
 
3
- require 'rspec/expectations'
3
+ require 'rspec'
4
4
  require 'watir-webdriver'
5
5
  require 'selenium-webdriver'
6
6
  require 'page-object'
@@ -466,7 +466,6 @@ module PageObject
466
466
  # * :name => Watir and Selenium
467
467
  #
468
468
  def radio_button_group(name, identifier)
469
- check_name(name)
470
469
  define_method("select_#{name}") do |value|
471
470
  platform.radio_buttons_for(identifier.clone).each do |radio_elem|
472
471
  if radio_elem.value == value
@@ -1171,7 +1170,6 @@ module PageObject
1171
1170
  # @param optional block to be invoked when element method is called
1172
1171
  #
1173
1172
  def element(name, tag, identifier={:index => 0}, &block)
1174
- check_name(name)
1175
1173
  define_method("#{name}") do
1176
1174
  self.send("#{name}_element").text
1177
1175
  end
@@ -1205,7 +1203,6 @@ module PageObject
1205
1203
  # @param optional block to be invoked when element method is called
1206
1204
  #
1207
1205
  def elements(name, tag, identifier={:index => 0}, &block)
1208
- check_name(name)
1209
1206
  define_method("#{name}_elements") do
1210
1207
  return call_block(&block) if block_given?
1211
1208
  platform.elements_for(tag, identifier.clone)
@@ -1246,7 +1243,6 @@ module PageObject
1246
1243
  end
1247
1244
 
1248
1245
  def standard_methods(name, identifier, method, &block)
1249
- check_name(name)
1250
1246
  define_method("#{name}_element") do
1251
1247
  return call_block(&block) if block_given?
1252
1248
  platform.send(method, identifier.clone)
@@ -1314,9 +1310,5 @@ module PageObject
1314
1310
  end
1315
1311
  end
1316
1312
  end
1317
-
1318
- def check_name(name)
1319
- raise NameError, "Identifier '#{name}' conflicts with page-object method of the same name" if self.instance_methods.include? name
1320
- end
1321
1313
  end
1322
1314
  end
@@ -34,7 +34,7 @@ module PageObject
34
34
  end
35
35
 
36
36
  #
37
- # Return an array of Options contained in the select lit.
37
+ # Return an array of Options contained in the select list.
38
38
  #
39
39
  # @return [array of PageObject::Elements::Option]
40
40
  def options
@@ -974,24 +974,26 @@ module PageObject
974
974
  identifier[:tag_name] = tag if identifier[:name]
975
975
  identifier
976
976
  end
977
-
977
+
978
978
  def nested_frames(frame_identifiers)
979
979
  return if frame_identifiers.nil?
980
980
  frame_str = ''
981
981
  frame_identifiers.each do |frame|
982
- id = frame.values.first
983
982
  type = frame.keys.first
984
- value = id.values.first
985
- if value.is_a?(Regexp)
986
- frame_str += "#{type.to_s}(:#{id.keys.first} => #{value.inspect})."
987
- else
988
- frame_str += "#{type.to_s}(:#{id.keys.first} => #{value})." if value.to_s.is_integer
989
- frame_str += "#{type.to_s}(:#{id.keys.first} => '#{value}')." unless value.to_s.is_integer
990
- end
983
+ identifier = frame.values.first.map do |key, value|
984
+ if value.is_a?(Regexp)
985
+ ":#{key} => #{value.inspect}"
986
+ elsif value.to_s.is_integer
987
+ ":#{key} => #{value}"
988
+ else
989
+ ":#{key} => '#{value}'"
990
+ end
991
+ end.join(', ')
992
+ frame_str += "#{type.to_s}(#{identifier})."
991
993
  end
992
994
  frame_str
993
995
  end
994
-
996
+
995
997
  def switch_to_default_content(frame_identifiers)
996
998
  @browser.wd.switch_to.default_content unless frame_identifiers.nil?
997
999
  end
@@ -29,7 +29,7 @@ module PageObject
29
29
  end
30
30
 
31
31
  #
32
- # Return an array of Options contained in the select lit.
32
+ # Return an array of Options contained in the select list.
33
33
  #
34
34
  # @return [array of PageObject::Elements::Option]
35
35
  #
@@ -1,4 +1,4 @@
1
1
  module PageObject
2
2
  # @private
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
@@ -30,7 +30,6 @@ module PageObject
30
30
  def self.define_accessors(base, widget_tag, widget_class)
31
31
  accessors_module = Module.new do
32
32
  define_method widget_tag do |name, *identifier_args, &block|
33
- check_name(name)
34
33
 
35
34
  identifier = identifier_args.first
36
35
  identifier = {:index => 0} if identifier.nil?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page-object
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-19 00:00:00.000000000 Z
11
+ date: 2014-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: watir-webdriver
@@ -330,7 +330,6 @@ files:
330
330
  - lib/page-object/widgets.rb
331
331
  - page-object.gemspec
332
332
  - pageobject.gems
333
- - spec/page-object/accessors_spec.rb
334
333
  - spec/page-object/element_locators_spec.rb
335
334
  - spec/page-object/elements/area_spec.rb
336
335
  - spec/page-object/elements/button_spec.rb
@@ -519,7 +518,6 @@ test_files:
519
518
  - features/text_field.feature
520
519
  - features/unordered_list.feature
521
520
  - features/video.feature
522
- - spec/page-object/accessors_spec.rb
523
521
  - spec/page-object/element_locators_spec.rb
524
522
  - spec/page-object/elements/area_spec.rb
525
523
  - spec/page-object/elements/button_spec.rb
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include RSpec::Matchers
4
-
5
- describe PageObject::Accessors do
6
- context 'when declaring new elements on the page' do
7
-
8
- it "should check the name when adding an element" do
9
- class TestPage
10
- include PageObject
11
-
12
- def self.elements
13
- [
14
- 'text_field',
15
- 'hidden_field',
16
- 'text_area',
17
- 'select_list',
18
- 'link',
19
- 'checkbox',
20
- 'radio_button',
21
- 'radio_button_group',
22
- 'button',
23
- 'div',
24
- 'span',
25
- 'table',
26
- 'cell',
27
- 'image',
28
- 'form',
29
- 'list_item',
30
- 'unordered_list',
31
- 'ordered_list',
32
- 'h1',
33
- 'h2',
34
- 'h3',
35
- 'h4',
36
- 'h5',
37
- 'h6',
38
- 'paragraph',
39
- 'file_field',
40
- 'label',
41
- 'area',
42
- 'canvas',
43
- 'audio',
44
- 'video',
45
- 'svg',
46
- 'address',
47
- 'figure'
48
- ]
49
- end
50
-
51
- elements.each do |ele|
52
- expect {
53
- self.send ele, :platform, :id => 'foo'
54
- }.to raise_error(NameError, "Identifier \'platform\' conflicts with page-object method of the same name")
55
- end
56
- end
57
- end
58
-
59
- end
60
- end