page-object 0.6.7 → 0.6.8

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.
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.6.7
4
+ version: 0.6.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,33 +9,33 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-17 00:00:00.000000000 Z
12
+ date: 2012-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir-webdriver
16
- requirement: &70136515814060 !ruby/object:Gem::Requirement
16
+ requirement: &70276232212840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.5.8
21
+ version: 0.6.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70136515814060
24
+ version_requirements: *70276232212840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: selenium-webdriver
27
- requirement: &70136515813300 !ruby/object:Gem::Requirement
27
+ requirement: &70276232228720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 2.21.2
32
+ version: 2.22.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70136515813300
35
+ version_requirements: *70276232228720
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70136515812620 !ruby/object:Gem::Requirement
38
+ requirement: &70276232228260 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.6.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70136515812620
46
+ version_requirements: *70276232228260
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: cucumber
49
- requirement: &70136515811900 !ruby/object:Gem::Requirement
49
+ requirement: &70276232227800 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - <
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.2.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70136515811900
57
+ version_requirements: *70276232227800
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: yard
60
- requirement: &70136515811220 !ruby/object:Gem::Requirement
60
+ requirement: &70276232227340 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.7.2
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70136515811220
68
+ version_requirements: *70276232227340
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rack
71
- requirement: &70136515810500 !ruby/object:Gem::Requirement
71
+ requirement: &70276232226880 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '1.0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70136515810500
79
+ version_requirements: *70276232226880
80
80
  description: Page Object DSL that works with both Watir and Selenium
81
81
  email:
82
82
  - jeff.morgan@leandog.com
@@ -259,7 +259,6 @@ files:
259
259
  - lib/page-object/platforms/watir_webdriver/unordered_list.rb
260
260
  - lib/page-object/version.rb
261
261
  - page-object.gemspec
262
- - spec/page-object/accessors_spec.rb
263
262
  - spec/page-object/element_locators_spec.rb
264
263
  - spec/page-object/elements/button_spec.rb
265
264
  - spec/page-object/elements/check_box_spec.rb
@@ -296,6 +295,8 @@ files:
296
295
  - spec/page-object/platforms/selenium_webdriver/selenium_page_object_spec.rb
297
296
  - spec/page-object/platforms/selenium_webdriver_spec.rb
298
297
  - spec/page-object/platforms/watir_webdriver_spec.rb
298
+ - spec/page-object/selenium_accessors_spec.rb
299
+ - spec/page-object/watir_accessors_spec.rb
299
300
  - spec/spec_helper.rb
300
301
  homepage: http://github.com/cheezy/page-object
301
302
  licenses: []
@@ -414,7 +415,6 @@ test_files:
414
415
  - features/text_area.feature
415
416
  - features/text_field.feature
416
417
  - features/unordered_list.feature
417
- - spec/page-object/accessors_spec.rb
418
418
  - spec/page-object/element_locators_spec.rb
419
419
  - spec/page-object/elements/button_spec.rb
420
420
  - spec/page-object/elements/check_box_spec.rb
@@ -451,5 +451,7 @@ test_files:
451
451
  - spec/page-object/platforms/selenium_webdriver/selenium_page_object_spec.rb
452
452
  - spec/page-object/platforms/selenium_webdriver_spec.rb
453
453
  - spec/page-object/platforms/watir_webdriver_spec.rb
454
+ - spec/page-object/selenium_accessors_spec.rb
455
+ - spec/page-object/watir_accessors_spec.rb
454
456
  - spec/spec_helper.rb
455
457
  has_rdoc:
@@ -1,1455 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class AccessorsTestPageObject
4
- include PageObject
5
-
6
- page_url "http://apple.com"
7
- expected_title "Expected Title"
8
- expected_element :google_search
9
- link(:google_search, :link => 'Google Search')
10
- text_field(:first_name, :id => 'first_name')
11
- hidden_field(:social_security_number, :id => 'ssn')
12
- text_area(:address, :id => 'address')
13
- select_list(:state, :id => 'state')
14
- checkbox(:active, :id => 'is_active_id')
15
- radio_button(:first, :id => 'first_choice')
16
- button(:click_me, :id => 'button_submit')
17
- div(:message, :id => 'message_id')
18
- table(:cart, :id => 'cart_id')
19
- cell(:total, :id => 'total')
20
- span(:alert, :id => 'alert_id')
21
- image(:logo, :id => 'logo')
22
- form(:login, :id => 'login')
23
- list_item(:item_one, :id => 'one')
24
- unordered_list(:menu, :id => 'main_menu')
25
- ordered_list(:top_five, :id => 'top')
26
- h1(:heading1, :id => 'main_heading')
27
- h2(:heading2, :id => 'main_heading')
28
- h3(:heading3, :id => 'main_heading')
29
- h4(:heading4, :id => 'main_heading')
30
- h5(:heading5, :id => 'main_heading')
31
- h6(:heading6, :id => 'main_heading')
32
- paragraph(:first_para, :id => 'first')
33
- file_field(:upload_me, :id => 'the_file')
34
- end
35
-
36
- class BlockPageObject
37
- include PageObject
38
-
39
- attr_reader :value
40
-
41
- text_field :first_name do |element|
42
- "text_field"
43
- end
44
- hidden_field :secret do |element|
45
- "hidden_field"
46
- end
47
- text_area :address do |element|
48
- "text_area"
49
- end
50
- select_list :state do |element|
51
- "select_list"
52
- end
53
- link :continue do |element|
54
- "link"
55
- end
56
- checkbox :active do |element|
57
- "checkbox"
58
- end
59
- radio_button :first do |element|
60
- "radio_button"
61
- end
62
- button :click_me do |element|
63
- "button"
64
- end
65
- div :footer do |element|
66
- "div"
67
- end
68
- span :alert do |element|
69
- "span"
70
- end
71
- table :cart do |element|
72
- "table"
73
- end
74
- cell :total do |element|
75
- "cell"
76
- end
77
- image :logo do |element|
78
- "image"
79
- end
80
- form :login do |element|
81
- "form"
82
- end
83
- list_item :item_one do |element|
84
- "list_item"
85
- end
86
- unordered_list :menu do |element|
87
- "unordered_list"
88
- end
89
- ordered_list :top_five do |element|
90
- "ordered_list"
91
- end
92
- h1 :heading1 do |element|
93
- "h1"
94
- end
95
- h2 :heading2 do |element|
96
- "h2"
97
- end
98
- h3 :heading3 do |element|
99
- "h3"
100
- end
101
- h4 :heading4 do |element|
102
- "h4"
103
- end
104
- h5 :heading5 do |element|
105
- "h5"
106
- end
107
- h6 :heading6 do |element|
108
- "h6"
109
- end
110
- paragraph :first_para do |element|
111
- "p"
112
- end
113
- file_field :a_file do |element|
114
- "file_field"
115
- end
116
- end
117
-
118
- describe PageObject::Accessors do
119
- let(:watir_browser) { mock_watir_browser }
120
- let(:selenium_browser) { mock_selenium_browser }
121
- let(:watir_page_object) { AccessorsTestPageObject.new(watir_browser) }
122
- let(:selenium_page_object) { AccessorsTestPageObject.new(selenium_browser) }
123
- let(:block_page_object) { BlockPageObject.new(watir_browser) }
124
-
125
- before(:each) do
126
- selenium_browser.stub(:switch_to).and_return(selenium_browser)
127
- selenium_browser.stub(:default_content)
128
- end
129
-
130
- describe "goto a page" do
131
- it "should navigate to a page when requested" do
132
- watir_browser.should_receive(:goto)
133
- AccessorsTestPageObject.new(watir_browser, true)
134
- end
135
-
136
- it "should call a method when page_url called with a symbol" do
137
- class SymbolPageUrl
138
- include PageObject
139
- page_url :custom_url
140
- def custom_url
141
- "custom"
142
- end
143
- end
144
- watir_browser.should_receive(:goto).with('custom')
145
- SymbolPageUrl.new(watir_browser, true)
146
- end
147
-
148
- it "should not navigate to a page when not requested" do
149
- watir_browser.should_not_receive(:goto)
150
- AccessorsTestPageObject.new(watir_browser)
151
- end
152
-
153
- it "should not navigate to a page when 'page_url' not specified" do
154
- watir_browser.should_not_receive(:goto)
155
- BlockPageObject.new(watir_browser, true)
156
- end
157
- end
158
-
159
- describe "validating the page title" do
160
- it "should validate the title" do
161
- watir_browser.should_receive(:title).and_return("Expected Title")
162
- watir_page_object.should have_expected_title
163
- end
164
-
165
- it "should raise error when it does not have expected title" do
166
- watir_browser.should_receive(:title).twice.and_return("Not Expected")
167
- expect { watir_page_object.has_expected_title? }.to raise_error
168
- end
169
- end
170
-
171
- describe "validating the existence of an element" do
172
- it "should validate an element exists" do
173
- watir_page_object.should_receive(:google_search_element).and_return(watir_browser)
174
- watir_browser.should_receive(:when_present).and_return(true)
175
- watir_page_object.has_expected_element?
176
- end
177
-
178
- it "should handle non-existent elements gracefully" do
179
- class FakePage
180
- include PageObject
181
- expected_element :foo
182
- end
183
- FakePage.new(watir_browser).should_not have_expected_element
184
- end
185
- end
186
-
187
- describe "using default identifiers" do
188
- class DefaultIdentifier
189
- include PageObject
190
- text_field(:default_tf)
191
- hidden_field(:default_hf)
192
- text_area(:default_ta)
193
- select_list(:default_sl)
194
- link(:default_link)
195
- checkbox(:default_cb)
196
- radio_button(:default_rb)
197
- button(:default_but)
198
- div(:default_div)
199
- span(:default_span)
200
- table(:default_tab)
201
- cell(:default_cell)
202
- image(:default_im)
203
- form(:default_form)
204
- list_item(:default_li)
205
- unordered_list(:default_ul)
206
- ordered_list(:default_ol)
207
- h1(:default_h1)
208
- h2(:default_h2)
209
- h3(:default_h3)
210
- h4(:default_h4)
211
- h5(:default_h5)
212
- h6(:default_h6)
213
- paragraph(:default_p)
214
- file_field(:default_ff)
215
- label(:default_lab)
216
- element(:default_el, :audio)
217
- end
218
-
219
- let(:default_identifier) { DefaultIdentifier.new(watir_browser) }
220
-
221
- before(:each) do
222
- watir_browser.should_receive(:exists?).and_return(true)
223
- end
224
-
225
- def mock_driver_for(tag)
226
- watir_browser.should_receive(tag).with(:index => 0).and_return(watir_browser)
227
- end
228
-
229
- it "should work with a text_field" do
230
- mock_driver_for :text_field
231
- default_identifier.default_tf?
232
- end
233
-
234
- it "should work with a hidden field" do
235
- mock_driver_for :hidden
236
- default_identifier.default_hf?
237
- end
238
-
239
- it "should work with a text area" do
240
- mock_driver_for :textarea
241
- default_identifier.default_ta?
242
- end
243
-
244
- it "should work with a select list" do
245
- mock_driver_for :select_list
246
- default_identifier.default_sl?
247
- end
248
-
249
- it "should work with a link" do
250
- mock_driver_for :link
251
- default_identifier.default_link?
252
- end
253
-
254
- it "should work with a checkbox" do
255
- mock_driver_for :checkbox
256
- default_identifier.default_cb?
257
- end
258
-
259
- it "should work with a radio button" do
260
- mock_driver_for :radio
261
- default_identifier.default_rb?
262
- end
263
-
264
- it "should work with a button" do
265
- mock_driver_for :button
266
- default_identifier.default_but?
267
- end
268
-
269
- it "should work with a div" do
270
- mock_driver_for :div
271
- default_identifier.default_div?
272
- end
273
-
274
- it "should work with a span" do
275
- mock_driver_for :span
276
- default_identifier.default_span?
277
- end
278
-
279
- it "should work for a table" do
280
- mock_driver_for :table
281
- default_identifier.default_tab?
282
- end
283
-
284
- it "should work for a cell" do
285
- mock_driver_for :td
286
- default_identifier.default_cell?
287
- end
288
-
289
- it "should work for an image" do
290
- mock_driver_for :image
291
- default_identifier.default_im?
292
- end
293
-
294
- it "should work for a form" do
295
- mock_driver_for :form
296
- default_identifier.default_form?
297
- end
298
-
299
- it "should work for a list item" do
300
- mock_driver_for :li
301
- default_identifier.default_li?
302
- end
303
-
304
- it "should work for unordered lists" do
305
- mock_driver_for :ul
306
- default_identifier.default_ul?
307
- end
308
-
309
- it "should work for ordered lists" do
310
- mock_driver_for :ol
311
- default_identifier.default_ol?
312
- end
313
-
314
- it "should work for h1" do
315
- mock_driver_for :h1
316
- default_identifier.default_h1?
317
- end
318
-
319
- it "should work for h2" do
320
- mock_driver_for :h2
321
- default_identifier.default_h2?
322
- end
323
-
324
- it "should work for h3" do
325
- mock_driver_for :h3
326
- default_identifier.default_h3?
327
- end
328
-
329
- it "should work for a h4" do
330
- mock_driver_for :h4
331
- default_identifier.default_h4?
332
- end
333
-
334
- it "should work for a h5" do
335
- mock_driver_for :h5
336
- default_identifier.default_h5?
337
- end
338
-
339
- it "should work for a h6" do
340
- mock_driver_for :h6
341
- default_identifier.default_h6?
342
- end
343
-
344
- it "should work with a paragraph" do
345
- mock_driver_for :p
346
- default_identifier.default_p?
347
- end
348
-
349
- it "should work with a file_field" do
350
- mock_driver_for :file_field
351
- default_identifier.default_ff?
352
- end
353
-
354
- it "should work with a label" do
355
- mock_driver_for :label
356
- default_identifier.default_lab?
357
- end
358
-
359
- it "should work with an element" do
360
- mock_driver_for :audio
361
- default_identifier.default_el?
362
- end
363
-
364
- end
365
-
366
- describe "link accessors" do
367
- context "when called on a page object" do
368
- it "should generate accessor methods" do
369
- watir_page_object.should respond_to(:google_search)
370
- watir_page_object.should respond_to(:google_search_element)
371
- watir_page_object.should respond_to(:google_search_link)
372
- end
373
-
374
- it "should call a block on the element method when present" do
375
- block_page_object.continue_element.should == "link"
376
- end
377
- end
378
-
379
- context "Watir implementation" do
380
- it "should select a link" do
381
- watir_browser.stub_chain(:link, :click)
382
- watir_page_object.google_search
383
- end
384
-
385
- it "should return a link element" do
386
- watir_browser.should_receive(:link).and_return(watir_browser)
387
- element = watir_page_object.google_search_element
388
- element.should be_instance_of PageObject::Elements::Link
389
- end
390
- end
391
-
392
- context "Selenium implementation" do
393
- it "should select a link" do
394
- selenium_browser.stub_chain(:find_element, :click)
395
- selenium_page_object.google_search
396
- end
397
-
398
- it "should return a link element" do
399
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
400
- element = selenium_page_object.google_search_element
401
- element.should be_instance_of PageObject::Elements::Link
402
- end
403
- end
404
- end
405
-
406
-
407
- describe "text_field accessors" do
408
- context "when called on a page object" do
409
- it "should generate accessor methods" do
410
- watir_page_object.should respond_to(:first_name)
411
- watir_page_object.should respond_to(:first_name=)
412
- watir_page_object.should respond_to(:first_name_element)
413
- watir_page_object.should respond_to(:first_name_text_field)
414
- watir_page_object.should respond_to(:first_name?)
415
- end
416
-
417
- it "should call a block on the element method when present" do
418
- block_page_object.first_name_element.should == "text_field"
419
- end
420
- end
421
-
422
- context "Watir implementation" do
423
- it "should get the text from the text field element" do
424
- watir_browser.should_receive(:text_field).and_return(watir_browser)
425
- watir_browser.should_receive(:value).and_return('Kim')
426
- watir_page_object.first_name.should == 'Kim'
427
- end
428
-
429
- it "should set some text on a text field element" do
430
- watir_browser.should_receive(:text_field).and_return(watir_browser)
431
- watir_browser.should_receive(:set).with('Kim')
432
- watir_page_object.first_name = 'Kim'
433
- end
434
-
435
- it "should retrieve a text field element" do
436
- watir_browser.should_receive(:text_field).and_return(watir_browser)
437
- element = watir_page_object.first_name_element
438
- element.should be_instance_of PageObject::Elements::TextField
439
- end
440
- end
441
-
442
- context "Selenium implementation" do
443
- it "should get the text from the text field element" do
444
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
445
- selenium_browser.should_receive(:attribute).with('value').and_return('Katie')
446
- selenium_page_object.first_name.should == 'Katie'
447
- end
448
-
449
- it "should set some text on a text field element" do
450
- selenium_browser.should_receive(:find_element).twice.and_return(selenium_browser)
451
- selenium_browser.should_receive(:clear)
452
- selenium_browser.should_receive(:send_keys).with('Katie')
453
- selenium_page_object.first_name = 'Katie'
454
- end
455
-
456
- it "should retrieve a text field element" do
457
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
458
- element = selenium_page_object.first_name_element
459
- element.should be_instance_of PageObject::Elements::TextField
460
- end
461
- end
462
- end
463
-
464
-
465
- describe "hidden field accessors" do
466
- context "when called on a page object" do
467
- it "should generate accessor methods" do
468
- watir_page_object.should respond_to(:social_security_number)
469
- watir_page_object.should respond_to(:social_security_number_element)
470
- watir_page_object.should respond_to(:social_security_number_hidden_field)
471
- end
472
-
473
- it "should call a block on the element method when present" do
474
- block_page_object.secret_element.should == "hidden_field"
475
- end
476
- end
477
-
478
- context "watir implementation" do
479
- it "should get the text from a hidden field" do
480
- watir_browser.should_receive(:hidden).and_return(watir_browser)
481
- watir_browser.should_receive(:value).and_return("value")
482
- watir_page_object.social_security_number.should == "value"
483
- end
484
-
485
- it "should retrieve a hidden field element" do
486
- watir_browser.should_receive(:hidden).and_return(watir_browser)
487
- element = watir_page_object.social_security_number_element
488
- element.should be_instance_of(PageObject::Elements::HiddenField)
489
- end
490
- end
491
-
492
- context "selenium implementation" do
493
- it "should get the text from a hidden field" do
494
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
495
- selenium_browser.should_receive(:attribute).with('value').and_return("12345")
496
- selenium_page_object.social_security_number.should == "12345"
497
- end
498
-
499
- it "should retrieve a hidden field element" do
500
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
501
- element = selenium_page_object.social_security_number_element
502
- element.should be_instance_of PageObject::Elements::HiddenField
503
- end
504
- end
505
- end
506
-
507
- describe "text area accessors" do
508
- context "when called on a page object" do
509
- it "should generate accessor methods" do
510
- watir_page_object.should respond_to(:address)
511
- watir_page_object.should respond_to(:address=)
512
- watir_page_object.should respond_to(:address_element)
513
- watir_page_object.should respond_to(:address_text_area)
514
- end
515
-
516
- it "should call a block on the element method when present" do
517
- block_page_object.address_element.should == "text_area"
518
- end
519
- end
520
-
521
- context "watir implementation" do
522
- it "should set some text on the text area" do
523
- watir_browser.should_receive(:textarea).and_return(watir_browser)
524
- watir_browser.should_receive(:send_keys).with("123 main street")
525
- watir_page_object.address = "123 main street"
526
- end
527
-
528
- it "should get the text from the text area" do
529
- watir_browser.should_receive(:textarea).and_return(watir_browser)
530
- watir_browser.should_receive(:value).and_return("123 main street")
531
- watir_page_object.address.should == "123 main street"
532
- end
533
-
534
- it "should retrieve a text area element" do
535
- watir_browser.should_receive(:textarea).and_return(watir_browser)
536
- element = watir_page_object.address_element
537
- element.should be_instance_of PageObject::Elements::TextArea
538
- end
539
- end
540
-
541
- context "selenium implementation" do
542
- it "should set some text on the text area" do
543
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
544
- selenium_browser.should_receive(:send_keys).with("123 main street")
545
- selenium_page_object.address = "123 main street"
546
- end
547
-
548
- it "should get the text from the text area" do
549
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
550
- selenium_browser.should_receive(:attribute).with('value').and_return("123 main street")
551
- selenium_page_object.address.should == "123 main street"
552
- end
553
-
554
- it "should retrieve a text area element" do
555
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
556
- element = selenium_page_object.address_element
557
- element.should be_instance_of PageObject::Elements::TextArea
558
- end
559
- end
560
- end
561
-
562
- describe "select_list accessors" do
563
- context "when called on a page object" do
564
- it "should generate accessor methods" do
565
- watir_page_object.should respond_to :state
566
- watir_page_object.should respond_to :state=
567
- watir_page_object.should respond_to(:state_element)
568
- watir_page_object.should respond_to(:state_select_list)
569
- end
570
-
571
- it "should call a block on the element method when present" do
572
- block_page_object.state_element.should == "select_list"
573
- end
574
- end
575
-
576
- context "Watir implementation" do
577
- it "should get the current item from a select list" do
578
- selected = "OH"
579
- selected.should_receive(:selected?).and_return(selected)
580
- selected.should_receive(:text).and_return("OH")
581
- watir_browser.should_receive(:select_list).and_return watir_browser
582
- watir_browser.should_receive(:options).and_return([selected])
583
- watir_page_object.state.should == "OH"
584
- end
585
-
586
- it "should set the current item of a select list" do
587
- watir_browser.should_receive(:select_list).and_return watir_browser
588
- watir_browser.should_receive(:select).with("OH")
589
- watir_page_object.state = "OH"
590
- end
591
-
592
- it "should retreive the select list element" do
593
- watir_browser.should_receive(:select_list).and_return(watir_browser)
594
- element = watir_page_object.state_element
595
- element.should be_instance_of PageObject::Elements::SelectList
596
- end
597
- end
598
-
599
- context "Selenium implementation" do
600
- it "should should get the current item from a select list" do
601
- selected = "OH"
602
- selected.should_receive(:selected?).and_return(selected)
603
- selected.should_receive(:text).and_return("OH")
604
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
605
- selenium_browser.should_receive(:find_elements).and_return([selected])
606
- selenium_page_object.state.should == "OH"
607
- end
608
-
609
- it "should set the current item of a select list" do
610
- option = double('option')
611
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
612
- selenium_browser.should_receive(:find_elements).and_return([option])
613
- option.should_receive(:text).and_return('OH')
614
- option.should_receive(:click)
615
- selenium_page_object.state = "OH"
616
- end
617
-
618
- it "should retrieve the select list element" do
619
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
620
- element = selenium_page_object.state_element
621
- element.should be_instance_of PageObject::Elements::SelectList
622
- end
623
- end
624
- end
625
-
626
-
627
- describe "check_box accessors" do
628
- context "when called on a page object" do
629
- it "should generate accessor methods" do
630
- watir_page_object.should respond_to :check_active
631
- watir_page_object.should respond_to :uncheck_active
632
- watir_page_object.should respond_to :active_checked?
633
- watir_page_object.should respond_to :active_element
634
- watir_page_object.should respond_to :active_checkbox
635
- end
636
-
637
- it "should call a block on the element method when present" do
638
- block_page_object.active_element.should == "checkbox"
639
- end
640
- end
641
-
642
- context "Watir implementation" do
643
- it "should check a check box element" do
644
- watir_browser.should_receive(:checkbox).and_return(watir_browser)
645
- watir_browser.should_receive(:set)
646
- watir_page_object.check_active
647
- end
648
-
649
- it "should clear a check box element" do
650
- watir_browser.should_receive(:checkbox).and_return(watir_browser)
651
- watir_browser.should_receive(:clear)
652
- watir_page_object.uncheck_active
653
- end
654
-
655
- it "should know if a check box element is selected" do
656
- watir_browser.should_receive(:checkbox).and_return(watir_browser)
657
- watir_browser.should_receive(:set?).and_return(true)
658
- watir_page_object.active_checked?.should be_true
659
- end
660
-
661
- it "should retrieve a checkbox element" do
662
- watir_browser.should_receive(:checkbox).and_return(watir_browser)
663
- element = watir_page_object.active_element
664
- element.should be_instance_of PageObject::Elements::CheckBox
665
- end
666
- end
667
-
668
- context "Selenium implementation" do
669
- it "should check a check box element" do
670
- selenium_browser.should_receive(:find_element).twice.and_return(selenium_browser)
671
- selenium_browser.should_receive(:selected?).and_return(false)
672
- selenium_browser.should_receive(:click)
673
- selenium_page_object.check_active
674
- end
675
-
676
- it "should clear a check box element" do
677
- selenium_browser.should_receive(:find_element).twice.and_return(selenium_browser)
678
- selenium_browser.should_receive(:selected?).and_return(true)
679
- selenium_browser.should_receive(:click)
680
- selenium_page_object.uncheck_active
681
- end
682
-
683
- it "should know if a check box element is selected" do
684
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
685
- selenium_browser.should_receive(:selected?).and_return(true)
686
- selenium_page_object.active_checked?.should be_true
687
- end
688
-
689
- it "should retrieve a checkbox element" do
690
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
691
- element = selenium_page_object.active_element
692
- element.should be_instance_of PageObject::Elements::CheckBox
693
- end
694
- end
695
- end
696
-
697
-
698
- describe "radio accessors" do
699
- context "when called on a page object" do
700
- it "should generate accessor methods" do
701
- watir_page_object.should respond_to :select_first
702
- watir_page_object.should respond_to :clear_first
703
- watir_page_object.should respond_to :first_selected?
704
- watir_page_object.should respond_to(:first_element)
705
- watir_page_object.should respond_to(:first_radio_button)
706
- end
707
-
708
- it "should call a block on the element method when present" do
709
- block_page_object.first_element.should == "radio_button"
710
- end
711
- end
712
-
713
- context "Watir implementation" do
714
- it "should select a radio button" do
715
- watir_browser.should_receive(:radio).and_return(watir_browser)
716
- watir_browser.should_receive(:set)
717
- watir_page_object.select_first
718
- end
719
-
720
- it "should clear a radio button" do
721
- watir_browser.should_receive(:radio).and_return(watir_browser)
722
- watir_browser.should_receive(:clear)
723
- watir_page_object.clear_first
724
- end
725
-
726
- it "should determine if a radio is selected" do
727
- watir_browser.should_receive(:radio).and_return(watir_browser)
728
- watir_browser.should_receive(:set?)
729
- watir_page_object.first_selected?
730
- end
731
-
732
- it "should retrieve a radio button element" do
733
- watir_browser.should_receive(:radio).and_return(watir_browser)
734
- element = watir_page_object.first_element
735
- element.should be_instance_of PageObject::Elements::RadioButton
736
- end
737
- end
738
-
739
- context "Selenium implementation" do
740
- it "should select a radio button" do
741
- selenium_browser.should_receive(:find_element).twice.and_return(selenium_browser)
742
- selenium_browser.should_receive(:selected?).and_return(false)
743
- selenium_browser.should_receive(:click)
744
- selenium_page_object.select_first
745
- end
746
-
747
- it "should clear a radio button" do
748
- selenium_browser.should_receive(:find_element).twice.and_return(selenium_browser)
749
- selenium_browser.should_receive(:selected?).and_return(true)
750
- selenium_browser.should_receive(:click)
751
- selenium_page_object.clear_first
752
- end
753
-
754
- it "should determine if a radio is selected" do
755
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
756
- selenium_browser.should_receive(:selected?).and_return(true)
757
- selenium_page_object.first_selected?
758
- end
759
-
760
- it "should retrieve a radio button element" do
761
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
762
- element = selenium_page_object.first_element
763
- element.should be_instance_of PageObject::Elements::RadioButton
764
- end
765
- end
766
- end
767
-
768
- describe "button accessors" do
769
- context "when called on a page object" do
770
- it "should generate accessor methods" do
771
- watir_page_object.should respond_to :click_me
772
- watir_page_object.should respond_to :click_me_element
773
- watir_page_object.should respond_to :click_me_button
774
- end
775
-
776
- it "should call a block on the element method when present" do
777
- block_page_object.click_me_element.should == "button"
778
- end
779
- end
780
-
781
- context "watir implementation" do
782
- it "should be able to click a button" do
783
- watir_browser.should_receive(:button).and_return(watir_browser)
784
- watir_browser.should_receive(:click)
785
- watir_page_object.click_me
786
- end
787
-
788
- it "should retrieve a button element" do
789
- watir_browser.should_receive(:button).and_return(watir_browser)
790
- element = watir_page_object.click_me_element
791
- element.should be_instance_of PageObject::Elements::Button
792
- end
793
- end
794
-
795
- context "selenium implementation" do
796
- it "should be able to click a button" do
797
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
798
- selenium_browser.should_receive(:click)
799
- selenium_page_object.click_me
800
- end
801
-
802
- it "should retrieve a button element" do
803
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
804
- element = selenium_page_object.click_me_element
805
- element.should be_instance_of PageObject::Elements::Button
806
-
807
- end
808
- end
809
- end
810
-
811
- describe "div accessors" do
812
- context "when called on a page object" do
813
- it "should generate accessor methods" do
814
- watir_page_object.should respond_to(:message)
815
- watir_page_object.should respond_to(:message_element)
816
- watir_page_object.should respond_to(:message_div)
817
- end
818
-
819
- it "should call a block on the element method when present" do
820
- block_page_object.footer_element.should == "div"
821
- end
822
- end
823
-
824
- context "watir implementation" do
825
- it "should retrieve the text from a div" do
826
- watir_browser.should_receive(:div).and_return(watir_browser)
827
- watir_browser.should_receive(:text).and_return("Message from div")
828
- watir_page_object.message.should == "Message from div"
829
- end
830
-
831
- it "should retrieve the div element from the page" do
832
- watir_browser.should_receive(:div).and_return(watir_browser)
833
- element = watir_page_object.message_element
834
- element.should be_instance_of PageObject::Elements::Div
835
- end
836
- end
837
-
838
- context "selenium implementation" do
839
- it "should retrieve the text from a div" do
840
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
841
- selenium_browser.should_receive(:text).and_return("Message from div")
842
- selenium_page_object.message.should == "Message from div"
843
-
844
- end
845
-
846
- it "should retrieve the div element from the page" do
847
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
848
- element = selenium_page_object.message_element
849
- element.should be_instance_of PageObject::Elements::Div
850
-
851
- end
852
- end
853
- end
854
-
855
- describe "span accessors" do
856
- context "when called on a page object" do
857
- it "should generate accessor methods" do
858
- watir_page_object.should respond_to(:alert)
859
- watir_page_object.should respond_to(:alert_element)
860
- watir_page_object.should respond_to(:alert_span)
861
- end
862
-
863
- it "should call a block on the element method when present" do
864
- block_page_object.alert_element.should == "span"
865
- end
866
- end
867
-
868
- context "watir implementation" do
869
- it "should retrieve the text from a span" do
870
- watir_browser.should_receive(:span).and_return(watir_browser)
871
- watir_browser.should_receive(:text).and_return("Alert")
872
- watir_page_object.alert.should == "Alert"
873
- end
874
-
875
- it "should retrieve the span element from the page" do
876
- watir_browser.should_receive(:span).and_return(watir_browser)
877
- element = watir_page_object.alert_element
878
- element.should be_instance_of PageObject::Elements::Span
879
- end
880
- end
881
-
882
- context "selenium implementation" do
883
- it "should retrieve the text from a span" do
884
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
885
- selenium_browser.should_receive(:text).and_return("Alert")
886
- selenium_page_object.alert.should == "Alert"
887
- end
888
-
889
- it "should retrieve the span element from the page" do
890
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
891
- element = selenium_page_object.alert_element
892
- element.should be_instance_of PageObject::Elements::Span
893
-
894
- end
895
- end
896
- end
897
-
898
- describe "table accessors" do
899
- context "when called on a page object" do
900
- it "should generate accessor methods" do
901
- watir_page_object.should respond_to(:cart_element)
902
- watir_page_object.should respond_to(:cart_table)
903
- end
904
-
905
- it "should call a block on the element method when present" do
906
- block_page_object.cart_element.should == "table"
907
- end
908
- end
909
-
910
- context "watir implementation" do
911
- it "should retrieve the table element from the page" do
912
- watir_browser.should_receive(:table).and_return(watir_browser)
913
- element = watir_page_object.cart_element
914
- element.should be_instance_of PageObject::Elements::Table
915
- end
916
- end
917
-
918
- context "selenium implementation" do
919
- it "should retrieve the table element from the page" do
920
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
921
- element = selenium_page_object.cart_element
922
- element.should be_instance_of(PageObject::Elements::Table)
923
- end
924
- end
925
- end
926
-
927
- describe "table cell accessors" do
928
- context "when called on a page object" do
929
- it "should generate accessor methods" do
930
- watir_page_object.should respond_to(:total)
931
- watir_page_object.should respond_to(:total_element)
932
- watir_page_object.should respond_to(:total_cell)
933
- end
934
-
935
- it "should call a block on the element method when present" do
936
- block_page_object.total_element.should == "cell"
937
- end
938
- end
939
-
940
- context "watir implementation" do
941
- it "should retrieve the text for the cell" do
942
- watir_browser.should_receive(:td).and_return(watir_browser)
943
- watir_browser.should_receive(:text).and_return('10.00')
944
- watir_page_object.total.should == '10.00'
945
- end
946
-
947
- it "should retrieve the cell element from the page" do
948
- watir_browser.should_receive(:td).and_return(watir_browser)
949
- element = watir_page_object.total_element
950
- element.should be_instance_of PageObject::Elements::TableCell
951
- end
952
- end
953
-
954
- context "selenium implementation" do
955
- it "should retrieve the text from the cell" do
956
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
957
- selenium_browser.should_receive(:text).and_return('celldata')
958
- selenium_page_object.total.should == 'celldata'
959
- end
960
-
961
- it "should retrieve the cell element from the page" do
962
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
963
- element = selenium_page_object.total_element
964
- element.should be_instance_of PageObject::Elements::TableCell
965
- end
966
- end
967
- end
968
-
969
- describe "image accessors" do
970
- context "when called on a page object" do
971
- it "should generate accessor methods" do
972
- watir_page_object.should respond_to(:logo_element)
973
- watir_page_object.should respond_to(:logo_image)
974
- end
975
-
976
- it "should call a block on the element method when present" do
977
- block_page_object.logo_element.should == "image"
978
- end
979
- end
980
-
981
- context "watir implementation" do
982
- it "should retrieve the image element from the page" do
983
- watir_browser.should_receive(:image).and_return(watir_browser)
984
- element = watir_page_object.logo_element
985
- element.should be_instance_of PageObject::Elements::Image
986
- end
987
- end
988
-
989
- context "selenium implementation" do
990
- it "should retrieve the image element from the page" do
991
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
992
- element = selenium_page_object.logo_element
993
- element.should be_instance_of PageObject::Elements::Image
994
- end
995
- end
996
- end
997
-
998
- describe "form accessors" do
999
- context "when called on a page object" do
1000
- it "should generate accessor methods" do
1001
- watir_page_object.should respond_to(:login_element)
1002
- watir_page_object.should respond_to(:login_form)
1003
- end
1004
-
1005
- it "should call a block on the element method when present" do
1006
- block_page_object.login_element.should == "form"
1007
- end
1008
- end
1009
-
1010
- context "watir implementation" do
1011
- it "should retrieve the form element from the page" do
1012
- watir_browser.should_receive(:form).and_return(watir_browser)
1013
- element = watir_page_object.login_element
1014
- element.should be_instance_of PageObject::Elements::Form
1015
- end
1016
- end
1017
-
1018
- context "selenium implementation" do
1019
- it "should retrieve the form element from the page" do
1020
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1021
- element = selenium_page_object.login_element
1022
- element.should be_instance_of PageObject::Elements::Form
1023
- end
1024
- end
1025
- end
1026
-
1027
- describe "list item accessors" do
1028
- context "when called on a page object" do
1029
- it "should generate accessor methods" do
1030
- watir_page_object.should respond_to(:item_one)
1031
- watir_page_object.should respond_to(:item_one_element)
1032
- watir_page_object.should respond_to(:item_one_list_item)
1033
- end
1034
-
1035
- it "should call a block on the element method when present" do
1036
- block_page_object.item_one_element.should == "list_item"
1037
- end
1038
- end
1039
-
1040
- context "watir implementation" do
1041
- it "should retrieve the text from the list item" do
1042
- watir_browser.should_receive(:li).and_return(watir_browser)
1043
- watir_browser.should_receive(:text).and_return("value")
1044
- watir_page_object.item_one.should == "value"
1045
- end
1046
-
1047
- it "should retrieve the list item element from the page" do
1048
- watir_browser.should_receive(:li).and_return(watir_browser)
1049
- element = watir_page_object.item_one_element
1050
- element.should be_instance_of PageObject::Elements::ListItem
1051
- end
1052
- end
1053
-
1054
- context "selenium implementation" do
1055
- it "should retrieve the text from the list item" do
1056
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1057
- selenium_browser.should_receive(:text).and_return("value")
1058
- selenium_page_object.item_one.should == "value"
1059
- end
1060
-
1061
- it "should retrieve the list item from the page" do
1062
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1063
- element = selenium_page_object.item_one_element
1064
- element.should be_instance_of PageObject::Elements::ListItem
1065
- end
1066
- end
1067
- end
1068
-
1069
- describe "unordered list accessors" do
1070
- context "when called on a page object" do
1071
- it "should generate accessor methods" do
1072
- watir_page_object.should respond_to(:menu_element)
1073
- watir_page_object.should respond_to(:menu_unordered_list)
1074
- end
1075
-
1076
- it "should call a block on the element method when present" do
1077
- block_page_object.menu_element.should == "unordered_list"
1078
- end
1079
- end
1080
-
1081
- context "watir implementation" do
1082
- it "should retrieve the element from the page" do
1083
- watir_browser.should_receive(:ul).and_return(watir_browser)
1084
- element = watir_page_object.menu_element
1085
- element.should be_instance_of PageObject::Elements::UnorderedList
1086
- end
1087
- end
1088
-
1089
- context "selenium implementation" do
1090
- it "should retrieve the element from the page" do
1091
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1092
- element = selenium_page_object.menu_element
1093
- element.should be_instance_of PageObject::Elements::UnorderedList
1094
- end
1095
- end
1096
- end
1097
-
1098
- describe "ordered list accessors" do
1099
- context "when called on a page object" do
1100
- it "should generate accessor methods" do
1101
- watir_page_object.should respond_to(:top_five_element)
1102
- watir_page_object.should respond_to(:top_five_ordered_list)
1103
- end
1104
-
1105
- it "should call a block on the element method when present" do
1106
- block_page_object.top_five_element.should == "ordered_list"
1107
- end
1108
- end
1109
-
1110
- context "watir implementation" do
1111
- it "should retrieve the element from the page" do
1112
- watir_browser.should_receive(:ol).and_return(watir_browser)
1113
- element = watir_page_object.top_five_element
1114
- element.should be_instance_of PageObject::Elements::OrderedList
1115
- end
1116
- end
1117
-
1118
- context "selenium implementation" do
1119
- it "should retrieve the element from the page" do
1120
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1121
- element = selenium_page_object.top_five_element
1122
- element.should be_instance_of PageObject::Elements::OrderedList
1123
- end
1124
- end
1125
- end
1126
-
1127
- describe "h1 accessors" do
1128
- context "when called on a page object" do
1129
- it "should generate accessor methods" do
1130
- watir_page_object.should respond_to(:heading1)
1131
- watir_page_object.should respond_to(:heading1_element)
1132
- end
1133
-
1134
- it "should call a block on the element method when present" do
1135
- block_page_object.heading1_element.should == "h1"
1136
- end
1137
- end
1138
-
1139
- context "watir implementation" do
1140
- it "should retrieve the text from the h1" do
1141
- watir_browser.should_receive(:h1).and_return(watir_browser)
1142
- watir_browser.should_receive(:text).and_return("value")
1143
- watir_page_object.heading1.should == "value"
1144
- end
1145
-
1146
- it "should retrieve the element from the page" do
1147
- watir_browser.should_receive(:h1).and_return(watir_browser)
1148
- element = watir_page_object.heading1_element
1149
- element.should be_instance_of PageObject::Elements::Heading
1150
- end
1151
- end
1152
-
1153
- context "selenium implementation" do
1154
- it "should retrieve the text from the h1" do
1155
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1156
- selenium_browser.should_receive(:text).and_return("value")
1157
- selenium_page_object.heading1.should == "value"
1158
- end
1159
-
1160
- it "should retrieve the element from the page" do
1161
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1162
- element = selenium_page_object.heading1_element
1163
- element.should be_instance_of PageObject::Elements::Heading
1164
- end
1165
- end
1166
- end
1167
-
1168
- describe "h2 accessors" do
1169
- context "when called on a page object" do
1170
- it "should generate accessor methods" do
1171
- watir_page_object.should respond_to(:heading2)
1172
- watir_page_object.should respond_to(:heading2_element)
1173
- end
1174
-
1175
- it "should call a block on the element method when present" do
1176
- block_page_object.heading2_element.should == "h2"
1177
- end
1178
- end
1179
-
1180
- context "watir implementation" do
1181
- it "should retrieve the text from the h2" do
1182
- watir_browser.should_receive(:h2).and_return(watir_browser)
1183
- watir_browser.should_receive(:text).and_return("value")
1184
- watir_page_object.heading2.should == "value"
1185
- end
1186
-
1187
- it "should retrieve the element from the page" do
1188
- watir_browser.should_receive(:h2).and_return(watir_browser)
1189
- element = watir_page_object.heading2_element
1190
- element.should be_instance_of PageObject::Elements::Heading
1191
- end
1192
- end
1193
-
1194
- context "selenium implementation" do
1195
- it "should retrieve the text from the h2" do
1196
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1197
- selenium_browser.should_receive(:text).and_return("value")
1198
- selenium_page_object.heading2.should == "value"
1199
- end
1200
-
1201
- it "should retrieve the element from the page" do
1202
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1203
- element = selenium_page_object.heading2_element
1204
- element.should be_instance_of PageObject::Elements::Heading
1205
- end
1206
- end
1207
- end
1208
-
1209
- describe "h3 accessors" do
1210
- context "when called on a page object" do
1211
- it "should generate accessor methods" do
1212
- watir_page_object.should respond_to(:heading3)
1213
- watir_page_object.should respond_to(:heading3_element)
1214
- end
1215
-
1216
- it "should call a block on the element method when present" do
1217
- block_page_object.heading3_element.should == "h3"
1218
- end
1219
- end
1220
-
1221
- context "watir implementation" do
1222
- it "should retrieve the text from the h3" do
1223
- watir_browser.should_receive(:h3).and_return(watir_browser)
1224
- watir_browser.should_receive(:text).and_return("value")
1225
- watir_page_object.heading3.should == "value"
1226
- end
1227
-
1228
- it "should retrieve the element from the page" do
1229
- watir_browser.should_receive(:h3).and_return(watir_browser)
1230
- element = watir_page_object.heading3_element
1231
- element.should be_instance_of PageObject::Elements::Heading
1232
- end
1233
- end
1234
-
1235
- context "selenium implementation" do
1236
- it "should retrieve the text from the h3" do
1237
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1238
- selenium_browser.should_receive(:text).and_return("value")
1239
- selenium_page_object.heading3.should == "value"
1240
- end
1241
-
1242
- it "should retrieve the element from the page" do
1243
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1244
- element = selenium_page_object.heading3_element
1245
- element.should be_instance_of PageObject::Elements::Heading
1246
- end
1247
- end
1248
- end
1249
-
1250
- describe "h4 accessors" do
1251
- context "when called on a page object" do
1252
- it "should generate accessor methods" do
1253
- watir_page_object.should respond_to(:heading4)
1254
- watir_page_object.should respond_to(:heading4_element)
1255
- end
1256
-
1257
- it "should call a block on the element method when present" do
1258
- block_page_object.heading4_element.should == "h4"
1259
- end
1260
- end
1261
-
1262
- context "watir implementation" do
1263
- it "should retrieve the text from the h4" do
1264
- watir_browser.should_receive(:h4).and_return(watir_browser)
1265
- watir_browser.should_receive(:text).and_return("value")
1266
- watir_page_object.heading4.should == "value"
1267
- end
1268
-
1269
- it "should retrieve the element from the page" do
1270
- watir_browser.should_receive(:h4).and_return(watir_browser)
1271
- element = watir_page_object.heading4_element
1272
- element.should be_instance_of PageObject::Elements::Heading
1273
- end
1274
- end
1275
-
1276
- context "selenium implementation" do
1277
- it "should retrieve the text from the h4" do
1278
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1279
- selenium_browser.should_receive(:text).and_return("value")
1280
- selenium_page_object.heading4.should == "value"
1281
- end
1282
-
1283
- it "should retrieve the element from the page" do
1284
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1285
- element = selenium_page_object.heading4_element
1286
- element.should be_instance_of PageObject::Elements::Heading
1287
- end
1288
- end
1289
- end
1290
-
1291
- describe "h5 accessors" do
1292
- context "when called on a page object" do
1293
- it "should generate accessor methods" do
1294
- watir_page_object.should respond_to(:heading5)
1295
- watir_page_object.should respond_to(:heading5_element)
1296
- end
1297
-
1298
- it "should call a block on the element method when present" do
1299
- block_page_object.heading5_element.should == "h5"
1300
- end
1301
- end
1302
-
1303
- context "watir implementation" do
1304
- it "should retrieve the text from the h5" do
1305
- watir_browser.should_receive(:h5).and_return(watir_browser)
1306
- watir_browser.should_receive(:text).and_return("value")
1307
- watir_page_object.heading5.should == "value"
1308
- end
1309
-
1310
- it "should retrieve the element from the page" do
1311
- watir_browser.should_receive(:h5).and_return(watir_browser)
1312
- element = watir_page_object.heading5_element
1313
- element.should be_instance_of PageObject::Elements::Heading
1314
- end
1315
- end
1316
-
1317
- context "selenium implementation" do
1318
- it "should retrieve the text from the h5" do
1319
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1320
- selenium_browser.should_receive(:text).and_return("value")
1321
- selenium_page_object.heading5.should == "value"
1322
- end
1323
-
1324
- it "should retrieve the element from the page" do
1325
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1326
- element = selenium_page_object.heading5_element
1327
- element.should be_instance_of PageObject::Elements::Heading
1328
- end
1329
- end
1330
- end
1331
-
1332
- describe "h6 accessors" do
1333
- context "when called on a page object" do
1334
- it "should generate accessor methods" do
1335
- watir_page_object.should respond_to(:heading6)
1336
- watir_page_object.should respond_to(:heading6_element)
1337
- end
1338
-
1339
- it "should call a block on the element method when present" do
1340
- block_page_object.heading6_element.should == "h6"
1341
- end
1342
- end
1343
-
1344
- context "watir implementation" do
1345
- it "should retrieve the text from the h6" do
1346
- watir_browser.should_receive(:h6).and_return(watir_browser)
1347
- watir_browser.should_receive(:text).and_return("value")
1348
- watir_page_object.heading6.should == "value"
1349
- end
1350
-
1351
- it "should retrieve the element from the page" do
1352
- watir_browser.should_receive(:h6).and_return(watir_browser)
1353
- element = watir_page_object.heading6_element
1354
- element.should be_instance_of PageObject::Elements::Heading
1355
- end
1356
- end
1357
-
1358
- context "selenium implementation" do
1359
- it "should retrieve the text from the h6" do
1360
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1361
- selenium_browser.should_receive(:text).and_return("value")
1362
- selenium_page_object.heading6.should == "value"
1363
- end
1364
-
1365
- it "should retrieve the element from the page" do
1366
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1367
- element = selenium_page_object.heading6_element
1368
- element.should be_instance_of PageObject::Elements::Heading
1369
- end
1370
- end
1371
- end
1372
-
1373
-
1374
- describe "p accessors" do
1375
- context "when called on a page object" do
1376
- it "should generate accessor methods" do
1377
- watir_page_object.should respond_to(:first_para)
1378
- watir_page_object.should respond_to(:first_para_element)
1379
- end
1380
-
1381
- it "should call a block on the element method when present" do
1382
- block_page_object.first_para_element.should == "p"
1383
- end
1384
- end
1385
-
1386
- context "watir implementation" do
1387
- it "should retrieve the text from the p" do
1388
- watir_browser.should_receive(:p).and_return(watir_browser)
1389
- watir_browser.should_receive(:text).and_return("value")
1390
- watir_page_object.first_para.should == "value"
1391
- end
1392
-
1393
- it "should retrieve the element from the page" do
1394
- watir_browser.should_receive(:p).and_return(watir_browser)
1395
- element = watir_page_object.first_para_element
1396
- element.should be_instance_of PageObject::Elements::Paragraph
1397
- end
1398
- end
1399
-
1400
- context "selenium implementation" do
1401
- it "should retrieve the text from the p" do
1402
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1403
- selenium_browser.should_receive(:text).and_return("value")
1404
- selenium_page_object.first_para.should == "value"
1405
- end
1406
-
1407
- it "should retrieve the element from the page" do
1408
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1409
- element = selenium_page_object.first_para_element
1410
- element.should be_instance_of PageObject::Elements::Paragraph
1411
- end
1412
- end
1413
- end
1414
-
1415
- describe "file_field accessors" do
1416
- context "when called on a page object" do
1417
- it "should generate accessor methods" do
1418
- watir_page_object.should respond_to(:upload_me=)
1419
- watir_page_object.should respond_to(:upload_me_element)
1420
- end
1421
-
1422
- it "should call a block on the element method when present" do
1423
- block_page_object.a_file_element.should == "file_field"
1424
- end
1425
- end
1426
-
1427
- context "watir implementation" do
1428
- it "should set the file name" do
1429
- watir_browser.should_receive(:file_field).and_return(watir_browser)
1430
- watir_browser.should_receive(:set).with('some_file')
1431
- watir_page_object.upload_me = 'some_file'
1432
- end
1433
-
1434
- it "should retrieve a text field element" do
1435
- watir_browser.should_receive(:file_field).and_return(watir_browser)
1436
- element = watir_page_object.upload_me_element
1437
- element.should be_instance_of PageObject::Elements::FileField
1438
- end
1439
- end
1440
-
1441
- context "selenium implementation" do
1442
- it "should set the file name" do
1443
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1444
- selenium_browser.should_receive(:send_keys).with('some_file')
1445
- selenium_page_object.upload_me = 'some_file'
1446
- end
1447
-
1448
- it "should retrieve a file_field element" do
1449
- selenium_browser.should_receive(:find_element).and_return(selenium_browser)
1450
- element = selenium_page_object.upload_me_element
1451
- element.should be_instance_of PageObject::Elements::FileField
1452
- end
1453
- end
1454
- end
1455
- end