page-object 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +1 -0
  4. data/ChangeLog +10 -0
  5. data/README.md +1 -1
  6. data/features/bold.feature +21 -0
  7. data/features/html/indexed_property.html +14 -0
  8. data/features/html/multi_elements.html +1 -1
  9. data/features/html/static_elements.html +1 -2
  10. data/features/indexed_property.feature +15 -0
  11. data/features/multi_elements.feature +6 -0
  12. data/features/step_definitions/async_steps.rb +1 -1
  13. data/features/step_definitions/bold_steps.rb +12 -0
  14. data/features/step_definitions/check_box_steps.rb +2 -2
  15. data/features/step_definitions/indexed_property_steps.rb +47 -1
  16. data/features/step_definitions/label_steps.rb +1 -1
  17. data/features/step_definitions/multi_elements_steps.rb +13 -0
  18. data/features/step_definitions/select_list_steps.rb +1 -1
  19. data/features/step_definitions/table_steps.rb +4 -0
  20. data/features/support/page.rb +9 -0
  21. data/features/table.feature +12 -4
  22. data/lib/page-object.rb +6 -5
  23. data/lib/page-object/accessors.rb +78 -58
  24. data/lib/page-object/elements.rb +1 -0
  25. data/lib/page-object/elements/bold.rb +11 -0
  26. data/lib/page-object/elements/element.rb +12 -1
  27. data/lib/page-object/elements/table.rb +12 -1
  28. data/lib/page-object/indexed_properties.rb +20 -21
  29. data/lib/page-object/javascript/angularjs.rb +14 -0
  30. data/lib/page-object/javascript_framework_facade.rb +4 -2
  31. data/lib/page-object/locator_generator.rb +1 -0
  32. data/lib/page-object/page_populator.rb +0 -1
  33. data/lib/page-object/platforms/selenium_webdriver/button.rb +1 -1
  34. data/lib/page-object/platforms/selenium_webdriver/element.rb +1 -1
  35. data/lib/page-object/platforms/selenium_webdriver/page_object.rb +26 -10
  36. data/lib/page-object/platforms/selenium_webdriver/radio_button.rb +0 -7
  37. data/lib/page-object/platforms/watir_webdriver/element.rb +1 -1
  38. data/lib/page-object/platforms/watir_webdriver/page_object.rb +23 -8
  39. data/lib/page-object/platforms/watir_webdriver/radio_button.rb +0 -7
  40. data/lib/page-object/version.rb +1 -1
  41. data/lib/page-object/widgets.rb +7 -0
  42. data/page-object.gemspec +3 -3
  43. data/spec/page-object/accessors_spec.rb +40 -0
  44. data/spec/page-object/element_locators_spec.rb +340 -305
  45. data/spec/page-object/elements/area_spec.rb +8 -8
  46. data/spec/page-object/elements/bold_spec.rb +29 -0
  47. data/spec/page-object/elements/button_spec.rb +7 -7
  48. data/spec/page-object/elements/canvas_spec.rb +6 -6
  49. data/spec/page-object/elements/check_box_spec.rb +9 -9
  50. data/spec/page-object/elements/div_spec.rb +3 -3
  51. data/spec/page-object/elements/element_spec.rb +21 -21
  52. data/spec/page-object/elements/file_field_spec.rb +4 -4
  53. data/spec/page-object/elements/form_spec.rb +3 -3
  54. data/spec/page-object/elements/heading_spec.rb +8 -8
  55. data/spec/page-object/elements/hidden_field_spec.rb +3 -3
  56. data/spec/page-object/elements/image_spec.rb +14 -14
  57. data/spec/page-object/elements/label_spec.rb +3 -3
  58. data/spec/page-object/elements/link_spec.rb +6 -6
  59. data/spec/page-object/elements/list_item_spec.rb +4 -3
  60. data/spec/page-object/elements/nested_element_spec.rb +47 -47
  61. data/spec/page-object/elements/option_spec.rb +1 -1
  62. data/spec/page-object/elements/ordered_list_spec.rb +33 -33
  63. data/spec/page-object/elements/paragraph_spec.rb +3 -4
  64. data/spec/page-object/elements/select_list_spec.rb +52 -52
  65. data/spec/page-object/elements/selenium/radio_button_spec.rb +7 -13
  66. data/spec/page-object/elements/selenium/text_field_spec.rb +7 -7
  67. data/spec/page-object/elements/selenium_element_spec.rb +53 -53
  68. data/spec/page-object/elements/span_spec.rb +3 -3
  69. data/spec/page-object/elements/table_cell_spec.rb +3 -3
  70. data/spec/page-object/elements/table_row_spec.rb +22 -22
  71. data/spec/page-object/elements/table_spec.rb +28 -28
  72. data/spec/page-object/elements/text_area_spec.rb +5 -5
  73. data/spec/page-object/elements/unordered_list_spec.rb +33 -34
  74. data/spec/page-object/elements/watir_element_spec.rb +47 -48
  75. data/spec/page-object/javascript_framework_facade_spec.rb +6 -6
  76. data/spec/page-object/loads_platform_spec.rb +4 -4
  77. data/spec/page-object/page-object_spec.rb +103 -102
  78. data/spec/page-object/page_factory_spec.rb +43 -61
  79. data/spec/page-object/page_populator_spec.rb +44 -50
  80. data/spec/page-object/platforms/selenium_webdriver/selenium_page_object_spec.rb +15 -15
  81. data/spec/page-object/platforms/selenium_webdriver_spec.rb +6 -6
  82. data/spec/page-object/platforms/watir_webdriver/watir_page_object_spec.rb +4 -4
  83. data/spec/page-object/platforms/watir_webdriver_spec.rb +1 -1
  84. data/spec/page-object/selenium_accessors_spec.rb +166 -153
  85. data/spec/page-object/watir_accessors_spec.rb +265 -245
  86. data/spec/page-object/widget_spec.rb +62 -30
  87. data/spec/spec_helper.rb +8 -8
  88. metadata +20 -10
@@ -13,17 +13,29 @@ describe "Widget PageObject Extensions" do
13
13
  ".//descendant::tr"
14
14
  end
15
15
  end
16
-
17
16
  PageObject.register_widget :gxt_table, GxtTable, :div
17
+
18
+ class WidgetMatrix < PageObject::Elements::Table
19
+ def self.plural_form
20
+ 'widget_matrices'
21
+ end
22
+ end
23
+ PageObject.register_widget :widget_matrix, WidgetMatrix, :div
18
24
  end
19
25
 
20
26
  class WidgetTestPageObject
21
27
  include PageObject
22
28
 
23
29
  gxt_table(:a_table, :id => "top_div_id")
30
+ gxt_tables(:some_table, :class => "top_div_class")
24
31
  gxt_table :gxt_block_table do |element|
25
32
  "block_gxt_table"
26
33
  end
34
+ gxt_tables :gxt_multiple_block_table do |element|
35
+ "multiple_block_gxt_table"
36
+ end
37
+
38
+ widget_matrices :matrix, :class => 'matrix'
27
39
 
28
40
  div(:outer_div)
29
41
  gxt_table(:a_nested_gxt_table) { |page| page.outer_div_element.gxt_table_element }
@@ -36,9 +48,9 @@ describe "Widget PageObject Extensions" do
36
48
  let(:watir_page_object) { WidgetTestPageObject.new(watir_browser) }
37
49
 
38
50
  it "should find a gxt_table element" do
39
- watir_browser.should_receive(:div).with(:id => 'blah').and_return(watir_browser)
51
+ expect(watir_browser).to receive(:div).with(:id => 'blah').and_return(watir_browser)
40
52
  element = watir_page_object.gxt_table_element(:id => 'blah')
41
- element.should be_instance_of GxtTable
53
+ expect(element).to be_instance_of GxtTable
42
54
  end
43
55
  end
44
56
 
@@ -47,9 +59,9 @@ describe "Widget PageObject Extensions" do
47
59
  let(:selenium_page_object) { WidgetTestPageObject.new(selenium_browser) }
48
60
 
49
61
  it "should find a gxt_table element" do
50
- selenium_browser.should_receive(:find_element).with(:id, 'blah').and_return(selenium_browser)
62
+ expect(selenium_browser).to receive(:find_element).with(:id, 'blah').and_return(selenium_browser)
51
63
  element = selenium_page_object.gxt_table_element(:id => 'blah')
52
- element.should be_instance_of GxtTable
64
+ expect(element).to be_instance_of GxtTable
53
65
  end
54
66
  end
55
67
  end
@@ -68,12 +80,12 @@ describe "Widget PageObject Extensions" do
68
80
  let(:default_identifier) { WatirDefaultIdentifier.new(watir_browser) }
69
81
 
70
82
  def mock_driver_for(tag)
71
- watir_browser.should_receive(tag).with(:index => 0).and_return(watir_browser)
83
+ expect(watir_browser).to receive(tag).with(:index => 0).and_return(watir_browser)
72
84
  end
73
85
 
74
86
  it "should work for a gxt_table" do
75
87
  mock_driver_for :div
76
- default_identifier.default_gxt_table_element.should_not be_nil
88
+ expect(default_identifier.default_gxt_table_element).not_to be_nil
77
89
  end
78
90
 
79
91
  end
@@ -81,18 +93,38 @@ describe "Widget PageObject Extensions" do
81
93
  describe "gxt_table accessors" do
82
94
  context "when called on a page object" do
83
95
  it "should generate accessor methods" do
84
- watir_page_object.should respond_to(:a_table_element)
96
+ expect(watir_page_object).to respond_to(:a_table_element)
97
+ end
98
+
99
+ it "should generate multiple accessor methods" do
100
+ expect(watir_page_object).to respond_to(:some_table_elements)
85
101
  end
86
102
 
87
103
  it "should call a block on the element method when present" do
88
- watir_page_object.gxt_block_table_element.should == "block_gxt_table"
104
+ expect(watir_page_object.gxt_block_table_element).to eql "block_gxt_table"
105
+ end
106
+
107
+ it "should call a block on the elements method when present" do
108
+ expect(watir_page_object.gxt_multiple_block_table_elements).to eql "multiple_block_gxt_table"
89
109
  end
90
110
  end
91
111
 
92
112
  it "should retrieve the table element from the page" do
93
- watir_browser.should_receive(:div).and_return(watir_browser)
113
+ expect(watir_browser).to receive(:div).and_return(watir_browser)
94
114
  element = watir_page_object.a_table_element
95
- element.should be_instance_of GxtTable
115
+ expect(element).to be_instance_of GxtTable
116
+ end
117
+
118
+ it "should retrieve all table elements from the page" do
119
+ expect(watir_browser).to receive(:divs).and_return([watir_browser])
120
+ element = watir_page_object.some_table_elements
121
+ expect(element[0]).to be_instance_of GxtTable
122
+ end
123
+
124
+ it "should be able to specify the plural form" do
125
+ expect(watir_browser).to receive(:divs).and_return([watir_browser])
126
+ element = watir_page_object.matrix_elements
127
+ expect(element[0]).to be_instance_of WidgetMatrix
96
128
  end
97
129
  end
98
130
  end
@@ -102,14 +134,14 @@ describe "Widget PageObject Extensions" do
102
134
  it "should map watir types to same" do
103
135
  [:class, :id, :index, :xpath].each do |t|
104
136
  identifier = GxtTable.watir_identifier_for t => 'value'
105
- identifier.keys.first.should == t
137
+ expect(identifier.keys.first).to eql t
106
138
  end
107
139
  end
108
140
 
109
141
  it "should map selenium types to same" do
110
142
  [:class, :id, :index, :name, :xpath].each do |t|
111
143
  key, value = GxtTable.selenium_identifier_for t => 'value'
112
- key.should == t
144
+ expect(key).to eql t
113
145
  end
114
146
  end
115
147
  end
@@ -118,23 +150,23 @@ describe "Widget PageObject Extensions" do
118
150
  let(:gxt_table_element) { double('gxt_table_element') }
119
151
 
120
152
  before(:each) do
121
- gxt_table_element.stub(:[]).and_return(gxt_table_element)
122
- gxt_table_element.stub(:find_elements).and_return(gxt_table_element)
153
+ allow(gxt_table_element).to receive(:[]).and_return(gxt_table_element)
154
+ allow(gxt_table_element).to receive(:find_elements).and_return(gxt_table_element)
123
155
  end
124
156
 
125
157
  context "for watir" do
126
158
  let(:watir_table) { GxtTable.new(gxt_table_element, :platform => :watir_webdriver) }
127
159
 
128
160
  it "should return a table row when indexed" do
129
- gxt_table_element.stub(:[]).with(1).and_return(gxt_table_element)
130
- watir_table[1].should be_instance_of PageObject::Elements::TableRow
161
+ allow(gxt_table_element).to receive(:[]).with(1).and_return(gxt_table_element)
162
+ expect(watir_table[1]).to be_instance_of PageObject::Elements::TableRow
131
163
  end
132
164
 
133
165
  it "should return the number of rows" do
134
- gxt_table_element.stub(:wd).and_return(gxt_table_element)
135
- gxt_table_element.should_receive(:find_elements).with(:xpath, ".//descendant::tr").and_return(gxt_table_element)
136
- gxt_table_element.should_receive(:size).and_return(2)
137
- watir_table.rows.should == 2
166
+ allow(gxt_table_element).to receive(:wd).and_return(gxt_table_element)
167
+ expect(gxt_table_element).to receive(:find_elements).with(:xpath, ".//descendant::tr").and_return(gxt_table_element)
168
+ expect(gxt_table_element).to receive(:size).and_return(2)
169
+ expect(watir_table.rows).to eql 2
138
170
  end
139
171
  end
140
172
 
@@ -142,21 +174,21 @@ describe "Widget PageObject Extensions" do
142
174
  let(:selenium_table) { GxtTable.new(gxt_table_element, :platform => :selenium_webdriver) }
143
175
 
144
176
  it "should return a table row when indexed" do
145
- gxt_table_element.should_receive(:find_elements).with(:xpath, ".//descendant::tr").and_return(gxt_table_element)
146
- selenium_table[1].should be_instance_of PageObject::Elements::TableRow
177
+ expect(gxt_table_element).to receive(:find_elements).with(:xpath, ".//descendant::tr").and_return(gxt_table_element)
178
+ expect(selenium_table[1]).to be_instance_of PageObject::Elements::TableRow
147
179
  end
148
180
 
149
181
  it "should return the number of rows" do
150
- gxt_table_element.should_receive(:find_elements).with(:xpath, ".//descendant::tr").and_return(gxt_table_element)
151
- gxt_table_element.should_receive(:size).and_return(2)
152
- selenium_table.rows.should == 2
182
+ expect(gxt_table_element).to receive(:find_elements).with(:xpath, ".//descendant::tr").and_return(gxt_table_element)
183
+ expect(gxt_table_element).to receive(:size).and_return(2)
184
+ expect(selenium_table.rows).to eql 2
153
185
  end
154
186
 
155
187
  it "should iterate over the table rows" do
156
- selenium_table.should_receive(:rows).and_return(2)
188
+ expect(selenium_table).to receive(:rows).and_return(2)
157
189
  count = 0
158
190
  selenium_table.each { |e| count += 1 }
159
- count.should == 2
191
+ expect(count).to eql 2
160
192
  end
161
193
  end
162
194
  end
@@ -170,7 +202,7 @@ describe "Widget PageObject Extensions" do
170
202
  end
171
203
 
172
204
  it "should find a nested gxt_table" do
173
- @watir_driver.should_receive(:div).and_return(@watir_driver)
205
+ expect(@watir_driver).to receive(:div).and_return(@watir_driver)
174
206
  @watir_element.gxt_table_element
175
207
  end
176
208
  end
@@ -182,7 +214,7 @@ describe "Widget PageObject Extensions" do
182
214
  end
183
215
 
184
216
  it "should find a nested gxt_table" do
185
- @selenium_driver.should_receive(:find_element).and_return(@selenium_driver)
217
+ expect(@selenium_driver).to receive(:find_element).and_return(@selenium_driver)
186
218
  @selenium_element.gxt_table_element
187
219
  end
188
220
  end
@@ -17,28 +17,28 @@ require 'page-object'
17
17
 
18
18
  def mock_watir_browser
19
19
  watir_browser = double('watir')
20
- watir_browser.stub(:is_a?).with(anything()).and_return(false)
21
- watir_browser.stub(:is_a?).with(Watir::Browser).and_return(true)
20
+ allow(watir_browser).to receive(:is_a?).with(anything()).and_return(false)
21
+ allow(watir_browser).to receive(:is_a?).with(Watir::Browser).and_return(true)
22
22
  watir_browser
23
23
  end
24
24
 
25
25
 
26
26
  def mock_selenium_browser
27
27
  selenium_browser = double('selenium')
28
- selenium_browser.stub(:is_a?).with(Watir::Browser).and_return(false)
29
- selenium_browser.stub(:is_a?).with(Selenium::WebDriver::Driver).and_return(true)
28
+ allow(selenium_browser).to receive(:is_a?).with(Watir::Browser).and_return(false)
29
+ allow(selenium_browser).to receive(:is_a?).with(Selenium::WebDriver::Driver).and_return(true)
30
30
  selenium_browser
31
31
  end
32
32
 
33
33
 
34
34
  def mock_adapter(browser, page_object)
35
35
  adapter = double('adapter')
36
- adapter.stub(:is_for?).with(anything()).and_return false
37
- adapter.stub(:is_for?).with(browser).and_return true
38
- adapter.stub(:create_page_object).and_return page_object
36
+ allow(adapter).to receive(:is_for?).with(anything()).and_return false
37
+ allow(adapter).to receive(:is_for?).with(browser).and_return true
38
+ allow(adapter).to receive(:create_page_object).and_return page_object
39
39
  adapter
40
40
  end
41
41
 
42
42
  def mock_adapters(adapters)
43
- PageObject::Platforms.stub(:get).and_return adapters
43
+ allow(PageObject::Platforms).to receive(:get).and_return adapters
44
44
  end
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.2
4
+ version: 1.0.3
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-21 00:00:00.000000000 Z
11
+ date: 2014-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: watir-webdriver
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.9
19
+ version: 0.6.11
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.6.9
26
+ version: 0.6.11
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: selenium-webdriver
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.42.0
33
+ version: 2.44.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 2.42.0
40
+ version: 2.44.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: page_navigation
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "<"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "<"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: cucumber
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -130,6 +130,7 @@ files:
130
130
  - features/area.feature
131
131
  - features/async.feature
132
132
  - features/audio.feature
133
+ - features/bold.feature
133
134
  - features/button.feature
134
135
  - features/canvas.feature
135
136
  - features/check_box.feature
@@ -198,6 +199,7 @@ files:
198
199
  - features/step_definitions/area_steps.rb
199
200
  - features/step_definitions/async_steps.rb
200
201
  - features/step_definitions/audio_steps.rb
202
+ - features/step_definitions/bold_steps.rb
201
203
  - features/step_definitions/button_steps.rb
202
204
  - features/step_definitions/canvas_steps.rb
203
205
  - features/step_definitions/check_box_steps.rb
@@ -254,6 +256,7 @@ files:
254
256
  - lib/page-object/elements.rb
255
257
  - lib/page-object/elements/area.rb
256
258
  - lib/page-object/elements/audio.rb
259
+ - lib/page-object/elements/bold.rb
257
260
  - lib/page-object/elements/button.rb
258
261
  - lib/page-object/elements/canvas.rb
259
262
  - lib/page-object/elements/check_box.rb
@@ -282,6 +285,7 @@ files:
282
285
  - lib/page-object/elements/unordered_list.rb
283
286
  - lib/page-object/elements/video.rb
284
287
  - lib/page-object/indexed_properties.rb
288
+ - lib/page-object/javascript/angularjs.rb
285
289
  - lib/page-object/javascript/jquery.rb
286
290
  - lib/page-object/javascript/prototype.rb
287
291
  - lib/page-object/javascript/yui.rb
@@ -330,8 +334,10 @@ files:
330
334
  - lib/page-object/widgets.rb
331
335
  - page-object.gemspec
332
336
  - pageobject.gems
337
+ - spec/page-object/accessors_spec.rb
333
338
  - spec/page-object/element_locators_spec.rb
334
339
  - spec/page-object/elements/area_spec.rb
340
+ - spec/page-object/elements/bold_spec.rb
335
341
  - spec/page-object/elements/button_spec.rb
336
342
  - spec/page-object/elements/canvas_spec.rb
337
343
  - spec/page-object/elements/check_box_spec.rb
@@ -401,6 +407,7 @@ test_files:
401
407
  - features/area.feature
402
408
  - features/async.feature
403
409
  - features/audio.feature
410
+ - features/bold.feature
404
411
  - features/button.feature
405
412
  - features/canvas.feature
406
413
  - features/check_box.feature
@@ -469,6 +476,7 @@ test_files:
469
476
  - features/step_definitions/area_steps.rb
470
477
  - features/step_definitions/async_steps.rb
471
478
  - features/step_definitions/audio_steps.rb
479
+ - features/step_definitions/bold_steps.rb
472
480
  - features/step_definitions/button_steps.rb
473
481
  - features/step_definitions/canvas_steps.rb
474
482
  - features/step_definitions/check_box_steps.rb
@@ -518,8 +526,10 @@ test_files:
518
526
  - features/text_field.feature
519
527
  - features/unordered_list.feature
520
528
  - features/video.feature
529
+ - spec/page-object/accessors_spec.rb
521
530
  - spec/page-object/element_locators_spec.rb
522
531
  - spec/page-object/elements/area_spec.rb
532
+ - spec/page-object/elements/bold_spec.rb
523
533
  - spec/page-object/elements/button_spec.rb
524
534
  - spec/page-object/elements/canvas_spec.rb
525
535
  - spec/page-object/elements/check_box_spec.rb