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
@@ -10,27 +10,27 @@ describe PageObject::JavascriptFrameworkFacade do
10
10
 
11
11
  it "should allow the selection of a javascript framework" do
12
12
  facade.framework = :jquery
13
- facade.framework.should == :jquery
13
+ expect(facade.framework).to eql :jquery
14
14
  end
15
15
 
16
16
  it "should register the jQuery script builder" do
17
17
  facade.framework = :jquery
18
- facade.script_builder.should == ::PageObject::Javascript::JQuery
18
+ expect(facade.script_builder).to eql ::PageObject::Javascript::JQuery
19
19
  end
20
20
 
21
21
  it "should return script for pending requests in jQuery" do
22
22
  facade.framework = :jquery
23
- facade.pending_requests.should == 'return jQuery.active'
23
+ expect(facade.pending_requests).to eql 'return jQuery.active'
24
24
  end
25
25
 
26
26
  it "should register the Prototype script builder" do
27
27
  facade.framework = :prototype
28
- facade.script_builder.should == ::PageObject::Javascript::Prototype
28
+ expect(facade.script_builder).to eql ::PageObject::Javascript::Prototype
29
29
  end
30
30
 
31
31
  it "should return script for pending requests in Prototype" do
32
32
  facade.framework = :prototype
33
- facade.pending_requests.should == 'return Ajax.activeRequestCount'
33
+ expect(facade.pending_requests).to eql 'return Ajax.activeRequestCount'
34
34
  end
35
35
 
36
36
  it "should not allow you to set the framework to one it does not know about" do
@@ -46,7 +46,7 @@ describe PageObject::JavascriptFrameworkFacade do
46
46
 
47
47
  facade.add_framework(:blah, GoodFake)
48
48
  facade.framework = :blah
49
- facade.pending_requests.should == "fake"
49
+ expect(facade.pending_requests).to eql "fake"
50
50
  end
51
51
 
52
52
  it "should not allow you to add a new javascript framework that is invalid" do
@@ -11,7 +11,7 @@ describe TestLoadsPlatform do
11
11
  before { adapters[:browser_x] = mock_adapter(browser_x, :nom_nom_nom) }
12
12
 
13
13
  it "returns platform nom_nom_nom when asked about browser_x" do
14
- subject.load_platform(browser_x, adapters).should == :nom_nom_nom
14
+ expect(subject.load_platform(browser_x, adapters)).to eql :nom_nom_nom
15
15
  end
16
16
 
17
17
  context "when browser a is registered with platform boom_boom_boom" do
@@ -19,7 +19,7 @@ describe TestLoadsPlatform do
19
19
  before { adapters[:browser_a] = mock_adapter(browser_a, :boom_boom_boom) }
20
20
 
21
21
  it "should return platform nom_nom_nom when asked about browser_x" do
22
- subject.load_platform(browser_x, adapters).should == :nom_nom_nom
22
+ expect(subject.load_platform(browser_x, adapters)).to eql :nom_nom_nom
23
23
  end
24
24
  end
25
25
  end
@@ -29,7 +29,7 @@ describe TestLoadsPlatform do
29
29
  before { adapters[:browser_n] = mock_adapter(browser_n, :boom_boom_boom) }
30
30
 
31
31
  it "should return platform boom_boom_boom" do
32
- subject.load_platform(browser_n, adapters).should == :boom_boom_boom
32
+ expect(subject.load_platform(browser_n, adapters)).to eql :boom_boom_boom
33
33
  end
34
34
  end
35
35
 
@@ -46,7 +46,7 @@ describe TestLoadsPlatform do
46
46
  begin
47
47
  subject.load_platform(nil, {})
48
48
  rescue Exception => e
49
- e.message.should == "#{basic_message}\nnil was passed to the PageObject constructor instead of a valid browser object."
49
+ expect(e.message).to eql "#{basic_message}\nnil was passed to the PageObject constructor instead of a valid browser object."
50
50
  end
51
51
  end
52
52
  end
@@ -15,45 +15,45 @@ describe PageObject do
15
15
 
16
16
  context "setting values on the PageObject module" do
17
17
  it "should set the javascript framework" do
18
- PageObject::JavascriptFrameworkFacade.should_receive(:framework=)
18
+ expect(PageObject::JavascriptFrameworkFacade).to receive(:framework=)
19
19
  PageObject.javascript_framework = :foo
20
20
  end
21
21
 
22
22
  it "should add a new Javascript Framework" do
23
- PageObject::JavascriptFrameworkFacade.should_receive(:add_framework)
23
+ expect(PageObject::JavascriptFrameworkFacade).to receive(:add_framework)
24
24
  PageObject.add_framework(:foo, :bar)
25
25
  end
26
26
 
27
27
  it "should set a default page wait value" do
28
28
  PageObject.default_page_wait = 20
29
29
  wait = PageObject.instance_variable_get("@page_wait")
30
- wait.should == 20
30
+ expect(wait).to eql 20
31
31
  end
32
32
 
33
33
  it "should provide the default page wait value" do
34
34
  PageObject.instance_variable_set("@page_wait", 10)
35
- PageObject.default_page_wait.should == 10
35
+ expect(PageObject.default_page_wait).to eql 10
36
36
  end
37
37
 
38
38
  it "should default the page wait value to 30" do
39
39
  PageObject.instance_variable_set("@page_wait", nil)
40
- PageObject.default_page_wait.should == 30
40
+ expect(PageObject.default_page_wait).to eql 30
41
41
  end
42
42
 
43
43
  it "should set the default element wait value" do
44
44
  PageObject.default_element_wait = 20
45
45
  wait = PageObject.instance_variable_get("@element_wait")
46
- wait.should == 20
46
+ expect(wait).to eql 20
47
47
  end
48
48
 
49
49
  it "should provide the default element wait value" do
50
50
  PageObject.instance_variable_set("@element_wait", 10)
51
- PageObject.default_element_wait.should == 10
51
+ expect(PageObject.default_element_wait).to eql 10
52
52
  end
53
53
 
54
54
  it "should default the element wait to 5" do
55
55
  PageObject.instance_variable_set("@element_wait", nil)
56
- PageObject.default_element_wait.should == 5
56
+ expect(PageObject.default_element_wait).to eql 5
57
57
  end
58
58
  end
59
59
 
@@ -61,38 +61,39 @@ describe PageObject do
61
61
  it "should set the params value" do
62
62
  PageObjectTestPageObject.params = {:some => :value}
63
63
  params = PageObjectTestPageObject.instance_variable_get("@params")
64
- params[:some].should == :value
64
+ expect(params[:some]).to eql :value
65
65
  end
66
66
 
67
67
  it "should provide the params value" do
68
68
  PageObjectTestPageObject.instance_variable_set("@params", {:value => :updated})
69
- PageObjectTestPageObject.params[:value].should == :updated
69
+ expect(PageObjectTestPageObject.params[:value]).to eql :updated
70
70
  end
71
71
 
72
72
  it "should default the params to an empty hash" do
73
73
  PageObjectTestPageObject.instance_variable_set("@params", nil)
74
- PageObjectTestPageObject.params.should == {}
74
+ expect(PageObjectTestPageObject.params).to eql Hash.new
75
75
  end
76
76
  end
77
77
 
78
78
  context "when created with a watir-webdriver browser" do
79
79
  it "should include the WatirPageObject module" do
80
- watir_page_object.platform.should be_kind_of PageObject::Platforms::WatirWebDriver::PageObject
80
+ expect(watir_page_object.platform).to be_kind_of PageObject::Platforms::WatirWebDriver::PageObject
81
81
  end
82
82
  end
83
83
 
84
84
  context "when created with a selenium browser" do
85
85
  it "should include the SeleniumPageObject module" do
86
- selenium_page_object.platform.should be_kind_of PageObject::Platforms::SeleniumWebDriver::PageObject
86
+ expect(selenium_page_object.platform).to be_kind_of PageObject::Platforms::SeleniumWebDriver::PageObject
87
87
  end
88
88
  end
89
89
 
90
90
  context "when created with a non_bundled adapter" do
91
91
  let(:custom_adapter) { mock_adapter(:custom_browser, CustomPlatform) }
92
+
92
93
  it "should be an instance of whatever that objects adapter is" do
93
94
  mock_adapters({:custom_adapter=>custom_adapter})
94
95
  custom_page_object = PageObjectTestPageObject.new(:custom_browser)
95
- custom_page_object.platform.should be custom_adapter.create_page_object
96
+ expect(custom_page_object.platform).to be custom_adapter.create_page_object
96
97
  end
97
98
  end
98
99
 
@@ -107,8 +108,8 @@ describe PageObject do
107
108
  describe "page level functionality" do
108
109
  context "for all drivers" do
109
110
  it "should try a second time after sleeping when attach to window fails" do
110
- watir_page_object.platform.should_receive(:attach_to_window).once.and_throw "error"
111
- watir_page_object.platform.should_receive(:attach_to_window)
111
+ expect(watir_page_object.platform).to receive(:attach_to_window).once.and_throw "error"
112
+ expect(watir_page_object.platform).to receive(:attach_to_window)
112
113
  watir_page_object.attach_to_window("blah")
113
114
  end
114
115
 
@@ -123,7 +124,7 @@ describe PageObject do
123
124
  end
124
125
 
125
126
  @page = CallbackPage.new(watir_browser)
126
- @page.initialize_page_called.should be true
127
+ expect(@page.initialize_page_called).to be true
127
128
  end
128
129
 
129
130
  it "should call initialize_accessors if it exists" do
@@ -137,7 +138,7 @@ describe PageObject do
137
138
  end
138
139
 
139
140
  @page = CallbackPage.new(watir_browser)
140
- @page.initialize_accessors_called.should be true
141
+ expect(@page.initialize_accessors_called).to be true
141
142
  end
142
143
 
143
144
  it "should call initialize_accessors before initialize_page if both exist" do
@@ -155,249 +156,249 @@ describe PageObject do
155
156
  end
156
157
 
157
158
  @page = CallbackPage.new(watir_browser)
158
- @page.initialize_accessors.usec.should be <= @page.initialize_page.usec
159
+ expect(@page.initialize_accessors.usec).to be <= @page.initialize_page.usec
159
160
  end
160
161
 
161
162
  it "should know which element has focus" do
162
- watir_browser.should_receive(:execute_script).and_return(watir_browser)
163
- watir_browser.should_receive(:tag_name).twice.and_return(:input)
164
- watir_browser.should_receive(:type).and_return(:submit)
165
- watir_page_object.element_with_focus.class.should == PageObject::Elements::Button
163
+ expect(watir_browser).to receive(:execute_script).and_return(watir_browser)
164
+ expect(watir_browser).to receive(:tag_name).twice.and_return(:input)
165
+ expect(watir_browser).to receive(:type).and_return(:submit)
166
+ expect(watir_page_object.element_with_focus.class).to eql PageObject::Elements::Button
166
167
  end
167
168
  end
168
169
 
169
170
  context "when using WatirPageObject" do
170
171
  it "should display the page text" do
171
- watir_browser.should_receive(:text).and_return("browser text")
172
- watir_page_object.text.should == "browser text"
172
+ expect(watir_browser).to receive(:text).and_return("browser text")
173
+ expect(watir_page_object.text).to eql "browser text"
173
174
  end
174
175
 
175
176
  it "should display the html of the page" do
176
- watir_browser.should_receive(:html).and_return("<html>Some Sample HTML</html>")
177
- watir_page_object.html.should == "<html>Some Sample HTML</html>"
177
+ expect(watir_browser).to receive(:html).and_return("<html>Some Sample HTML</html>")
178
+ expect(watir_page_object.html).to eql "<html>Some Sample HTML</html>"
178
179
  end
179
180
 
180
181
  it "should display the title of the page" do
181
- watir_browser.should_receive(:title).and_return("I am the title of a page")
182
- watir_page_object.title.should == "I am the title of a page"
182
+ expect(watir_browser).to receive(:title).and_return("I am the title of a page")
183
+ expect(watir_page_object.title).to eql "I am the title of a page"
183
184
  end
184
185
 
185
186
  it "should be able to navigate to a page" do
186
- watir_browser.should_receive(:goto).with("cheezyworld.com")
187
+ expect(watir_browser).to receive(:goto).with("cheezyworld.com")
187
188
  watir_page_object.navigate_to("cheezyworld.com")
188
189
  end
189
190
 
190
191
  it "should wait until a block returns true" do
191
- watir_browser.should_receive(:wait_until).with(5, "too long")
192
+ expect(watir_browser).to receive(:wait_until).with(5, "too long")
192
193
  watir_page_object.wait_until(5, "too long")
193
194
  end
194
195
 
195
196
  it "should use the overriden timeout value when set" do
196
197
  PageObject.default_page_wait = 10
197
- watir_browser.should_receive(:wait_until).with(10, nil)
198
+ expect(watir_browser).to receive(:wait_until).with(10, nil)
198
199
  watir_page_object.wait_until
199
200
  end
200
201
 
201
202
  it "should wait until there are no pending ajax requests" do
202
- PageObject::JavascriptFrameworkFacade.should_receive(:pending_requests).and_return('pending requests')
203
- watir_browser.should_receive(:execute_script).with('pending requests').and_return(0)
203
+ expect(PageObject::JavascriptFrameworkFacade).to receive(:pending_requests).and_return('pending requests')
204
+ expect(watir_browser).to receive(:execute_script).with('pending requests').and_return(0)
204
205
  watir_page_object.wait_for_ajax
205
206
  end
206
207
 
207
208
  it "should override alert popup behavior" do
208
- watir_browser.should_receive(:alert).exactly(3).times.and_return(watir_browser)
209
- watir_browser.should_receive(:exists?).and_return(true)
210
- watir_browser.should_receive(:text)
211
- watir_browser.should_receive(:ok)
209
+ expect(watir_browser).to receive(:alert).exactly(3).times.and_return(watir_browser)
210
+ expect(watir_browser).to receive(:exists?).and_return(true)
211
+ expect(watir_browser).to receive(:text)
212
+ expect(watir_browser).to receive(:ok)
212
213
  watir_page_object.alert do
213
214
  end
214
215
  end
215
216
 
216
217
  it "should override confirm popup behavior" do
217
- watir_browser.should_receive(:alert).exactly(3).times.and_return(watir_browser)
218
- watir_browser.should_receive(:exists?).and_return(true)
219
- watir_browser.should_receive(:text)
220
- watir_browser.should_receive(:ok)
218
+ expect(watir_browser).to receive(:alert).exactly(3).times.and_return(watir_browser)
219
+ expect(watir_browser).to receive(:exists?).and_return(true)
220
+ expect(watir_browser).to receive(:text)
221
+ expect(watir_browser).to receive(:ok)
221
222
  watir_page_object.confirm(true) do
222
223
  end
223
224
  end
224
225
 
225
226
  it "should override prompt popup behavior" do
226
- watir_browser.should_receive(:wd).twice.and_return(watir_browser)
227
- watir_browser.should_receive(:execute_script).twice
227
+ expect(watir_browser).to receive(:wd).twice.and_return(watir_browser)
228
+ expect(watir_browser).to receive(:execute_script).twice
228
229
  watir_page_object.prompt("blah") do
229
230
  end
230
231
  end
231
232
 
232
233
  it "should execute javascript on the browser" do
233
- watir_browser.should_receive(:execute_script).and_return("abc")
234
- watir_page_object.execute_script("333").should == "abc"
234
+ expect(watir_browser).to receive(:execute_script).and_return("abc")
235
+ expect(watir_page_object.execute_script("333")).to eql "abc"
235
236
  end
236
237
 
237
238
  it "should convert a modal popup to a window" do
238
- watir_browser.should_receive(:execute_script)
239
+ expect(watir_browser).to receive(:execute_script)
239
240
  watir_page_object.modal_dialog {}
240
241
  end
241
242
 
242
243
  it "should switch to a new window with a given title" do
243
- watir_browser.should_receive(:window).with(:title => /My\ Title/).and_return(watir_browser)
244
- watir_browser.should_receive(:use)
244
+ expect(watir_browser).to receive(:window).with(:title => /My\ Title/).and_return(watir_browser)
245
+ expect(watir_browser).to receive(:use)
245
246
  watir_page_object.attach_to_window(:title => "My Title")
246
247
  end
247
248
 
248
249
  it "should switch to a new window with a given url" do
249
- watir_browser.should_receive(:window).with(:url => /success\.html/).and_return(watir_browser)
250
- watir_browser.should_receive(:use)
250
+ expect(watir_browser).to receive(:window).with(:url => /success\.html/).and_return(watir_browser)
251
+ expect(watir_browser).to receive(:use)
251
252
  watir_page_object.attach_to_window(:url => "success.html")
252
253
  end
253
254
 
254
255
  it "should refresh the page contents" do
255
- watir_browser.should_receive(:refresh)
256
+ expect(watir_browser).to receive(:refresh)
256
257
  watir_page_object.refresh
257
258
  end
258
259
 
259
260
  it "should know how to go back" do
260
- watir_browser.should_receive(:back)
261
+ expect(watir_browser).to receive(:back)
261
262
  watir_page_object.back
262
263
  end
263
264
 
264
265
  it "should know how to go forward" do
265
- watir_browser.should_receive(:forward)
266
+ expect(watir_browser).to receive(:forward)
266
267
  watir_page_object.forward
267
268
  end
268
269
 
269
270
  it "should know its' current url" do
270
- watir_browser.should_receive(:url).and_return("cheezyworld.com")
271
- watir_page_object.current_url.should == "cheezyworld.com"
271
+ expect(watir_browser).to receive(:url).and_return("cheezyworld.com")
272
+ expect(watir_page_object.current_url).to eql "cheezyworld.com"
272
273
  end
273
274
 
274
275
  it "should know how to clear all of the cookies from the browser" do
275
- watir_browser.should_receive(:cookies).and_return(watir_browser)
276
- watir_browser.should_receive(:clear)
276
+ expect(watir_browser).to receive(:cookies).and_return(watir_browser)
277
+ expect(watir_browser).to receive(:clear)
277
278
  watir_page_object.clear_cookies
278
279
  end
279
280
 
280
281
  it "should be able to save a screenshot" do
281
- watir_browser.should_receive(:wd).and_return(watir_browser)
282
- watir_browser.should_receive(:save_screenshot)
282
+ expect(watir_browser).to receive(:wd).and_return(watir_browser)
283
+ expect(watir_browser).to receive(:save_screenshot)
283
284
  watir_page_object.save_screenshot("test.png")
284
285
  end
285
286
  end
286
287
 
287
288
  context "when using SeleniumPageObject" do
288
289
  it "should display the page text" do
289
- selenium_browser.stub_chain(:find_element, :text).and_return("browser text")
290
- selenium_page_object.text.should == "browser text"
290
+ expect(selenium_browser).to receive_messages(find_element: selenium_browser, text: 'browser text')
291
+ expect(selenium_page_object.text).to eql "browser text"
291
292
  end
292
293
 
293
294
  it "should display the html of the page" do
294
- selenium_browser.should_receive(:page_source).and_return("<html>Some Sample HTML</html>")
295
- selenium_page_object.html.should == "<html>Some Sample HTML</html>"
295
+ expect(selenium_browser).to receive(:page_source).and_return("<html>Some Sample HTML</html>")
296
+ expect(selenium_page_object.html).to eql "<html>Some Sample HTML</html>"
296
297
  end
297
298
 
298
299
  it "should display the title of the page" do
299
- selenium_browser.should_receive(:title).and_return("I am the title of a page")
300
- selenium_page_object.title.should == "I am the title of a page"
300
+ expect(selenium_browser).to receive(:title).and_return("I am the title of a page")
301
+ expect(selenium_page_object.title).to eql "I am the title of a page"
301
302
  end
302
303
 
303
304
  it "should be able to navigate to a page" do
304
- selenium_browser.stub_chain(:navigate, :to).with('cheezyworld.com')
305
+ expect(selenium_browser).to receive_messages(navigate: selenium_browser, to: 'cheezyworld.com')
305
306
  selenium_page_object.navigate_to('cheezyworld.com')
306
307
  end
307
308
 
308
309
  it "should wait until a block returns true" do
309
310
  wait = double('wait')
310
- Selenium::WebDriver::Wait.should_receive(:new).with({:timeout => 5, :message => 'too long'}).and_return(wait)
311
- wait.should_receive(:until)
311
+ expect(Selenium::WebDriver::Wait).to receive(:new).with({:timeout => 5, :message => 'too long'}).and_return(wait)
312
+ expect(wait).to receive(:until)
312
313
  selenium_page_object.wait_until(5, 'too long')
313
314
  end
314
315
 
315
316
  it "should wait until there are no pending ajax requests" do
316
- PageObject::JavascriptFrameworkFacade.should_receive(:pending_requests).and_return('pending requests')
317
- selenium_browser.should_receive(:execute_script).with('pending requests').and_return(0)
317
+ expect(PageObject::JavascriptFrameworkFacade).to receive(:pending_requests).and_return('pending requests')
318
+ expect(selenium_browser).to receive(:execute_script).with('pending requests').and_return(0)
318
319
  selenium_page_object.wait_for_ajax
319
320
  end
320
321
 
321
322
  it "should override alert popup behavior" do
322
- selenium_browser.should_receive(:switch_to).and_return(selenium_browser)
323
- selenium_browser.should_receive(:alert).and_return(selenium_browser)
324
- selenium_browser.should_receive(:text)
325
- selenium_browser.should_receive(:accept)
323
+ expect(selenium_browser).to receive(:switch_to).and_return(selenium_browser)
324
+ expect(selenium_browser).to receive(:alert).and_return(selenium_browser)
325
+ expect(selenium_browser).to receive(:text)
326
+ expect(selenium_browser).to receive(:accept)
326
327
  selenium_page_object.alert do
327
328
  end
328
329
  end
329
330
 
330
331
  it "should override confirm popup behavior" do
331
- selenium_browser.should_receive(:switch_to).and_return(selenium_browser)
332
- selenium_browser.should_receive(:alert).and_return(selenium_browser)
333
- selenium_browser.should_receive(:text)
334
- selenium_browser.should_receive(:accept)
332
+ expect(selenium_browser).to receive(:switch_to).and_return(selenium_browser)
333
+ expect(selenium_browser).to receive(:alert).and_return(selenium_browser)
334
+ expect(selenium_browser).to receive(:text)
335
+ expect(selenium_browser).to receive(:accept)
335
336
  selenium_page_object.confirm(true) do
336
337
  end
337
338
  end
338
339
  it "should override prompt popup behavior" do
339
- selenium_browser.should_receive(:execute_script).twice
340
+ expect(selenium_browser).to receive(:execute_script).twice
340
341
  selenium_page_object.prompt("blah") do
341
342
  end
342
343
  end
343
344
 
344
345
  it "should convert a modal popup to a window" do
345
- selenium_browser.should_receive(:execute_script)
346
+ expect(selenium_browser).to receive(:execute_script)
346
347
  selenium_page_object.modal_dialog {}
347
348
  end
348
349
 
349
350
  it "should execute javascript on the browser" do
350
- selenium_browser.should_receive(:execute_script).and_return("abc")
351
- selenium_page_object.execute_script("333").should == "abc"
351
+ expect(selenium_browser).to receive(:execute_script).and_return("abc")
352
+ expect(selenium_page_object.execute_script("333")).to eql "abc"
352
353
  end
353
354
 
354
355
  it "should switch to a new window with a given title" do
355
- selenium_browser.should_receive(:window_handles).and_return(["win1"])
356
- selenium_browser.should_receive(:switch_to).twice.and_return(selenium_browser)
357
- selenium_browser.should_receive(:window).twice.with("win1").and_return(selenium_browser)
358
- selenium_browser.should_receive(:title).and_return("My Title")
356
+ expect(selenium_browser).to receive(:window_handles).and_return(["win1"])
357
+ expect(selenium_browser).to receive(:switch_to).twice.and_return(selenium_browser)
358
+ expect(selenium_browser).to receive(:window).twice.with("win1").and_return(selenium_browser)
359
+ expect(selenium_browser).to receive(:title).and_return("My Title")
359
360
  selenium_page_object.attach_to_window(:title => "My Title")
360
361
  end
361
362
 
362
363
  it "should switch to a new window with a given url" do
363
- selenium_browser.should_receive(:window_handles).and_return(["win1"])
364
- selenium_browser.should_receive(:switch_to).twice.and_return(selenium_browser)
365
- selenium_browser.should_receive(:window).twice.with("win1").and_return(selenium_browser)
366
- selenium_browser.should_receive(:current_url).and_return("page.html")
364
+ expect(selenium_browser).to receive(:window_handles).and_return(["win1"])
365
+ expect(selenium_browser).to receive(:switch_to).twice.and_return(selenium_browser)
366
+ expect(selenium_browser).to receive(:window).twice.with("win1").and_return(selenium_browser)
367
+ expect(selenium_browser).to receive(:current_url).and_return("page.html")
367
368
  selenium_page_object.attach_to_window(:url => "page.html")
368
369
  end
369
370
 
370
371
  it "should refresh the page contents" do
371
- selenium_browser.should_receive(:navigate).and_return(selenium_browser)
372
- selenium_browser.should_receive(:refresh)
372
+ expect(selenium_browser).to receive(:navigate).and_return(selenium_browser)
373
+ expect(selenium_browser).to receive(:refresh)
373
374
  selenium_page_object.refresh
374
375
  end
375
376
 
376
377
  it "should know how to go back" do
377
- selenium_browser.should_receive(:navigate).and_return(selenium_browser)
378
- selenium_browser.should_receive(:back)
378
+ expect(selenium_browser).to receive(:navigate).and_return(selenium_browser)
379
+ expect(selenium_browser).to receive(:back)
379
380
  selenium_page_object.back
380
381
  end
381
382
 
382
383
  it "should know how to go forward" do
383
- selenium_browser.should_receive(:navigate).and_return(selenium_browser)
384
- selenium_browser.should_receive(:forward)
384
+ expect(selenium_browser).to receive(:navigate).and_return(selenium_browser)
385
+ expect(selenium_browser).to receive(:forward)
385
386
  selenium_page_object.forward
386
387
  end
387
388
 
388
389
  it "should know its' current url" do
389
- selenium_browser.should_receive(:current_url).and_return("cheezyworld.com")
390
- selenium_page_object.current_url.should == "cheezyworld.com"
390
+ expect(selenium_browser).to receive(:current_url).and_return("cheezyworld.com")
391
+ expect(selenium_page_object.current_url).to eql "cheezyworld.com"
391
392
  end
392
393
 
393
394
  it "should clear all of the cookies from the browser" do
394
- selenium_browser.should_receive(:manage).and_return(selenium_browser)
395
- selenium_browser.should_receive(:delete_all_cookies)
395
+ expect(selenium_browser).to receive(:manage).and_return(selenium_browser)
396
+ expect(selenium_browser).to receive(:delete_all_cookies)
396
397
  selenium_page_object.clear_cookies
397
398
  end
398
399
 
399
400
  it "should be able to save a screenshot" do
400
- selenium_browser.should_receive(:save_screenshot)
401
+ expect(selenium_browser).to receive(:save_screenshot)
401
402
  selenium_page_object.save_screenshot("test.png")
402
403
  end
403
404
  end