page-object 0.6.4 → 0.6.5
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.
- data/ChangeLog +10 -0
- data/features/hidden_field.feature +0 -2
- data/features/html/multi_elements.html +4 -0
- data/features/multi_elements.feature +139 -24
- data/features/step_definitions/multi_elements_steps.rb +108 -0
- data/features/text_area.feature +1 -3
- data/features/text_field.feature +0 -2
- data/lib/page-object/accessors.rb +53 -58
- data/lib/page-object/element_locators.rb +187 -104
- data/lib/page-object/elements/element.rb +7 -7
- data/lib/page-object/elements/hidden_field.rb +2 -10
- data/lib/page-object/elements/text_area.rb +0 -16
- data/lib/page-object/elements/text_field.rb +2 -10
- data/lib/page-object/platforms/selenium_webdriver/null_selenium_element.rb +28 -0
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +8 -0
- data/lib/page-object/platforms/watir_webdriver/page_object.rb +10 -1
- data/lib/page-object/version.rb +1 -1
- data/page-object.gemspec +1 -1
- data/spec/page-object/accessors_spec.rb +180 -0
- data/spec/page-object/element_locators_spec.rb +281 -2
- data/spec/page-object/elements/hidden_field_spec.rb +2 -12
- data/spec/page-object/elements/text_area_spec.rb +2 -12
- data/spec/page-object/elements/text_field_spec.rb +2 -12
- metadata +16 -15
data/ChangeLog
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== Version 0.6.5 / 2012-4-12
|
2
|
+
* Enhancements
|
3
|
+
* Added a page level element method to return a generic Element object
|
4
|
+
* Added a method to retrieve all file fields on a page
|
5
|
+
* Updated all accessor methods to take a default identifier of {:index => 0}
|
6
|
+
* Updated all page level element locators to take a default identifier of {:index => 0}
|
7
|
+
* Updated all page level multi-element locators to take a default identifier of {}
|
8
|
+
* Updated deprecation warning to print to stderr (Thanks Josh Adell)
|
9
|
+
* Updated to use selenium-webdriver 2.21.0
|
10
|
+
|
1
11
|
=== Version 0.6.4 / 2012-3-27
|
2
12
|
* Enhancements
|
3
13
|
* Added support for finding the following elements by :css
|
@@ -136,5 +136,9 @@
|
|
136
136
|
<p class="p">Paragraph Two</p>
|
137
137
|
<p class="p">Paragraph Three</p>
|
138
138
|
|
139
|
+
<input type="file" class="file_field_class" title="File Field 1" />
|
140
|
+
<input type="file" class="file_field_class" title="File Field 2" />
|
141
|
+
<input type="file" class="file_field_class" title="File Field 3" />
|
142
|
+
|
139
143
|
</body>
|
140
144
|
</html>
|
@@ -3,173 +3,288 @@ Feature: Multi Elements
|
|
3
3
|
Background:
|
4
4
|
Given I am on the multi elements page
|
5
5
|
|
6
|
-
Scenario: Selecting buttons
|
6
|
+
Scenario: Selecting buttons using an identifier
|
7
7
|
When I select the buttons with class "button"
|
8
8
|
Then I should have 3 buttons
|
9
9
|
And the value of button 1 should be "Button 1"
|
10
10
|
And the value of button 2 should be "Button 2"
|
11
11
|
And the value of button 3 should be "Button 3"
|
12
|
+
|
13
|
+
Scenario: Selecting buttons using no identifier
|
14
|
+
When I select all buttons using no identifier
|
15
|
+
Then I should have 3 buttons
|
12
16
|
|
13
|
-
Scenario: Selecting
|
17
|
+
Scenario: Selecting text fields using an identifier
|
14
18
|
When I select the text fields with class "textfield"
|
15
19
|
Then I should have 3 text fields
|
16
20
|
And the value of text field 1 should be "text 1"
|
17
21
|
And the value of text field 2 should be "text 2"
|
18
22
|
And the value of text field 3 should be "text 3"
|
23
|
+
|
24
|
+
Scenario: Selecting text fields using no identifier
|
25
|
+
When I select all text fields using no identifier
|
26
|
+
Then I should have 3 text fields
|
19
27
|
|
20
|
-
Scenario: Selecting
|
28
|
+
Scenario: Selecting hidden fields using an identifier
|
21
29
|
When I select the hidden fields with class "hiddenfield"
|
22
30
|
Then I should have 3 hidden fields
|
23
31
|
And the value of hidden field 1 should be "hidden 1"
|
24
32
|
And the value of hidden field 2 should be "hidden 2"
|
25
33
|
And the value of hidden field 3 should be "hidden 3"
|
26
34
|
|
27
|
-
Scenario: Selecting
|
35
|
+
Scenario: Selecting hidden fields using no identifier
|
36
|
+
When I select all hidden fields using no identifier
|
37
|
+
Then I should have 3 hidden fields
|
38
|
+
|
39
|
+
Scenario: Selecting text areas using an identifier
|
28
40
|
When I select the text areas with class "textarea"
|
29
41
|
Then I should have 3 text areas
|
30
42
|
And the value of text area 1 should be "textarea 1"
|
31
43
|
And the value of text area 2 should be "textarea 2"
|
32
44
|
And the value of text area 3 should be "textarea 3"
|
33
45
|
|
34
|
-
Scenario: Selecting
|
46
|
+
Scenario: Selecting text areas using no identifier
|
47
|
+
When I select text areas using no identifier
|
48
|
+
Then I should have 3 text areas
|
49
|
+
|
50
|
+
Scenario: Selecting select lists using an identifier
|
35
51
|
When I select the select lists with class "selectlist"
|
36
52
|
Then I should have 3 select lists
|
37
53
|
And the value of select list 1 should be "selectlist 1"
|
38
54
|
And the value of select list 2 should be "selectlist 2"
|
39
55
|
And the value of select list 3 should be "selectlist 3"
|
40
56
|
|
41
|
-
Scenario: Selecting
|
57
|
+
Scenario: Selecting select lists using no identifier
|
58
|
+
When I select select lists using no identifier
|
59
|
+
Then I should have 3 select lists
|
60
|
+
|
61
|
+
Scenario: Selecting links using an identifier
|
42
62
|
When I select the link with class "link"
|
43
63
|
Then I should have 3 links
|
44
64
|
And the text of link 1 should be "link 1"
|
45
65
|
And the text of link 2 should be "link 2"
|
46
66
|
And the text of link 3 should be "link 3"
|
47
67
|
|
48
|
-
Scenario: Selecting
|
68
|
+
Scenario: Selecting links using no identifier
|
69
|
+
When I select links using no identifier
|
70
|
+
Then I should have 3 links
|
71
|
+
|
72
|
+
Scenario: Selecting checkboxes using an identifier
|
49
73
|
When I select the check boxes with class "checkbox"
|
50
74
|
Then I should have 3 checkboxes
|
51
75
|
And the value of checkbox 1 should be "checkbox 1"
|
52
76
|
And the value of checkbox 2 should be "checkbox 2"
|
53
77
|
And the value of checkbox 3 should be "checkbox 3"
|
78
|
+
|
79
|
+
Scenario: Selecting checkboxes using no identifier
|
80
|
+
When I select checboxes using no identifier
|
81
|
+
Then I should have 3 checkboxes
|
54
82
|
|
55
|
-
Scenario: Selecting radio buttons
|
83
|
+
Scenario: Selecting radio buttons using an identifier
|
56
84
|
When I select the radio button with class "radio"
|
57
85
|
Then I should have 3 radio buttons
|
58
86
|
And the value of radio button 1 should be "radio 1"
|
59
87
|
And the value of radio button 2 should be "radio 2"
|
60
88
|
And the value of radio button 3 should be "radio 3"
|
61
89
|
|
62
|
-
Scenario: Selecting
|
90
|
+
Scenario: Selecting radio buttons using no identifier
|
91
|
+
When I select radio buttons using no identifier
|
92
|
+
Then I should have 3 radio buttons
|
93
|
+
|
94
|
+
Scenario: Selecting divs using an identifier
|
63
95
|
When I select the div with class "div"
|
64
96
|
Then I should have 3 divs
|
65
97
|
And the text of div 1 should be "Div 1"
|
66
98
|
And the text of div 2 should be "Div 2"
|
67
99
|
And the text of div 3 should be "Div 3"
|
68
100
|
|
69
|
-
Scenario: Selecting
|
101
|
+
Scenario: Selecting divs using no identifier
|
102
|
+
When I select divs using no identifier
|
103
|
+
Then I should have 3 divs
|
104
|
+
|
105
|
+
Scenario: Selecting spans using an identifier
|
70
106
|
When I select the spans with class "span"
|
71
107
|
Then I should have 3 spans
|
72
108
|
And the text of span 1 should be "Span 1"
|
73
109
|
And the text of span 2 should be "Span 2"
|
74
110
|
And the text of span 3 should be "Span 3"
|
75
111
|
|
76
|
-
Scenario: Selecting
|
112
|
+
Scenario: Selecting spans using no identifier
|
113
|
+
When I select spans using no identifier
|
114
|
+
Then I should have 3 spans
|
115
|
+
|
116
|
+
Scenario: Selecting tables using an identifier
|
77
117
|
When I select the tables with class "table"
|
78
118
|
Then I should have 3 tables
|
79
119
|
And the first row first column for table 1 should have "Data 1"
|
80
120
|
And the first row first column for table 2 should have "Data 4"
|
81
121
|
And the first row first column for table 3 should have "Data 7"
|
82
122
|
|
83
|
-
Scenario: Selecting
|
123
|
+
Scenario: Selecting tables using no identifier
|
124
|
+
When I select tables using no identifier
|
125
|
+
Then I should have 3 tables
|
126
|
+
|
127
|
+
Scenario: Selecting cells using an identifier
|
84
128
|
When I select the cells with class "td"
|
85
129
|
Then I should have 3 cells
|
86
130
|
And the text for cell 1 should be "Data 1"
|
87
131
|
And the text for cell 2 should be "Data 2"
|
88
132
|
And the text for cell 3 should be "Data 3"
|
89
133
|
|
90
|
-
Scenario: Selecting
|
134
|
+
Scenario: Selecting cells using no identifier
|
135
|
+
When I select the cells using no identifier
|
136
|
+
Then I should have 9 cells
|
137
|
+
|
138
|
+
Scenario: Selecting images using an identifier
|
91
139
|
When I select the images with class "image"
|
92
140
|
Then I should have 3 images
|
93
141
|
And the alt for image 1 should be "image 1"
|
94
142
|
And the alt for image 2 should be "image 2"
|
95
143
|
And the alt for image 3 should be "image 3"
|
144
|
+
|
145
|
+
Scenario: Selecting images using no identifier
|
146
|
+
When I select the images using no identifier
|
147
|
+
Then I should have 3 images
|
96
148
|
|
97
|
-
Scenario: Selecting forms
|
149
|
+
Scenario: Selecting forms using an identifier
|
98
150
|
When I select the forms with class "form"
|
99
151
|
Then I should have 3 forms
|
100
152
|
And the action for form 1 should be "form1"
|
101
153
|
And the action for form 2 should be "form2"
|
102
154
|
And the action for form 3 should be "form3"
|
155
|
+
|
156
|
+
Scenario: Selecting forms using no identifier
|
157
|
+
When I select the forms using no identifier
|
158
|
+
Then I should have 3 forms
|
103
159
|
|
104
|
-
Scenario: Selecting list items
|
160
|
+
Scenario: Selecting list items using an identifier
|
105
161
|
When I select the list items with class "li"
|
106
162
|
Then I should have 3 list items
|
107
163
|
And the text for list item 1 should be "Item One"
|
108
164
|
And the text for list item 2 should be "Item Two"
|
109
165
|
And the text for list item 3 should be "Item Three"
|
166
|
+
|
167
|
+
Scenario: Selecting list items using no identifier
|
168
|
+
When I select the list items using no identifier
|
169
|
+
Then I should have 8 list items
|
110
170
|
|
111
|
-
Scenario: Selecting unordered lists
|
171
|
+
Scenario: Selecting unordered lists using an identifier
|
112
172
|
When I select the unordered list with class "ul"
|
113
173
|
Then I should have 3 unordered lists
|
114
174
|
And the text for the first item in unordered list 1 should be "Item One"
|
115
175
|
And the text for the first item in unordered list 2 should be "Item Four"
|
116
176
|
And the text for the first item in unordered list 3 should be "Item Five"
|
117
177
|
|
118
|
-
Scenario: Selecting
|
178
|
+
Scenario: Selecting unordered lists using no identifier
|
179
|
+
When I select the unordered list using no parameter
|
180
|
+
Then I should have 3 unordered lists
|
181
|
+
|
182
|
+
Scenario: Selecting ordered lists using an identifier
|
119
183
|
When I select the ordered lists with class "ol"
|
120
184
|
Then I should have 3 ordered lists
|
121
185
|
And the text for the first item in ordered list 1 should be "Number One"
|
122
186
|
And the text for the first item in ordered list 2 should be "Number Two"
|
123
187
|
And the text for the first item in ordered list 3 should be "Number Three"
|
188
|
+
|
189
|
+
Scenario: Selecting ordered lists using no identifier
|
190
|
+
When I select the ordered lists using no identifier
|
191
|
+
Then I should have 3 ordered lists
|
124
192
|
|
125
|
-
Scenario: Selecting h1s
|
193
|
+
Scenario: Selecting h1s using an identifier
|
126
194
|
When I select the h1s with class "h1"
|
127
195
|
Then I should have 3 h1s
|
128
196
|
And the text for h1 1 should be "H1 One"
|
129
197
|
And the text for h1 2 should be "H1 Two"
|
130
198
|
And the text for h1 3 should be "H1 Three"
|
199
|
+
|
200
|
+
Scenario: Selecting h1s using no identifier
|
201
|
+
When I select h1s using no identifier
|
202
|
+
Then I should have 3 h1s
|
131
203
|
|
132
|
-
Scenario: Selecting h2s
|
204
|
+
Scenario: Selecting h2s using an identifier
|
133
205
|
When I select the h2s with the class "h2"
|
134
206
|
Then I should have 3 h2s
|
135
207
|
And the text for h2 1 should be "H2 One"
|
136
208
|
And the text for h2 2 should be "H2 Two"
|
137
209
|
And the text for h2 3 should be "H2 Three"
|
210
|
+
|
211
|
+
Scenario: Selecting h2s using no identifier
|
212
|
+
When I select h2s using no identifier
|
213
|
+
Then I should have 3 h2s
|
138
214
|
|
139
|
-
Scenario: Selecting h3s
|
215
|
+
Scenario: Selecting h3s using an identifier
|
140
216
|
When I select the h3s with the class "h3"
|
141
217
|
Then I should have 3 h3s
|
142
218
|
And the text for h3 1 should be "H3 One"
|
143
219
|
And the text for h3 2 should be "H3 Two"
|
144
220
|
And the text for h3 3 should be "H3 Three"
|
221
|
+
|
222
|
+
Scenario: Selecting h3s using no identifier
|
223
|
+
When I select h3s using no identifier
|
224
|
+
Then I should have 3 h3s
|
145
225
|
|
146
|
-
Scenario: Selecting h4s
|
226
|
+
Scenario: Selecting h4s using an identifier
|
147
227
|
When I select the h4s with the class "h4"
|
148
228
|
Then I should have 3 h4s
|
149
229
|
And the text for H4 1 should be "H4 One"
|
150
230
|
And the text for H4 2 should be "H4 Two"
|
151
231
|
And the text for H4 3 should be "H4 Three"
|
152
232
|
|
153
|
-
Scenario: Selecting
|
233
|
+
Scenario: Selecting h4s using no identifier
|
234
|
+
When I select h4s using no identifier
|
235
|
+
Then I should have 3 h4s
|
236
|
+
|
237
|
+
Scenario: Selecting h5s using an identifier
|
154
238
|
When I select the h5s with the class "h5"
|
155
239
|
Then I should have 3 h5s
|
156
240
|
And the text for H5 1 should be "H5 One"
|
157
241
|
And the text for H5 2 should be "H5 Two"
|
158
242
|
And the text for H5 3 should be "H5 Three"
|
243
|
+
|
244
|
+
Scenario: Selecting h5s using no identifier
|
245
|
+
When I select h5s using no identifier
|
246
|
+
Then I should have 3 h5s
|
159
247
|
|
160
|
-
Scenario: Selecting h6s
|
248
|
+
Scenario: Selecting h6s using an identifier
|
161
249
|
When I select the h6s with the class "h6"
|
162
250
|
Then I should have 3 h6s
|
163
251
|
And the text for H6 1 should be "H6 One"
|
164
252
|
And the text for H6 2 should be "H6 Two"
|
165
253
|
And the text for H6 3 should be "H6 Three"
|
254
|
+
|
255
|
+
Scenario: Selecting h6s using no identifier
|
256
|
+
When I select h6s using no identifier
|
257
|
+
Then I should have 3 h6s
|
166
258
|
|
167
|
-
Scenario: Selecting paragraphs
|
259
|
+
Scenario: Selecting paragraphs using an identifier
|
168
260
|
When I select the paragraph with class "p"
|
169
261
|
Then I should have 3 paragraphs
|
170
262
|
And the text for paragraph 1 should be "Paragraph One"
|
171
263
|
And the text for paragraph 2 should be "Paragraph Two"
|
172
264
|
And the text for paragraph 3 should be "Paragraph Three"
|
173
265
|
|
266
|
+
Scenario: Selecting paragraphs using no identifier
|
267
|
+
When I select paragraphs using no identifier
|
268
|
+
Then I should have 3 paragraphs
|
269
|
+
|
270
|
+
Scenario: Selecting labels with an identifier
|
271
|
+
When I select the labels with class "label"
|
272
|
+
Then I should have 3 labels
|
273
|
+
And the text for label 1 should be "Label 1"
|
274
|
+
And the text for label 2 should be "Label 2"
|
275
|
+
And the text for label 3 should be "Label 3"
|
276
|
+
|
277
|
+
Scenario: Selecting labels using no identifier
|
278
|
+
When I select labels using no identifier
|
279
|
+
Then I should have 3 labels
|
174
280
|
|
281
|
+
Scenario: Selecting file fields with an identifier
|
282
|
+
When I select the file fields with class "file_field_class"
|
283
|
+
Then I should have 3 file fields
|
284
|
+
And the title for file field 1 should be "File Field 1"
|
285
|
+
And the title for file field 2 should be "File Field 2"
|
286
|
+
And the title for file field 3 should be "File Field 3"
|
175
287
|
|
288
|
+
Scenario: Selecting file fields using no identifier
|
289
|
+
When I select the file fields using no identifier
|
290
|
+
Then I should have 3 file fields
|
@@ -295,3 +295,111 @@ end
|
|
295
295
|
Then /^the text for paragraph (\d+) should be "([^\"]*)"$/ do |para_num, text|
|
296
296
|
@elements[para_num.to_i - 1].text.should == text
|
297
297
|
end
|
298
|
+
|
299
|
+
When /^I select all buttons using no identifier$/ do
|
300
|
+
@elements = @page.button_elements
|
301
|
+
end
|
302
|
+
|
303
|
+
When /^I select all text fields using no identifier$/ do
|
304
|
+
@elements = @page.text_field_elements
|
305
|
+
end
|
306
|
+
|
307
|
+
When /^I select all hidden fields using no identifier$/ do
|
308
|
+
@elements = @page.hidden_field_elements
|
309
|
+
end
|
310
|
+
|
311
|
+
When /^I select text areas using no identifier$/ do
|
312
|
+
@elements = @page.text_area_elements
|
313
|
+
end
|
314
|
+
|
315
|
+
When /^I select select lists using no identifier$/ do
|
316
|
+
@elements = @page.select_list_elements
|
317
|
+
end
|
318
|
+
|
319
|
+
When /^I select links using no identifier$/ do
|
320
|
+
@elements = @page.link_elements
|
321
|
+
end
|
322
|
+
|
323
|
+
When /^I select checboxes using no identifier$/ do
|
324
|
+
@elements = @page.checkbox_elements
|
325
|
+
end
|
326
|
+
|
327
|
+
When /^I select radio buttons using no identifier$/ do
|
328
|
+
@elements = @page.radio_button_elements
|
329
|
+
end
|
330
|
+
|
331
|
+
When /^I select divs using no identifier$/ do
|
332
|
+
@elements = @page.div_elements
|
333
|
+
end
|
334
|
+
|
335
|
+
When /^I select spans using no identifier$/ do
|
336
|
+
@elements = @page.span_elements
|
337
|
+
end
|
338
|
+
|
339
|
+
When /^I select tables using no identifier$/ do
|
340
|
+
@elements = @page.table_elements
|
341
|
+
end
|
342
|
+
|
343
|
+
When /^I select the cells using no identifier$/ do
|
344
|
+
@elements = @page.cell_elements
|
345
|
+
end
|
346
|
+
|
347
|
+
When /^I select the images using no identifier$/ do
|
348
|
+
@elements = @page.image_elements
|
349
|
+
end
|
350
|
+
|
351
|
+
When /^I select the forms using no identifier$/ do
|
352
|
+
@elements = @page.form_elements
|
353
|
+
end
|
354
|
+
|
355
|
+
When /^I select the list items using no identifier$/ do
|
356
|
+
@elements = @page.list_item_elements
|
357
|
+
end
|
358
|
+
|
359
|
+
When /^I select the unordered list using no parameter$/ do
|
360
|
+
@elements = @page.unordered_list_elements
|
361
|
+
end
|
362
|
+
|
363
|
+
When /^I select the ordered lists using no identifier$/ do
|
364
|
+
@elements = @page.ordered_list_elements
|
365
|
+
end
|
366
|
+
|
367
|
+
When /^I select h(\d+)s using no identifier$/ do |num|
|
368
|
+
@elements = @page.send "h#{num}_elements"
|
369
|
+
end
|
370
|
+
|
371
|
+
When /^I select paragraphs using no identifier$/ do
|
372
|
+
@elements = @page.paragraph_elements
|
373
|
+
end
|
374
|
+
|
375
|
+
When /^I select the labels with class "([^\"]*)"$/ do |class_name|
|
376
|
+
@elements = @page.label_elements(:class => class_name)
|
377
|
+
end
|
378
|
+
|
379
|
+
Then /^I should have (\d+) labels$/ do |num_labels|
|
380
|
+
@elements.size.should == num_labels.to_i
|
381
|
+
end
|
382
|
+
|
383
|
+
Then /^the text for label (\d+) should be "([^\"]*)"$/ do |label_num, text|
|
384
|
+
@elements[label_num.to_i - 1].text.should == text
|
385
|
+
end
|
386
|
+
|
387
|
+
When /^I select labels using no identifier$/ do
|
388
|
+
@elements = @page.label_elements
|
389
|
+
end
|
390
|
+
|
391
|
+
When /^I select the file fields with class "([^\"]*)"$/ do |class_name|
|
392
|
+
@elements = @page.file_field_elements(:class => class_name)
|
393
|
+
end
|
394
|
+
|
395
|
+
Then /^I should have (\d+) file fields$/ do |num_file_fields|
|
396
|
+
@elements.size.should == num_file_fields.to_i
|
397
|
+
end
|
398
|
+
|
399
|
+
Then /^the title for file field (\d+) should be "([^\"]*)"$/ do |file_field_num, title|
|
400
|
+
@elements[file_field_num.to_i - 1].attribute('title').should == title
|
401
|
+
end
|
402
|
+
|
403
|
+
When /^I select the file fields using no identifier$/ do
|
404
|
+
@elements = @page.file_field_elements
|
405
|
+
end
|