page-object 0.6.3 → 0.6.4

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.
Files changed (50) hide show
  1. data/ChangeLog +15 -0
  2. data/features/button.feature +1 -0
  3. data/features/element.feature +60 -56
  4. data/features/frames.feature +1 -0
  5. data/features/generic_elements.feature +24 -0
  6. data/features/html/multi_elements.html +4 -0
  7. data/features/html/nested_elements.html +4 -1
  8. data/features/html/static_elements.html +15 -1
  9. data/features/label.feature +44 -0
  10. data/features/link.feature +1 -0
  11. data/features/sample-app/public/prototype.html +1 -0
  12. data/features/step_definitions/element_steps.rb +22 -6
  13. data/features/step_definitions/frames_steps.rb +4 -0
  14. data/features/step_definitions/generic_element_steps.rb +19 -0
  15. data/features/step_definitions/label_steps.rb +19 -0
  16. data/features/support/page.rb +17 -0
  17. data/lib/page-object.rb +7 -0
  18. data/lib/page-object/accessors.rb +73 -1
  19. data/lib/page-object/element_locators.rb +36 -0
  20. data/lib/page-object/elements.rb +2 -1
  21. data/lib/page-object/elements/button.rb +2 -2
  22. data/lib/page-object/elements/element.rb +6 -6
  23. data/lib/page-object/elements/label.rb +19 -0
  24. data/lib/page-object/elements/link.rb +2 -2
  25. data/lib/page-object/elements/text_field.rb +1 -1
  26. data/lib/page-object/nested_elements.rb +8 -0
  27. data/lib/page-object/page_factory.rb +6 -0
  28. data/lib/page-object/platforms/selenium_webdriver/element.rb +17 -17
  29. data/lib/page-object/platforms/selenium_webdriver/form.rb +2 -2
  30. data/lib/page-object/platforms/selenium_webdriver/image.rb +2 -2
  31. data/lib/page-object/platforms/selenium_webdriver/page_object.rb +54 -1
  32. data/lib/page-object/platforms/selenium_webdriver/select_list.rb +2 -2
  33. data/lib/page-object/platforms/selenium_webdriver/table.rb +2 -2
  34. data/lib/page-object/platforms/watir_webdriver/element.rb +14 -14
  35. data/lib/page-object/platforms/watir_webdriver/form.rb +2 -2
  36. data/lib/page-object/platforms/watir_webdriver/image.rb +2 -2
  37. data/lib/page-object/platforms/watir_webdriver/page_object.rb +72 -9
  38. data/lib/page-object/platforms/watir_webdriver/select_list.rb +5 -5
  39. data/lib/page-object/platforms/watir_webdriver/table.rb +2 -2
  40. data/lib/page-object/version.rb +1 -1
  41. data/page-object.gemspec +1 -1
  42. data/spec/page-object/accessors_spec.rb +15 -3
  43. data/spec/page-object/element_locators_spec.rb +24 -0
  44. data/spec/page-object/elements/button_spec.rb +2 -2
  45. data/spec/page-object/elements/label_spec.rb +29 -0
  46. data/spec/page-object/elements/link_spec.rb +2 -2
  47. data/spec/page-object/page-object_spec.rb +7 -1
  48. data/spec/page-object/page_factory_spec.rb +26 -0
  49. data/spec/page-object/platforms/watir_webdriver_spec.rb +1 -0
  50. metadata +26 -15
data/ChangeLog CHANGED
@@ -1,3 +1,18 @@
1
+ === Version 0.6.4 / 2012-3-27
2
+ * Enhancements
3
+ * Added support for finding the following elements by :css
4
+ Button
5
+ Link
6
+ * Added support for the label element (Thanks Paul Clewell)
7
+ * Added method to fetch generic element (Thanks Jim Holmes)
8
+ * Added direct_url alias for page_url
9
+ * Added visit alias for visit_page
10
+ * Added on alias for on_page
11
+ * Added element_with_focus method to return the element that has focus
12
+ * Changed Elements.element_class_for so parameters can be strings or symbols
13
+ * Changed page_url to accept a symbol that will cause it to call a corresponding method
14
+ * Updated to use watir-webdriver 0.5.4
15
+
1
16
  === Version 0.6.3 / 2012-3-1
2
17
  * Enhancements
3
18
  * Added #expected_title method to PageObject
@@ -39,6 +39,7 @@ Feature: Button
39
39
  | xpath |
40
40
  | index |
41
41
  | value |
42
+ | css |
42
43
 
43
44
  Scenario Outline: Locating real buttons on the page
44
45
  When I search for the button by "<search_by>"
@@ -16,46 +16,50 @@ Feature: Elements
16
16
  When I check a disabled button
17
17
  Then it should know it is not enabled
18
18
  And it should know that it is disabled
19
+
20
+ Scenario: Setting focus and finding the element with focus
21
+ When I set the focus to the test text_field
22
+ Then I should know that the text_field has the focus
19
23
 
20
24
  Scenario: Link element methods
21
25
  When I retrieve a link element
22
26
  Then I should know it exists
23
27
  And I should know it is visible
24
- And I should know its' text is "Google Search"
28
+ And I should know the text is "Google Search"
25
29
  And I should know it is equal to itself
26
- And I should know its' tag name is "a"
30
+ And I should know the tag name is "a"
27
31
  And I should know the attribute "readonly" is false
28
32
  And I should be able to click it
29
33
 
30
34
  @watir_only
31
35
  Scenario: Link element methods for watir
32
36
  When I retrieve a link element
33
- Then I should know its' value is ""
37
+ Then I should know the value is ""
34
38
 
35
39
 
36
40
  Scenario: Button element methods
37
41
  When I retrieve a button element
38
42
  Then I should know it exists
39
43
  And I should know it is visible
40
- And I should know its' value is "Click Me"
44
+ And I should know the value is "Click Me"
41
45
  And I should know it is equal to itself
42
- And I should know its' tag name is "input"
46
+ And I should know the tag name is "input"
43
47
  And I should know the attribute "readonly" is false
44
48
  And I should be able to click it
45
49
 
46
50
  @watir_only
47
51
  Scenario: Button element methods for watir
48
52
  When I retrieve a button element
49
- Then I should know its' text is "Click Me"
53
+ Then I should know the text is "Click Me"
50
54
 
51
55
  Scenario: Check Box element methods
52
56
  When I retrieve a check box element
53
57
  Then I should know it exists
54
58
  And I should know it is visible
55
- And I should know its' text is ""
56
- And I should know its' value is "1"
59
+ And I should know the text is ""
60
+ And I should know the value is "1"
57
61
  And I should know it is equal to itself
58
- And I should know its' tag name is "input"
62
+ And I should know the tag name is "input"
59
63
  And I should know the attribute "readonly" is false
60
64
  And I should be able to click it
61
65
 
@@ -63,30 +67,30 @@ Feature: Elements
63
67
  When I retrieve the div element
64
68
  Then I should know it exists
65
69
  And I should know it is visible
66
- And I should know its' text is "page-object rocks!"
70
+ And I should know the text is "page-object rocks!"
67
71
  And I should know it is equal to itself
68
- And I should know its' tag name is "div"
72
+ And I should know the tag name is "div"
69
73
  And I should know the attribute "readonly" is false
70
74
  And I should be able to click it
71
75
 
72
76
  @watir_only
73
77
  Scenario: Div element methods for watir
74
78
  When I retrieve the div element
75
- Then I should know its' value is ""
79
+ Then I should know the value is ""
76
80
 
77
81
  @selenium_only
78
82
  Scenario: Div element methods for selenium
79
83
  When I retrieve the div element
80
- Then I should know its' value is nil
84
+ Then I should know the value is nil
81
85
 
82
86
  Scenario: Radio Button element methods
83
87
  When I retrieve a radio button
84
88
  Then I should know it exists
85
89
  And I should know it is visible
86
- And I should know its' text is ""
87
- And I should know its' value is "Milk"
90
+ And I should know the text is ""
91
+ And I should know the value is "Milk"
88
92
  And I should know it is equal to itself
89
- And I should know its' tag name is "input"
93
+ And I should know the tag name is "input"
90
94
  And I should know the attribute "readonly" is false
91
95
  And I should be able to click it
92
96
 
@@ -94,19 +98,19 @@ Feature: Elements
94
98
  When I retrieve a select list
95
99
  Then I should know it exists
96
100
  And I should know it is visible
97
- And I should know its' text includes "Test 1"
98
- And I should know its' value is "option1"
101
+ And I should know the text includes "Test 1"
102
+ And I should know the value is "option1"
99
103
  And I should know it is equal to itself
100
- And I should know its' tag name is "select"
104
+ And I should know the tag name is "select"
101
105
  And I should know the attribute "readonly" is false
102
106
  And I should be able to click it
103
107
 
104
108
  Scenario: Table element methods
105
109
  When I retrieve a table element
106
110
  Then I should know it is visible
107
- And I should know its' text includes "Data1"
111
+ And I should know the text includes "Data1"
108
112
  And I should know it is equal to itself
109
- And I should know its' tag name is "table"
113
+ And I should know the tag name is "table"
110
114
  And I should know the attribute "readonly" is false
111
115
  And I should be able to click it
112
116
 
@@ -114,41 +118,41 @@ Feature: Elements
114
118
  Scenario: Table element methods in watir
115
119
  When I retrieve a table element
116
120
  Then I should know it exists
117
- And I should know its' value is ""
121
+ And I should know the value is ""
118
122
 
119
123
  @selenium_only
120
124
  Scenario: Table element methods in selenium
121
125
  When I retrieve a table element
122
- Then I should know its' value is nil
126
+ Then I should know the value is nil
123
127
 
124
128
  Scenario: Table Cell element methods
125
129
  When I retrieve table cell
126
130
  Then I should know it exists
127
131
  And I should know it is visible
128
- And I should know its' text includes "Data4"
132
+ And I should know the text includes "Data4"
129
133
  And I should know it is equal to itself
130
- And I should know its' tag name is "td"
134
+ And I should know the tag name is "td"
131
135
  And I should know the attribute "readonly" is false
132
136
  And I should be able to click it
133
137
 
134
138
  @watir_only
135
139
  Scenario: Table Cell element methods in watir
136
140
  When I retrieve table cell
137
- Then I should know its' value is ""
141
+ Then I should know the value is ""
138
142
 
139
143
  @selenium_only
140
144
  Scenario: Table Cell element methods in selenium
141
145
  When I retrieve table cell
142
- Then I should know its' value is nil
146
+ Then I should know the value is nil
143
147
 
144
148
  Scenario: Text Field element methods
145
149
  When I retrieve a text field
146
150
  Then I should know it exists
147
151
  And I should know it is visible
148
- And I should know its' text includes ""
149
- And I should know its' value is ""
152
+ And I should know the text includes ""
153
+ And I should know the value is ""
150
154
  And I should know it is equal to itself
151
- And I should know its' tag name is "input"
155
+ And I should know the tag name is "input"
152
156
  And I should know the attribute "readonly" is false
153
157
  And I should be able to click it
154
158
 
@@ -156,10 +160,10 @@ Feature: Elements
156
160
  When I retrieve the text area
157
161
  Then I should know it exists
158
162
  And I should know it is visible
159
- And I should know its' text includes ""
160
- And I should know its' value is ""
163
+ And I should know the text includes ""
164
+ And I should know the value is ""
161
165
  And I should know it is equal to itself
162
- And I should know its' tag name is "textarea"
166
+ And I should know the tag name is "textarea"
163
167
  And I should know the attribute "readonly" is false
164
168
  And I should be able to click it
165
169
 
@@ -167,58 +171,58 @@ Feature: Elements
167
171
  When I get the image element
168
172
  Then I should know it exists
169
173
  And I should know it is visible
170
- And I should know its' text includes ""
174
+ And I should know the text includes ""
171
175
  And I should know it is equal to itself
172
- And I should know its' tag name is "img"
176
+ And I should know the tag name is "img"
173
177
  And I should know the attribute "readonly" is false
174
178
  And I should be able to click it
175
179
 
176
180
  @watir_only
177
181
  Scenario: Image element methods in watir
178
182
  When I get the image element
179
- Then I should know its' value is ""
183
+ Then I should know the value is ""
180
184
 
181
185
  @selenium_only
182
186
  Scenario: Image element methods in selenium
183
187
  When I get the image element
184
- Then I should know its' value is nil
188
+ Then I should know the value is nil
185
189
 
186
190
  Scenario: Hidden Field element methods
187
191
  When I retrieve the hidden field element
188
192
  Then I should know it exists
189
193
  And I should know it is not visible
190
- And I should know its' text includes ""
191
- And I should know its' value is "12345"
194
+ And I should know the text includes ""
195
+ And I should know the value is "12345"
192
196
  And I should know it is equal to itself
193
- And I should know its' tag name is "input"
197
+ And I should know the tag name is "input"
194
198
  And I should know the attribute "readonly" is false
195
199
 
196
200
  Scenario: Form element methods
197
201
  When I locate the form
198
202
  Then I should know it exists
199
203
  And I should know it is visible
200
- And I should know its' text includes ""
204
+ And I should know the text includes ""
201
205
  And I should know it is equal to itself
202
- And I should know its' tag name is "form"
206
+ And I should know the tag name is "form"
203
207
  And I should know the attribute "readonly" is false
204
208
 
205
209
  @watir_only
206
210
  Scenario: Form element methods in watir
207
211
  When I locate the form
208
- Then I should know its' value is ""
212
+ Then I should know the value is ""
209
213
 
210
214
  @selenium_only
211
215
  Scenario: Form element methods in selenium
212
216
  When I locate the form
213
- Then I should know its' value is nil
217
+ Then I should know the value is nil
214
218
 
215
219
  Scenario: List item element methods
216
220
  When I retrieve a list item element
217
221
  Then I should know it exists
218
222
  And I should know it is visible
219
- And I should know its' text is "Item One"
223
+ And I should know the text is "Item One"
220
224
  And I should know it is equal to itself
221
- And I should know its' tag name is "li"
225
+ And I should know the tag name is "li"
222
226
  And I should know the attribute "readonly" is false
223
227
  And I should be able to click it
224
228
 
@@ -226,11 +230,11 @@ Feature: Elements
226
230
  When I retrieve an unordered list element
227
231
  Then I should know it exists
228
232
  And I should know it is visible
229
- And I should know its' text includes "Item One"
230
- And I should know its' text includes "Item Two"
231
- And I should know its' text includes "Item Three"
233
+ And I should know the text includes "Item One"
234
+ And I should know the text includes "Item Two"
235
+ And I should know the text includes "Item Three"
232
236
  And I should know it is equal to itself
233
- And I should know its' tag name is "ul"
237
+ And I should know the tag name is "ul"
234
238
  And I should know the attribute "readonly" is false
235
239
  And I should be able to click it
236
240
 
@@ -238,11 +242,11 @@ Feature: Elements
238
242
  When I retrieve an ordered list element
239
243
  Then I should know it exists
240
244
  And I should know it is visible
241
- And I should know its' text includes "Number One"
242
- And I should know its' text includes "Number Two"
243
- And I should know its' text includes "Number Three"
245
+ And I should know the text includes "Number One"
246
+ And I should know the text includes "Number Two"
247
+ And I should know the text includes "Number Three"
244
248
  And I should know it is equal to itself
245
- And I should know its' tag name is "ol"
249
+ And I should know the tag name is "ol"
246
250
  And I should know the attribute "readonly" is false
247
251
  And I should be able to click it
248
252
 
@@ -250,9 +254,9 @@ Feature: Elements
250
254
  When I retrieve a heading element
251
255
  Then I should know it exists
252
256
  And I should know it is visible
253
- And I should know its' text is "h1's are cool"
257
+ And I should know the text is "h1's are cool"
254
258
  And I should know it is equal to itself
255
- And I should know its' tag name is "h1"
259
+ And I should know the tag name is "h1"
256
260
  And I should know the attribute "readonly" is false
257
261
  And I should be able to click it
258
262
 
@@ -8,6 +8,7 @@ Feature: Handling frames
8
8
  Then I should verify "page-object" is in the text field for frame 2 using "name"
9
9
  When I type "page-object" into the text field for frame 2 using "index"
10
10
  Then I should verify "page-object" is in the text field for frame 2 using "index"
11
+ #And I should be able to get the text fields text from frame 2 using "index"
11
12
 
12
13
  Scenario: Switching between frames
13
14
  Given I am on the frame elements page
@@ -0,0 +1,24 @@
1
+ Feature: Generic Elements
2
+
3
+ Background:
4
+ Given I am on the static elements page
5
+
6
+ Scenario: Getting the text from the article element
7
+ When I get the text from the article
8
+ Then the text should be "HTML 5 Article"
9
+
10
+ Scenario: Getting the text from the header element
11
+ When I get the text from the header
12
+ Then the text should be "HTML 5 Header"
13
+
14
+ Scenario: Getting the text from the footer element
15
+ When I get the text from the footer
16
+ Then the text should be "HTML 5 Footer"
17
+
18
+ Scenario: Getting the text from the summary element
19
+ When I get the text from the summary
20
+ Then the text should be "The summary"
21
+
22
+ Scenario: Getting the text from the details element
23
+ When I get the text from the details
24
+ Then the text should be "The summary The details"
@@ -50,6 +50,10 @@
50
50
  <span class="span">Span 2</span>
51
51
  <span class="span">Span 3</span>
52
52
 
53
+ <label class="label">Label 1</label>
54
+ <label class="label">Label 2</label>
55
+ <label class="label">Label 3</label>
56
+
53
57
  <table class="table" border='1'>
54
58
  <tr>
55
59
  <td class="td">Data 1</td>
@@ -26,6 +26,9 @@
26
26
  <span>
27
27
  My alert
28
28
  </span>
29
+ <label>
30
+ page-object is the best!
31
+ </label>
29
32
  <table>
30
33
  <tr><td>Data1</td><td>Data2</td></tr>
31
34
  </table>
@@ -46,7 +49,7 @@
46
49
  <ul>
47
50
  <li>Item One</li>
48
51
  <li>Item Two</li>
49
- </ul
52
+ </ul>
50
53
 
51
54
  </div>
52
55
 
@@ -13,7 +13,7 @@
13
13
 
14
14
  <textarea rows="2" cols="20" id="text_area_id" class="text_area_class" name="text_area_name"></textarea>
15
15
 
16
- <select name="sel_list_name" id="sel_list_id", class="sel_list_class">
16
+ <select name="sel_list_name" id="sel_list_id" class="sel_list_class">
17
17
  <option value="option1">Test 1</option>
18
18
  <option value="option2">Test 2</option>
19
19
  </select>
@@ -33,6 +33,10 @@
33
33
  <span id="span_id" name="span_name" class="span_class">
34
34
  My alert
35
35
  </span>
36
+
37
+ <label id="label_id" name="label_name" class="label_class">
38
+ page-object is the best!
39
+ </label>
36
40
 
37
41
  <table id='table_id' name='table_name' class='table_class' border='1'>
38
42
  <tr>
@@ -94,6 +98,16 @@
94
98
  <div id="parent_div">
95
99
  <a href="success.html" id="child">Success</a>
96
100
  </div>
101
+
102
+ <article id='article_id'>HTML 5 Article</article>
103
+ <header id='header_id'>HTML 5 Header</header>
104
+ <footer id='footer_id'>HTML 5 Footer</footer>
105
+
106
+ <details id='details_id'>
107
+ <summary id='summary_id'>The summary</summary>
108
+ The details
109
+ </details>
110
+
97
111
  </body>
98
112
  </html>
99
113
 
@@ -0,0 +1,44 @@
1
+ Feature: Handling labels with page object
2
+
3
+ In order to interact with labels,
4
+ Testers will need to access the element
5
+ and the ability to interrogate
6
+
7
+ Background:
8
+ Given I am on the static elements page
9
+
10
+ Scenario: Getting the text from a label
11
+ When I get the text from the label
12
+ Then the text should be "page-object is the best!"
13
+
14
+ Scenario: Getting the label element
15
+ When I retrieve the label element
16
+ Then I should know it exists
17
+ And I should know it is visible
18
+
19
+ Scenario Outline: Locating labels on the page
20
+ When I search for the label by "<search_by>"
21
+ Then the text should be "page-object is the best!"
22
+
23
+ Scenarios:
24
+ | search_by |
25
+ | id |
26
+ | class |
27
+ | xpath |
28
+ | index |
29
+ | name |
30
+ | text |
31
+
32
+ Scenario Outline: Locating labels using multiple parameters
33
+ When I search for the label by "<param1>" and "<param2>"
34
+ Then the text should be "page-object is the best!"
35
+
36
+ Scenarios:
37
+ | param1 | param2 |
38
+ | class | index |
39
+ | name | index |
40
+
41
+ Scenario: Finding a label dynamically
42
+ When I get the text from a label while the script is executing
43
+ Then I should see that the label exists
44
+ And the text should be "page-object is the best!"