page-object 0.6.7 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,6 @@ rvm:
3
3
  - 1.8.7
4
4
  - 1.9.2
5
5
  - 1.9.3
6
- - rbx-19mode
7
6
  - ree
8
7
  before_script:
9
8
  - "export DISPLAY=:99.0"
data/ChangeLog CHANGED
@@ -1,3 +1,13 @@
1
+ === Version 0.6.8 / 2012-6-3
2
+ * Enhancements
3
+ * Updated [] method on Table to return nil when bad row header is provided
4
+ * Updated [] method on TableRow to return nil when bad column header is provided
5
+ * Updated to use watir-webdriver 0.6.1
6
+ * Updated to use selenium-webdriver 2.22.1
7
+ * Fixes
8
+ Modified text area methods so it clears before setting new text
9
+ Fixed clear method on SelectList when using Selenium to clear multi selects
10
+
1
11
  === Version 0.6.7 / 2012-5-16
2
12
  * Enhancements
3
13
  * Added flash method to Element to temporarily change the background color
@@ -52,7 +62,7 @@
52
62
  * Added #execute_script method to PageObject
53
63
  * Updated to use selenium-webdriver 2.20.0
54
64
  * Fixes
55
- * Udates to the README - Thanks to p0deje and ivaravko
65
+ * Updates to the README - Thanks to p0deje and ivaravko
56
66
  WARNING: This change breaks existing code
57
67
  * Changed the generated getter for select_list to return the text instead of the value
58
68
 
@@ -14,10 +14,15 @@
14
14
  <textarea rows="2" cols="20" id="text_area_id" class="text_area_class" name="text_area_name"></textarea>
15
15
 
16
16
  <select name="sel_list_name" id="sel_list_id" class="sel_list_class">
17
- <option value="option1">Test 1</option>
18
- <option value="option2">Test 2</option>
17
+ <option value="option1">Test 1</option>
18
+ <option value="option2">Test 2</option>
19
19
  </select>
20
20
 
21
+ <select multiple="multiple" id="sel_list_multiple">
22
+ <option value="option1" selected="true">Test 1</option>
23
+ <option value="option2">Test 2</option>
24
+ <option value="option3" selected="true">Test 3</option>
25
+ </select>
21
26
 
22
27
  <a href="success.html" id="link_id" name="link_name" class="link_class">Google Search</a>
23
28
 
@@ -33,7 +38,7 @@
33
38
  <span id="span_id" name="span_name" class="span_class" title="span_title">
34
39
  My alert
35
40
  </span>
36
-
41
+
37
42
  <label id="label_id" name="label_name" class="label_class">
38
43
  page-object is the best!
39
44
  </label>
@@ -91,7 +96,7 @@
91
96
  <h6 id="h6_id" class="h6_class" name="h6_name">h6's are cool</h6>
92
97
 
93
98
  <a href="success.html" target="_blank">New Window</a>
94
-
99
+
95
100
  <input type="text" id="onfocus_text_field" onfocus="document.getElementById('onfocus_test').innerHTML = 'changed by onfocus event'"/>
96
101
  <div id="onfocus_test"></div>
97
102
 
@@ -57,3 +57,6 @@ Feature: Select List
57
57
  When I select "Test 2" from the select list
58
58
  Then the select list should know that "Test 2" is selected
59
59
 
60
+ Scenario: Clearing multiple select list
61
+ When I clear multiple select list
62
+ Then multiple select list should have no selected options
@@ -47,3 +47,11 @@ Then /^the value for the option should be "([^\"]*)"$/ do |value|
47
47
  element = @page.send "sel_list_#{@how}_element".to_sym
48
48
  element.value.should == value
49
49
  end
50
+
51
+ When /^I clear multiple select list$/ do
52
+ @page.sel_list_multiple_element.clear
53
+ end
54
+
55
+ Then /^multiple select list should have no selected options$/ do
56
+ @page.sel_list_multiple_element.selected_options.should be_empty
57
+ end
@@ -47,3 +47,11 @@ end
47
47
  Then /^the data for row "([^\"]*)" and column "([^\"]*)" should be "([^\"]*)"$/ do |row, column, value|
48
48
  @element[row][column].text.should == value
49
49
  end
50
+
51
+ Then /^the data for row "([^\"]*)" should be nil$/ do |row|
52
+ @element[row].should be_nil
53
+ end
54
+
55
+ Then /^the data for row "([^\"]*)" and column "([^\"]*)" should be nil$/ do |row, column|
56
+ @element[row][column].should be_nil
57
+ end
@@ -3,7 +3,7 @@ class Page
3
3
 
4
4
  expected_title "Static Elements Page"
5
5
  expected_element :hello0
6
-
6
+
7
7
  link(:hello0, {:text => "Hello", :index => 0})
8
8
  link(:hello1, {:text => "Hello", :index => 1})
9
9
  link(:hello2, {:text => "Hello", :index => 2})
@@ -65,6 +65,7 @@ class Page
65
65
  select_list(:sel_list_text, :text => "Test 1")
66
66
  select_list(:sel_list_class_index, :class => "sel_list_class", :index => 0)
67
67
  select_list(:sel_list_name_index, :name => "sel_list_name", :index => 0)
68
+ select_list(:sel_list_multiple, :id => "sel_list_multiple")
68
69
 
69
70
  checkbox(:cb_id, :id => 'cb_id')
70
71
  checkbox(:cb_name, :name => 'cb_name')
@@ -190,7 +191,7 @@ class Page
190
191
  ordered_list(:ol_xpath, :xpath => '//ol')
191
192
  ordered_list(:ol_class_index, :class => "ol_class", :index => 0)
192
193
  ordered_list(:ol_name_index, :name => "ol_name", :index => 0)
193
-
194
+
194
195
  h1(:h1_id, :id => 'h1_id')
195
196
  h1(:h1_class, :class => 'h1_class')
196
197
  h1(:h1_name, :name => 'h1_name')
@@ -238,7 +239,7 @@ class Page
238
239
  h6(:h6_xpath, :xpath => '//h6')
239
240
  h6(:h6_class_index, :class => 'h6_class', :index => 0)
240
241
  h6(:h6_name_index, :name => 'h6_name', :index => 0)
241
-
242
+
242
243
  paragraph(:p_id, :id => 'p_id')
243
244
  paragraph(:p_class, :class => 'p_class')
244
245
  paragraph(:p_name, :name => 'p_name')
@@ -268,7 +269,7 @@ class Page
268
269
  label(:label_xpath, :xpath => '//label')
269
270
  label(:label_class_index, :class => "label_class", :index => 0)
270
271
  label(:label_name_index, :name => "label_name", :index => 0)
271
-
272
+
272
273
  link(:open_window, :text => 'New Window')
273
274
  link(:child, :id => 'child')
274
275
 
@@ -37,6 +37,14 @@ Feature: Table
37
37
  Scenario: Retrieve data from a table using both headers
38
38
  When I retrieve a table element
39
39
  Then the data for row "Data3" and column "Data2" should be "Data4"
40
+
41
+ Scenario: Retrieve data from a table with an incorrect row header
42
+ When I retrieve a table element
43
+ Then the data for row "Data20" should be nil
44
+
45
+ Scenario: Retrieve data from a table with an incorrect column header
46
+ When I retrieve a table element
47
+ Then the data for row "Data3" and column "Data20" should be nil
40
48
 
41
49
  Scenario Outline: Locating table cells on the Page
42
50
  When I retrieve a table element by "<search_by>"
@@ -250,7 +250,9 @@ module PageObject
250
250
  #
251
251
  def text_area_value_set(identifier, value)
252
252
  process_selenium_call(identifier, Elements::TextArea, 'textarea') do |how, what|
253
- @browser.find_element(how, what).send_keys(value)
253
+ text_area = @browser.find_element(how, what)
254
+ text_area.clear
255
+ text_area.send_keys(value)
254
256
  end
255
257
  end
256
258
 
@@ -12,7 +12,7 @@ module PageObject
12
12
  def [](idx)
13
13
  options[idx]
14
14
  end
15
-
15
+
16
16
  #
17
17
  # Select a value from the list
18
18
  #
@@ -56,6 +56,13 @@ module PageObject
56
56
  selected.any? { |e| e.text == value }
57
57
  end
58
58
 
59
+ #
60
+ # Deselect all selected options.
61
+ #
62
+ def clear
63
+ find_options.select { |e| e.selected? }.each { |o| o.click }
64
+ end
65
+
59
66
  private
60
67
 
61
68
  def find_options
@@ -13,6 +13,7 @@ module PageObject
13
13
  def [](idx)
14
14
  eles = table_rows
15
15
  idx = find_index_by_title(idx, eles) if idx.kind_of?(String)
16
+ return nil unless idx
16
17
  Object::PageObject::Elements::TableRow.new(eles[idx], :platform => :selenium_webdriver)
17
18
  end
18
19
 
@@ -12,6 +12,7 @@ module PageObject
12
12
  def [](idx)
13
13
  els = table_cells
14
14
  idx = find_index_by_title(idx) if idx.kind_of?(String)
15
+ return nil unless idx
15
16
  Object::PageObject::Elements::TableCell.new(els[idx], :platform => :selenium_webdriver)
16
17
  end
17
18
 
@@ -239,7 +239,7 @@ module PageObject
239
239
  # See PageObject::Accessors#text_area
240
240
  #
241
241
  def text_area_value_set(identifier, value)
242
- process_watir_call("textarea(identifier).send_keys(value)", Elements::TextArea,
242
+ process_watir_call("textarea(identifier).set(value)", Elements::TextArea,
243
243
  identifier, value)
244
244
  end
245
245
 
@@ -13,6 +13,7 @@ module PageObject
13
13
  #
14
14
  def [](idx)
15
15
  idx = find_index_by_title(idx) if idx.kind_of?(String)
16
+ return nil unless idx
16
17
  Object::PageObject::Elements::TableRow.new(element[idx], :platform => :watir_webdriver)
17
18
  end
18
19
 
@@ -10,6 +10,7 @@ module PageObject
10
10
  #
11
11
  def [](idx)
12
12
  idx = find_index_by_title(idx) if idx.kind_of?(String)
13
+ return nil unless idx
13
14
  Object::PageObject::Elements::TableCell.new(element[idx], :platform => :watir_webdriver)
14
15
  end
15
16
 
@@ -1,4 +1,4 @@
1
1
  module PageObject
2
2
  # @private
3
- VERSION = "0.6.7"
3
+ VERSION = "0.6.8"
4
4
  end
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency 'watir-webdriver', '>= 0.5.8'
23
- s.add_dependency 'selenium-webdriver', '>= 2.21.2'
22
+ s.add_dependency 'watir-webdriver', '>= 0.6.1'
23
+ s.add_dependency 'selenium-webdriver', '>= 2.22.1'
24
24
 
25
25
  s.add_development_dependency 'rspec', '>= 2.6.0'
26
26
  s.add_development_dependency 'cucumber', '< 1.2.0'
@@ -71,7 +71,7 @@ describe PageObject::Elements::SelectList do
71
71
 
72
72
  context "for selenium" do
73
73
  let(:selenium_sel_list) { PageObject::Elements::SelectList.new(sel_list, :platform => :selenium_webdriver) }
74
-
74
+
75
75
  it "should return an option when indexed" do
76
76
  sel_list.should_receive(:find_elements).with(:xpath, ".//child::option").and_return(opts)
77
77
  selenium_sel_list[1].should be_instance_of PageObject::Elements::Option
@@ -89,7 +89,7 @@ describe PageObject::Elements::SelectList do
89
89
  option.should_receive(:click)
90
90
  selenium_sel_list.select 'something'
91
91
  end
92
-
92
+
93
93
  it "should return an array of selected options" do
94
94
  sel_list.should_receive(:find_elements).with(:xpath, ".//child::option").and_return(opts)
95
95
  opts[0].should_receive(:selected?).and_return(true)
@@ -105,13 +105,22 @@ describe PageObject::Elements::SelectList do
105
105
  opts[0].should_receive(:text).and_return('blah')
106
106
  selenium_sel_list.should include 'blah'
107
107
  end
108
-
108
+
109
109
  it "should know if an option is selected" do
110
110
  sel_list.should_receive(:find_elements).and_return(opts)
111
111
  opts[0].should_receive(:selected?).twice.and_return(true)
112
112
  opts[0].should_receive(:text).and_return('blah')
113
113
  selenium_sel_list.selected?('blah').should be_true
114
114
  end
115
+
116
+ it "should be able to clear selected options" do
117
+ sel_list.should_receive(:find_elements).and_return(opts)
118
+ opts.each do |opt|
119
+ opt.should_receive(:selected?).and_return(true)
120
+ opt.should_receive(:click)
121
+ end
122
+ selenium_sel_list.clear
123
+ end
115
124
  end
116
125
  end
117
126
  end
@@ -0,0 +1,505 @@
1
+ require 'spec_helper'
2
+
3
+ class SeleniumAccessorsTestPageObject
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 SeleniumBlockPageObject
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(:selenium_browser) { mock_selenium_browser }
120
+ let(:selenium_page_object) { SeleniumAccessorsTestPageObject.new(selenium_browser) }
121
+ let(:block_page_object) { SeleniumBlockPageObject.new(watir_browser) }
122
+
123
+ before(:each) do
124
+ selenium_browser.stub(:switch_to).and_return(selenium_browser)
125
+ selenium_browser.stub(:default_content)
126
+ end
127
+
128
+ describe "link accessors" do
129
+ it "should select a link" do
130
+ selenium_browser.stub_chain(:find_element, :click)
131
+ selenium_page_object.google_search
132
+ end
133
+
134
+ it "should return a link element" do
135
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
136
+ element = selenium_page_object.google_search_element
137
+ element.should be_instance_of PageObject::Elements::Link
138
+ end
139
+ end
140
+
141
+
142
+ describe "text_field accessors" do
143
+ it "should get the text from the text field element" do
144
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
145
+ selenium_browser.should_receive(:attribute).with('value').and_return('Katie')
146
+ selenium_page_object.first_name.should == 'Katie'
147
+ end
148
+
149
+ it "should set some text on a text field element" do
150
+ selenium_browser.should_receive(:find_element).twice.and_return(selenium_browser)
151
+ selenium_browser.should_receive(:clear)
152
+ selenium_browser.should_receive(:send_keys).with('Katie')
153
+ selenium_page_object.first_name = 'Katie'
154
+ end
155
+
156
+ it "should retrieve a text field element" do
157
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
158
+ element = selenium_page_object.first_name_element
159
+ element.should be_instance_of PageObject::Elements::TextField
160
+ end
161
+ end
162
+
163
+
164
+ describe "hidden field accessors" do
165
+ it "should get the text from a hidden field" do
166
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
167
+ selenium_browser.should_receive(:attribute).with('value').and_return("12345")
168
+ selenium_page_object.social_security_number.should == "12345"
169
+ end
170
+
171
+ it "should retrieve a hidden field element" do
172
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
173
+ element = selenium_page_object.social_security_number_element
174
+ element.should be_instance_of PageObject::Elements::HiddenField
175
+ end
176
+ end
177
+
178
+ describe "text area accessors" do
179
+ it "should set some text on the text area" do
180
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
181
+ selenium_browser.should_receive(:clear)
182
+ selenium_browser.should_receive(:send_keys).with("123 main street")
183
+ selenium_page_object.address = "123 main street"
184
+ end
185
+
186
+ it "should get the text from the text area" do
187
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
188
+ selenium_browser.should_receive(:attribute).with('value').and_return("123 main street")
189
+ selenium_page_object.address.should == "123 main street"
190
+ end
191
+
192
+ it "should retrieve a text area element" do
193
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
194
+ element = selenium_page_object.address_element
195
+ element.should be_instance_of PageObject::Elements::TextArea
196
+ end
197
+ end
198
+
199
+ describe "select_list accessors" do
200
+ it "should should get the current item from a select list" do
201
+ selected = "OH"
202
+ selected.should_receive(:selected?).and_return(selected)
203
+ selected.should_receive(:text).and_return("OH")
204
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
205
+ selenium_browser.should_receive(:find_elements).and_return([selected])
206
+ selenium_page_object.state.should == "OH"
207
+ end
208
+
209
+ it "should set the current item of a select list" do
210
+ option = double('option')
211
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
212
+ selenium_browser.should_receive(:find_elements).and_return([option])
213
+ option.should_receive(:text).and_return('OH')
214
+ option.should_receive(:click)
215
+ selenium_page_object.state = "OH"
216
+ end
217
+
218
+ it "should retrieve the select list element" do
219
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
220
+ element = selenium_page_object.state_element
221
+ element.should be_instance_of PageObject::Elements::SelectList
222
+ end
223
+ end
224
+
225
+
226
+ describe "check_box accessors" do
227
+ it "should check a check box element" do
228
+ selenium_browser.should_receive(:find_element).twice.and_return(selenium_browser)
229
+ selenium_browser.should_receive(:selected?).and_return(false)
230
+ selenium_browser.should_receive(:click)
231
+ selenium_page_object.check_active
232
+ end
233
+
234
+ it "should clear a check box element" do
235
+ selenium_browser.should_receive(:find_element).twice.and_return(selenium_browser)
236
+ selenium_browser.should_receive(:selected?).and_return(true)
237
+ selenium_browser.should_receive(:click)
238
+ selenium_page_object.uncheck_active
239
+ end
240
+
241
+ it "should know if a check box element is selected" do
242
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
243
+ selenium_browser.should_receive(:selected?).and_return(true)
244
+ selenium_page_object.active_checked?.should be_true
245
+ end
246
+
247
+ it "should retrieve a checkbox element" do
248
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
249
+ element = selenium_page_object.active_element
250
+ element.should be_instance_of PageObject::Elements::CheckBox
251
+ end
252
+ end
253
+
254
+
255
+ describe "radio accessors" do
256
+ it "should select a radio button" do
257
+ selenium_browser.should_receive(:find_element).twice.and_return(selenium_browser)
258
+ selenium_browser.should_receive(:selected?).and_return(false)
259
+ selenium_browser.should_receive(:click)
260
+ selenium_page_object.select_first
261
+ end
262
+
263
+ it "should clear a radio button" do
264
+ selenium_browser.should_receive(:find_element).twice.and_return(selenium_browser)
265
+ selenium_browser.should_receive(:selected?).and_return(true)
266
+ selenium_browser.should_receive(:click)
267
+ selenium_page_object.clear_first
268
+ end
269
+
270
+ it "should determine if a radio is selected" do
271
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
272
+ selenium_browser.should_receive(:selected?).and_return(true)
273
+ selenium_page_object.first_selected?
274
+ end
275
+
276
+ it "should retrieve a radio button element" do
277
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
278
+ element = selenium_page_object.first_element
279
+ element.should be_instance_of PageObject::Elements::RadioButton
280
+ end
281
+ end
282
+
283
+ describe "button accessors" do
284
+ it "should be able to click a button" do
285
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
286
+ selenium_browser.should_receive(:click)
287
+ selenium_page_object.click_me
288
+ end
289
+
290
+ it "should retrieve a button element" do
291
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
292
+ element = selenium_page_object.click_me_element
293
+ element.should be_instance_of PageObject::Elements::Button
294
+ end
295
+ end
296
+
297
+ describe "div accessors" do
298
+ it "should retrieve the text from a div" do
299
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
300
+ selenium_browser.should_receive(:text).and_return("Message from div")
301
+ selenium_page_object.message.should == "Message from div"
302
+ end
303
+
304
+ it "should retrieve the div element from the page" do
305
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
306
+ element = selenium_page_object.message_element
307
+ element.should be_instance_of PageObject::Elements::Div
308
+ end
309
+ end
310
+
311
+ describe "span accessors" do
312
+ it "should retrieve the text from a span" do
313
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
314
+ selenium_browser.should_receive(:text).and_return("Alert")
315
+ selenium_page_object.alert.should == "Alert"
316
+ end
317
+
318
+ it "should retrieve the span element from the page" do
319
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
320
+ element = selenium_page_object.alert_element
321
+ element.should be_instance_of PageObject::Elements::Span
322
+ end
323
+ end
324
+
325
+ describe "table accessors" do
326
+ it "should retrieve the table element from the page" do
327
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
328
+ element = selenium_page_object.cart_element
329
+ element.should be_instance_of(PageObject::Elements::Table)
330
+ end
331
+ end
332
+
333
+ describe "table cell accessors" do
334
+ it "should retrieve the text from the cell" do
335
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
336
+ selenium_browser.should_receive(:text).and_return('celldata')
337
+ selenium_page_object.total.should == 'celldata'
338
+ end
339
+
340
+ it "should retrieve the cell element from the page" do
341
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
342
+ element = selenium_page_object.total_element
343
+ element.should be_instance_of PageObject::Elements::TableCell
344
+ end
345
+ end
346
+
347
+ describe "image accessors" do
348
+ it "should retrieve the image element from the page" do
349
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
350
+ element = selenium_page_object.logo_element
351
+ element.should be_instance_of PageObject::Elements::Image
352
+ end
353
+ end
354
+
355
+ describe "form accessors" do
356
+ it "should retrieve the form element from the page" do
357
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
358
+ element = selenium_page_object.login_element
359
+ element.should be_instance_of PageObject::Elements::Form
360
+ end
361
+ end
362
+
363
+ describe "list item accessors" do
364
+ it "should retrieve the text from the list item" do
365
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
366
+ selenium_browser.should_receive(:text).and_return("value")
367
+ selenium_page_object.item_one.should == "value"
368
+ end
369
+
370
+ it "should retrieve the list item from the page" do
371
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
372
+ element = selenium_page_object.item_one_element
373
+ element.should be_instance_of PageObject::Elements::ListItem
374
+ end
375
+ end
376
+
377
+ describe "unordered list accessors" do
378
+ it "should retrieve the element from the page" do
379
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
380
+ element = selenium_page_object.menu_element
381
+ element.should be_instance_of PageObject::Elements::UnorderedList
382
+ end
383
+ end
384
+
385
+ describe "ordered list accessors" do
386
+ it "should retrieve the element from the page" do
387
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
388
+ element = selenium_page_object.top_five_element
389
+ element.should be_instance_of PageObject::Elements::OrderedList
390
+ end
391
+ end
392
+
393
+ describe "h1 accessors" do
394
+ it "should retrieve the text from the h1" do
395
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
396
+ selenium_browser.should_receive(:text).and_return("value")
397
+ selenium_page_object.heading1.should == "value"
398
+ end
399
+
400
+ it "should retrieve the element from the page" do
401
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
402
+ element = selenium_page_object.heading1_element
403
+ element.should be_instance_of PageObject::Elements::Heading
404
+ end
405
+ end
406
+
407
+ describe "h2 accessors" do
408
+ it "should retrieve the text from the h2" do
409
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
410
+ selenium_browser.should_receive(:text).and_return("value")
411
+ selenium_page_object.heading2.should == "value"
412
+ end
413
+
414
+ it "should retrieve the element from the page" do
415
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
416
+ element = selenium_page_object.heading2_element
417
+ element.should be_instance_of PageObject::Elements::Heading
418
+ end
419
+ end
420
+
421
+ describe "h3 accessors" do
422
+ it "should retrieve the text from the h3" do
423
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
424
+ selenium_browser.should_receive(:text).and_return("value")
425
+ selenium_page_object.heading3.should == "value"
426
+ end
427
+
428
+ it "should retrieve the element from the page" do
429
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
430
+ element = selenium_page_object.heading3_element
431
+ element.should be_instance_of PageObject::Elements::Heading
432
+ end
433
+ end
434
+
435
+ describe "h4 accessors" do
436
+ it "should retrieve the text from the h4" do
437
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
438
+ selenium_browser.should_receive(:text).and_return("value")
439
+ selenium_page_object.heading4.should == "value"
440
+ end
441
+
442
+ it "should retrieve the element from the page" do
443
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
444
+ element = selenium_page_object.heading4_element
445
+ element.should be_instance_of PageObject::Elements::Heading
446
+ end
447
+ end
448
+
449
+ describe "h5 accessors" do
450
+ it "should retrieve the text from the h5" do
451
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
452
+ selenium_browser.should_receive(:text).and_return("value")
453
+ selenium_page_object.heading5.should == "value"
454
+ end
455
+
456
+ it "should retrieve the element from the page" do
457
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
458
+ element = selenium_page_object.heading5_element
459
+ element.should be_instance_of PageObject::Elements::Heading
460
+ end
461
+ end
462
+
463
+ describe "h6 accessors" do
464
+ it "should retrieve the text from the h6" do
465
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
466
+ selenium_browser.should_receive(:text).and_return("value")
467
+ selenium_page_object.heading6.should == "value"
468
+ end
469
+
470
+ it "should retrieve the element from the page" do
471
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
472
+ element = selenium_page_object.heading6_element
473
+ element.should be_instance_of PageObject::Elements::Heading
474
+ end
475
+ end
476
+
477
+
478
+ describe "p accessors" do
479
+ it "should retrieve the text from the p" do
480
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
481
+ selenium_browser.should_receive(:text).and_return("value")
482
+ selenium_page_object.first_para.should == "value"
483
+ end
484
+
485
+ it "should retrieve the element from the page" do
486
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
487
+ element = selenium_page_object.first_para_element
488
+ element.should be_instance_of PageObject::Elements::Paragraph
489
+ end
490
+ end
491
+
492
+ describe "file_field accessors" do
493
+ it "should set the file name" do
494
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
495
+ selenium_browser.should_receive(:send_keys).with('some_file')
496
+ selenium_page_object.upload_me = 'some_file'
497
+ end
498
+
499
+ it "should retrieve a file_field element" do
500
+ selenium_browser.should_receive(:find_element).and_return(selenium_browser)
501
+ element = selenium_page_object.upload_me_element
502
+ element.should be_instance_of PageObject::Elements::FileField
503
+ end
504
+ end
505
+ end