page-object 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +26 -2
- data/features/button.feature +5 -0
- data/features/check_box.feature +4 -2
- data/features/div.feature +4 -0
- data/features/form.feature +3 -0
- data/features/hidden_field.feature +4 -0
- data/features/image.feature +5 -0
- data/features/link.feature +4 -0
- data/features/list_item.feature +4 -0
- data/features/ordered_list.feature +5 -0
- data/features/radio_button.feature +4 -0
- data/features/select_list.feature +5 -1
- data/features/span.feature +4 -0
- data/features/step_definitions/accessor_steps.rb +0 -266
- data/features/step_definitions/button_steps.rb +23 -0
- data/features/step_definitions/check_box_steps.rb +31 -0
- data/features/step_definitions/div_steps.rb +15 -0
- data/features/step_definitions/element_steps.rb +0 -4
- data/features/step_definitions/form_steps.rb +15 -0
- data/features/step_definitions/hidden_field_steps.rb +23 -0
- data/features/step_definitions/image_steps.rb +23 -0
- data/features/step_definitions/link_steps.rb +20 -0
- data/features/step_definitions/list_item_steps.rb +15 -0
- data/features/step_definitions/ordered_list_steps.rb +15 -0
- data/features/step_definitions/radio_button_steps.rb +23 -0
- data/features/step_definitions/select_list_steps.rb +28 -0
- data/features/step_definitions/span_steps.rb +15 -0
- data/features/step_definitions/table_cell_steps.rb +11 -0
- data/features/step_definitions/table_steps.rb +12 -0
- data/features/step_definitions/text_area_steps.rb +27 -0
- data/features/step_definitions/text_field_steps.rb +27 -0
- data/features/step_definitions/unordered_list_steps.rb +16 -0
- data/features/table.feature +4 -0
- data/features/table_cell.feature +3 -0
- data/features/text_area.feature +4 -0
- data/features/text_field.feature +4 -0
- data/features/unordered_list.feature +5 -0
- data/lib/page-object.rb +8 -3
- data/lib/page-object/element_locators.rb +277 -0
- data/lib/page-object/platforms/selenium/page_object.rb +6 -5
- data/lib/page-object/platforms/watir/page_object.rb +2 -2
- data/lib/page-object/platforms/watir/text_area.rb +1 -1
- data/lib/page-object/version.rb +1 -1
- data/page-object.gemspec +2 -2
- data/spec/page-object/element_locators_spec.rb +113 -0
- data/spec/page-object/page-object_spec.rb +4 -4
- metadata +40 -5
data/ChangeLog
CHANGED
@@ -1,5 +1,29 @@
|
|
1
|
-
=== Version 0.2.
|
2
|
-
*
|
1
|
+
=== Version 0.2.5 / 2011-08-19
|
2
|
+
* Enhancements
|
3
|
+
* #attach_to_window takes an optional block - will return to calling window after block executes
|
4
|
+
* Added the following instance methods to PageObject via ElementLocators
|
5
|
+
* #button_element
|
6
|
+
* #text_field_element
|
7
|
+
* #hidden_field_element
|
8
|
+
* #text_area_element
|
9
|
+
* #select_list_element
|
10
|
+
* #link_element
|
11
|
+
* #checkbox_element
|
12
|
+
* #radio_button_element
|
13
|
+
* #div_element
|
14
|
+
* #span_element
|
15
|
+
* #table_element
|
16
|
+
* #cell_element
|
17
|
+
* #image_element
|
18
|
+
* #form_element
|
19
|
+
* #list_item_element
|
20
|
+
* #unordered_list_element
|
21
|
+
* #ordered_list_element
|
22
|
+
* Updated to use selenium-webdriver 2.4.0
|
23
|
+
* Updated to use watir-webdriver 0.3.2
|
24
|
+
|
25
|
+
=== Version 0.2.4 / 2011-08-08
|
26
|
+
* Enhancements
|
3
27
|
* Can now find span by :text
|
4
28
|
* Can now find button by :value
|
5
29
|
* Added #forward and #back methods to PageObject
|
data/features/button.feature
CHANGED
data/features/check_box.feature
CHANGED
@@ -6,7 +6,7 @@ Feature: Check Box
|
|
6
6
|
Background:
|
7
7
|
Given I am on the static elements page
|
8
8
|
|
9
|
-
Scenario: Selecting
|
9
|
+
Scenario: Selecting a check box
|
10
10
|
When I select the First check box
|
11
11
|
Then the First check box should be selected
|
12
12
|
When I unselect the First check box
|
@@ -33,9 +33,11 @@ Feature: Check Box
|
|
33
33
|
| class | index |
|
34
34
|
| name | index |
|
35
35
|
|
36
|
-
|
37
36
|
Scenario: Retrieve a CheckBox
|
38
37
|
When I retrieve a check box element
|
39
38
|
Then I should know it exists
|
40
39
|
And I should know it is visible
|
41
40
|
|
41
|
+
Scenario: Finding a check box dynamically
|
42
|
+
When I select the first check box while the script is executing
|
43
|
+
Then the First check box should be selected
|
data/features/div.feature
CHANGED
data/features/form.feature
CHANGED
data/features/image.feature
CHANGED
@@ -30,3 +30,8 @@ Feature: Image
|
|
30
30
|
| param1 | param2 |
|
31
31
|
| class | index |
|
32
32
|
| name | index |
|
33
|
+
|
34
|
+
Scenario: Finding an image dynamically
|
35
|
+
When I get the image element while the script is executing
|
36
|
+
Then the image should be "106" pixels wide
|
37
|
+
And the image should be "106" pixels tall
|
data/features/link.feature
CHANGED
data/features/list_item.feature
CHANGED
@@ -31,3 +31,8 @@ Feature: Ordered list
|
|
31
31
|
| param1 | param2 |
|
32
32
|
| class | index |
|
33
33
|
| name | index |
|
34
|
+
|
35
|
+
Scenario: Finding a ordered list dynamically
|
36
|
+
When I search for the ordered list while the script is executing
|
37
|
+
And I get the first item from the list
|
38
|
+
Then the list items text should be "Number One"
|
@@ -39,3 +39,7 @@ Feature: Radio Buttons
|
|
39
39
|
When I retrieve a radio button
|
40
40
|
Then I should know it exists
|
41
41
|
And I should know it is visible
|
42
|
+
|
43
|
+
Scenario: Finding a radio button dynamically
|
44
|
+
When I select the radio button while the script is executing
|
45
|
+
Then the "Milk" radio button should be selected
|
@@ -23,7 +23,7 @@ Feature: Select List
|
|
23
23
|
| xpath |
|
24
24
|
| index |
|
25
25
|
|
26
|
-
Scenario Outline: Locating a
|
26
|
+
Scenario Outline: Locating a select list using multiple parameters
|
27
27
|
When I search for the select list by "<param1>" and "<param2>"
|
28
28
|
Then I should be able to select "Test 2"
|
29
29
|
And the value for the selected item should be "option2"
|
@@ -38,3 +38,7 @@ Feature: Select List
|
|
38
38
|
Then option "1" should contain "Test 1"
|
39
39
|
And option "2" should contain "Test 2"
|
40
40
|
And each option should contain "Test"
|
41
|
+
|
42
|
+
Scenario: Finding a select list dynamically
|
43
|
+
When I find a select list while the script is executing
|
44
|
+
Then I should be able to select "Test 2" from the list
|
data/features/span.feature
CHANGED
@@ -1,290 +1,24 @@
|
|
1
|
-
When /^I type "([^\"]*)" into the text field$/ do |text|
|
2
|
-
@page.text_field_id = text
|
3
|
-
end
|
4
|
-
|
5
|
-
Then /^the text field should contain "([^\"]*)"$/ do |expected_text|
|
6
|
-
@page.text_field_id.should == expected_text
|
7
|
-
end
|
8
|
-
|
9
|
-
When /^I search for the text field by "([^\"]*)"$/ do |how|
|
10
|
-
@how = how
|
11
|
-
end
|
12
|
-
|
13
|
-
When /^I search for the text field by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
14
|
-
@how = "#{param1}_#{param2}"
|
15
|
-
end
|
16
|
-
|
17
|
-
Then /^I should be able to type "([^\"]*)" into the field$/ do |value|
|
18
|
-
@page.send "text_field_#{@how}=".to_sym, value
|
19
|
-
end
|
20
|
-
|
21
|
-
When /^I type "([^\"]*)" into the text area$/ do |text|
|
22
|
-
@page.text_area_id = text
|
23
|
-
end
|
24
|
-
|
25
|
-
Then /^the text area should contain "([^\"]*)"$/ do |expected_text|
|
26
|
-
@page.text_area_id.should == expected_text
|
27
|
-
end
|
28
|
-
|
29
|
-
When /^I search for the text area by "([^\"]*)"$/ do |how|
|
30
|
-
@how = how
|
31
|
-
end
|
32
|
-
|
33
|
-
When /^I search for the text area by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
34
|
-
@how = "#{param1}_#{param2}"
|
35
|
-
end
|
36
|
-
|
37
|
-
Then /^I should be able to type "([^\"]*)" into the area$/ do |value|
|
38
|
-
@page.send "text_area_#{@how}=".to_sym, value
|
39
|
-
end
|
40
|
-
|
41
|
-
When /^I select the link labeled "([^\"]*)"$/ do |text|
|
42
|
-
@page.google_search_id
|
43
|
-
end
|
44
|
-
|
45
|
-
When /^I search for the link by "([^\"]*)"$/ do |how|
|
46
|
-
@how = how
|
47
|
-
end
|
48
|
-
|
49
|
-
Then /^I should be able to select the link$/ do
|
50
|
-
@page.send "google_search_#{@how}".to_sym
|
51
|
-
end
|
52
|
-
|
53
|
-
When /^I select "([^\"]*)" from the select list$/ do |text|
|
54
|
-
@page.sel_list_id = text
|
55
|
-
end
|
56
|
-
|
57
1
|
Then /^the current item should be "([^\"]*)"$/ do |expected_text|
|
58
2
|
@page.sel_list_id.should == expected_text
|
59
3
|
end
|
60
4
|
|
61
|
-
When /^I search for the select list by "([^\"]*)"$/ do |how|
|
62
|
-
@how = how
|
63
|
-
end
|
64
|
-
|
65
|
-
When /^I search for the select list by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
66
|
-
@how = "#{param1}_#{param2}"
|
67
|
-
end
|
68
|
-
|
69
|
-
Then /^I should be able to select "([^\"]*)"$/ do |value|
|
70
|
-
@page.send "sel_list_#{@how}=".to_sym, value
|
71
|
-
end
|
72
|
-
|
73
|
-
Then /^the value for the selected item should be "([^\"]*)"$/ do |value|
|
74
|
-
result = @page.send "sel_list_#{@how}".to_sym
|
75
|
-
result.should == value
|
76
|
-
end
|
77
|
-
|
78
|
-
When /^I select the First check box$/ do
|
79
|
-
@page.check_cb_id
|
80
|
-
end
|
81
|
-
|
82
|
-
Then /^the First check box should be selected$/ do
|
83
|
-
@page.cb_id_checked?.should be_true
|
84
|
-
end
|
85
|
-
|
86
|
-
When /^I unselect the First check box$/ do
|
87
|
-
@page.uncheck_cb_id
|
88
|
-
end
|
89
|
-
|
90
|
-
Then /^the First check box should not be selected$/ do
|
91
|
-
@page.cb_id_checked?.should be_false
|
92
|
-
end
|
93
|
-
|
94
|
-
When /^I search for the check box by "([^\"]*)"$/ do |how|
|
95
|
-
@how = how
|
96
|
-
end
|
97
|
-
|
98
|
-
When /^I search for the check box by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
99
|
-
@how = "#{param1}_#{param2}"
|
100
|
-
end
|
101
|
-
|
102
|
-
Then /^I should be able to check the check box$/ do
|
103
|
-
@page.send "check_cb_#{@how}".to_sym
|
104
|
-
end
|
105
|
-
|
106
|
-
When /^I select the "([^\"]*)" radio button$/ do |how|
|
107
|
-
@page.send "select_#{how.downcase}_id".to_sym
|
108
|
-
end
|
109
|
-
|
110
|
-
Then /^the "([^\"]*)" radio button should be selected$/ do |how|
|
111
|
-
@page.send "#{how.downcase}_id_selected?".to_sym
|
112
|
-
end
|
113
|
-
|
114
|
-
When /^I search for the radio button by "([^\"]*)"$/ do |how|
|
115
|
-
@how = how
|
116
|
-
end
|
117
|
-
|
118
|
-
When /^I search for the radio button by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
119
|
-
@how = "#{param1}_#{param2}"
|
120
|
-
end
|
121
|
-
|
122
|
-
When /^I select the radio button$/ do
|
123
|
-
@page.send "select_milk_#{@how}".to_sym
|
124
|
-
end
|
125
|
-
|
126
|
-
When /^I get the text from the div$/ do
|
127
|
-
@text = @page.div_id
|
128
|
-
end
|
129
|
-
|
130
5
|
Then /^the text should be "([^\"]*)"$/ do |expected_text|
|
131
6
|
@text.should == expected_text
|
132
7
|
end
|
133
8
|
|
134
|
-
When /^I search for the div by "([^\"]*)"$/ do |how|
|
135
|
-
@text = @page.send "div_#{how}".to_sym
|
136
|
-
end
|
137
|
-
|
138
|
-
When /^I search for the div by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
139
|
-
@text = @page.send "div_#{param1}_#{param2}".to_sym
|
140
|
-
end
|
141
|
-
|
142
|
-
When /^I get the text from the span$/ do
|
143
|
-
@text = @page.span_id
|
144
|
-
end
|
145
|
-
|
146
|
-
When /^I search for the span by "([^\"]*)"$/ do |how|
|
147
|
-
@text = @page.send "span_#{how}".to_sym
|
148
|
-
end
|
149
|
-
|
150
|
-
When /^I search for the span by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
151
|
-
@text = @page.send "span_#{param1}_#{param2}".to_sym
|
152
|
-
end
|
153
|
-
|
154
|
-
When /^I click the button$/ do
|
155
|
-
@page.button_id
|
156
|
-
end
|
157
|
-
|
158
9
|
Then /^I should be on the success page$/ do
|
159
10
|
@page.text.should include 'Success'
|
160
11
|
@page.title.should == 'Success'
|
161
12
|
end
|
162
13
|
|
163
|
-
When /^I search for the button by "([^\"]*)"$/ do |how|
|
164
|
-
@how = how
|
165
|
-
end
|
166
|
-
|
167
|
-
When /^I search for the button by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
168
|
-
@how = "#{param1}_#{param2}"
|
169
|
-
end
|
170
|
-
|
171
|
-
Then /^I should be able to click the button$/ do
|
172
|
-
@page.send "button_#{@how}"
|
173
|
-
end
|
174
|
-
|
175
|
-
When /^I search for the table cell by "([^\"]*)"$/ do |how|
|
176
|
-
@cell_data = @page.send "cell_#{how}"
|
177
|
-
end
|
178
|
-
|
179
|
-
When /^I retrieve a table cell element by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
180
|
-
@cell_data = @page.send "cell_#{param1}_#{param2}"
|
181
|
-
end
|
182
|
-
|
183
|
-
When /^I retrieve a table element by "([^\"]*)"$/ do |how|
|
184
|
-
@element = @page.send "table_#{how}_element"
|
185
|
-
end
|
186
|
-
|
187
|
-
When /^I retrieve a table element by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
188
|
-
@element = @page.send "table_#{param1}_#{param2}_element"
|
189
|
-
end
|
190
|
-
|
191
|
-
When /^I get the image element$/ do
|
192
|
-
@element = @page.image_id_image
|
193
|
-
end
|
194
|
-
|
195
|
-
Then /^the image should be "([^\"]*)" pixels wide$/ do |width|
|
196
|
-
@element.width.should == width.to_i
|
197
|
-
end
|
198
|
-
|
199
|
-
Then /^the image should be "([^\"]*)" pixels tall$/ do |height|
|
200
|
-
@element.height.should == height.to_i
|
201
|
-
end
|
202
|
-
|
203
|
-
When /^I get the image element by "([^\"]*)"$/ do |how|
|
204
|
-
@element = @page.send "image_#{how}_element"
|
205
|
-
end
|
206
|
-
|
207
|
-
When /^I get the image element by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
208
|
-
@element = @page.send "image_#{param1}_#{param2}_element"
|
209
|
-
end
|
210
|
-
|
211
|
-
When /^I retrieve the hidden field element$/ do
|
212
|
-
@element = @page.hidden_field_id_element
|
213
|
-
end
|
214
|
-
|
215
|
-
Then /^I should see the hidden field contains "([^\"]*)"$/ do |text|
|
216
|
-
@page.hidden_field_id.should == text
|
217
|
-
end
|
218
|
-
|
219
|
-
When /^I search for the hidden field by "([^\"]*)"$/ do |how|
|
220
|
-
@element = @page.send "hidden_field_#{how}_element"
|
221
|
-
end
|
222
|
-
|
223
|
-
Then /^hidden field element should contains "([^\"]*)"$/ do |text|
|
224
|
-
@element.value.should == text
|
225
|
-
end
|
226
|
-
|
227
|
-
When /^I search for the hidden field by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
228
|
-
@element = @page.send "hidden_field_#{param1}_#{param2}_element"
|
229
|
-
end
|
230
|
-
|
231
|
-
Then /^I should be able to submit the form$/ do
|
232
|
-
@element.submit
|
233
|
-
end
|
234
|
-
|
235
|
-
When /^I locate the form by "([^\"]*)"$/ do |how|
|
236
|
-
@element = @page.send "form_#{how}_element"
|
237
|
-
end
|
238
|
-
|
239
|
-
When /^I locate the form using "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
240
|
-
@element = @page.send "form_#{param1}_#{param2}_element"
|
241
|
-
end
|
242
|
-
|
243
|
-
When /^I get the text from the list item$/ do
|
244
|
-
@text = @page.li_id
|
245
|
-
end
|
246
|
-
|
247
|
-
When /^I search for the list item by "([^\"]*)"$/ do |how|
|
248
|
-
@text = @page.send "li_#{how}"
|
249
|
-
end
|
250
|
-
|
251
|
-
When /^I search for the list item by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
252
|
-
@text = @page.send "li_#{param1}_#{param2}"
|
253
|
-
end
|
254
|
-
|
255
|
-
When /^I get the first item from the unordered list$/ do
|
256
|
-
@element = @page.ul_id_element[0]
|
257
|
-
end
|
258
|
-
|
259
14
|
Then /^the list items text should be "([^\"]*)"$/ do |expected_text|
|
260
15
|
@element.text.should == expected_text
|
261
16
|
end
|
262
17
|
|
263
|
-
When /^I search for the unordered list by "([^\"]*)"$/ do |how|
|
264
|
-
@list = @page.send "ul_#{how}_element"
|
265
|
-
end
|
266
|
-
|
267
|
-
When /^I search for the unordered list by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
268
|
-
@list = @page.send "ul_#{param1}_#{param2}_element"
|
269
|
-
end
|
270
|
-
|
271
|
-
|
272
18
|
When /^I get the first item from the list$/ do
|
273
19
|
@element = @list[0]
|
274
20
|
end
|
275
21
|
|
276
|
-
When /^I get the first item from the ordered list$/ do
|
277
|
-
@element = @page.ol_id_element[0]
|
278
|
-
end
|
279
|
-
|
280
|
-
When /^I search for the ordered list by "([^\"]*)"$/ do |how|
|
281
|
-
@list = @page.send "ol_#{how}_element"
|
282
|
-
end
|
283
|
-
|
284
|
-
When /^I search for the ordered list by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
285
|
-
@list = @page.send "ol_#{param1}_#{param2}_element"
|
286
|
-
end
|
287
|
-
|
288
22
|
Then /^the table should have "([^\"]*)" rows$/ do |rows|
|
289
23
|
@element.rows.should == rows.to_i
|
290
24
|
end
|