page-object 0.2.5 → 0.3.0

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 (90) hide show
  1. data/ChangeLog +25 -0
  2. data/Rakefile +3 -3
  3. data/features/element.feature +232 -1
  4. data/features/frames.feature +1 -1
  5. data/features/html/modal.html +17 -0
  6. data/features/html/modal_1.html +38 -0
  7. data/features/html/modal_2.html +27 -0
  8. data/features/html/nested_elements.html +42 -0
  9. data/features/html/static_elements.html +1 -0
  10. data/features/modal_dialog.feature +15 -0
  11. data/features/nested_elements.feature +73 -0
  12. data/features/step_definitions/frames_steps.rb +1 -1
  13. data/features/step_definitions/modal_dialog_steps.rb +62 -0
  14. data/features/step_definitions/nested_elements_steps.rb +165 -0
  15. data/features/support/page.rb +1 -0
  16. data/features/support/url_helper.rb +8 -0
  17. data/lib/page-object.rb +26 -0
  18. data/lib/page-object/accessors.rb +36 -36
  19. data/lib/page-object/elements/button.rb +3 -3
  20. data/lib/page-object/elements/check_box.rb +7 -7
  21. data/lib/page-object/elements/element.rb +16 -10
  22. data/lib/page-object/elements/form.rb +7 -7
  23. data/lib/page-object/elements/image.rb +7 -7
  24. data/lib/page-object/elements/link.rb +3 -3
  25. data/lib/page-object/elements/ordered_list.rb +7 -7
  26. data/lib/page-object/elements/radio_button.rb +7 -7
  27. data/lib/page-object/elements/select_list.rb +7 -7
  28. data/lib/page-object/elements/table.rb +7 -7
  29. data/lib/page-object/elements/table_row.rb +7 -7
  30. data/lib/page-object/elements/text_area.rb +7 -7
  31. data/lib/page-object/elements/text_field.rb +7 -7
  32. data/lib/page-object/elements/unordered_list.rb +7 -7
  33. data/lib/page-object/nested_elements.rb +72 -0
  34. data/lib/page-object/platforms.rb +2 -2
  35. data/lib/page-object/platforms/selenium_webdriver.rb +17 -0
  36. data/lib/page-object/platforms/{selenium → selenium_webdriver}/button.rb +1 -1
  37. data/lib/page-object/platforms/{selenium → selenium_webdriver}/check_box.rb +1 -1
  38. data/lib/page-object/platforms/{selenium → selenium_webdriver}/element.rb +1 -1
  39. data/lib/page-object/platforms/{watir → selenium_webdriver}/form.rb +1 -1
  40. data/lib/page-object/platforms/{selenium → selenium_webdriver}/image.rb +1 -1
  41. data/lib/page-object/platforms/{selenium → selenium_webdriver}/link.rb +1 -1
  42. data/lib/page-object/platforms/{selenium → selenium_webdriver}/ordered_list.rb +2 -2
  43. data/lib/page-object/platforms/{selenium → selenium_webdriver}/page_object.rb +59 -59
  44. data/lib/page-object/platforms/{selenium → selenium_webdriver}/radio_button.rb +1 -1
  45. data/lib/page-object/platforms/{selenium → selenium_webdriver}/select_list.rb +2 -2
  46. data/lib/page-object/platforms/{selenium → selenium_webdriver}/table.rb +2 -2
  47. data/lib/page-object/platforms/{selenium → selenium_webdriver}/table_row.rb +2 -2
  48. data/lib/page-object/platforms/{selenium → selenium_webdriver}/text_area.rb +1 -1
  49. data/lib/page-object/platforms/{selenium → selenium_webdriver}/text_field.rb +1 -1
  50. data/lib/page-object/platforms/{selenium → selenium_webdriver}/unordered_list.rb +2 -2
  51. data/lib/page-object/platforms/watir_webdriver.rb +17 -0
  52. data/lib/page-object/platforms/{watir → watir_webdriver}/check_box.rb +1 -1
  53. data/lib/page-object/platforms/{watir → watir_webdriver}/element.rb +1 -1
  54. data/lib/page-object/platforms/{selenium → watir_webdriver}/form.rb +1 -1
  55. data/lib/page-object/platforms/{watir → watir_webdriver}/image.rb +1 -1
  56. data/lib/page-object/platforms/{watir → watir_webdriver}/ordered_list.rb +2 -2
  57. data/lib/page-object/platforms/watir_webdriver/page_object.rb +486 -0
  58. data/lib/page-object/platforms/{watir → watir_webdriver}/radio_button.rb +1 -1
  59. data/lib/page-object/platforms/{watir → watir_webdriver}/select_list.rb +3 -3
  60. data/lib/page-object/platforms/{watir → watir_webdriver}/table.rb +2 -2
  61. data/lib/page-object/platforms/{watir → watir_webdriver}/table_row.rb +2 -2
  62. data/lib/page-object/platforms/{watir → watir_webdriver}/text_area.rb +1 -1
  63. data/lib/page-object/platforms/{watir → watir_webdriver}/text_field.rb +1 -1
  64. data/lib/page-object/platforms/{watir → watir_webdriver}/unordered_list.rb +2 -2
  65. data/lib/page-object/version.rb +1 -1
  66. data/page-object.gemspec +1 -1
  67. data/spec/page-object/elements/button_spec.rb +1 -1
  68. data/spec/page-object/elements/check_box_spec.rb +1 -1
  69. data/spec/page-object/elements/element_spec.rb +9 -5
  70. data/spec/page-object/elements/form_spec.rb +2 -2
  71. data/spec/page-object/elements/image_spec.rb +4 -4
  72. data/spec/page-object/elements/link_spec.rb +1 -1
  73. data/spec/page-object/elements/nested_element_spec.rb +185 -0
  74. data/spec/page-object/elements/ordered_list_spec.rb +6 -6
  75. data/spec/page-object/elements/radio_button_spec.rb +1 -1
  76. data/spec/page-object/elements/select_list_spec.rb +5 -5
  77. data/spec/page-object/elements/table_row_spec.rb +6 -6
  78. data/spec/page-object/elements/table_spec.rb +2 -2
  79. data/spec/page-object/elements/text_area_spec.rb +1 -1
  80. data/spec/page-object/elements/text_field_spec.rb +1 -1
  81. data/spec/page-object/elements/unordered_list_spec.rb +6 -6
  82. data/spec/page-object/page-object_spec.rb +12 -2
  83. data/spec/page-object/platforms/{selenium → selenium_webdriver}/selenium_page_object_spec.rb +2 -2
  84. data/spec/page-object/platforms/selenium_webdriver_spec.rb +29 -0
  85. data/spec/page-object/platforms/{watir_spec.rb → watir_webdriver_spec.rb} +11 -6
  86. metadata +58 -39
  87. data/lib/page-object/platforms/selenium.rb +0 -16
  88. data/lib/page-object/platforms/watir.rb +0 -16
  89. data/lib/page-object/platforms/watir/page_object.rb +0 -482
  90. data/spec/page-object/platforms/selenium_spec.rb +0 -26
data/ChangeLog CHANGED
@@ -1,3 +1,28 @@
1
+ === Version 0.3.0 / 2011-09-04
2
+ * Enhancements
3
+ * Changed namespace for selenium and watir to include webdriver
4
+ * Support for locating the following elements when nested
5
+ * Link
6
+ * Button
7
+ * TextField
8
+ * HiddenField
9
+ * TextArea
10
+ * SelectList
11
+ * Checkbox
12
+ * RadioButton
13
+ * Div
14
+ * Span
15
+ * Table
16
+ * TableCell
17
+ * Image
18
+ * Form
19
+ * OrderedList
20
+ * UnorderedList
21
+ * ListItem
22
+ * Added #modal_dialog to PageObject to override the default modal dialog behavior
23
+ * Changed element keys to include _webdriver
24
+ * Updated to use selenium-webdriver 2.5.0
25
+
1
26
  === Version 0.2.5 / 2011-08-19
2
27
  * Enhancements
3
28
  * #attach_to_window takes an optional block - will return to calling window after block executes
data/Rakefile CHANGED
@@ -13,16 +13,16 @@ end
13
13
  task :spec
14
14
 
15
15
  namespace :features do
16
- Cucumber::Rake::Task.new(:watir, "Run features with Watir") do |t|
16
+ Cucumber::Rake::Task.new(:watir_webdriver, "Run features with Watir") do |t|
17
17
  t.profile = "watir"
18
18
  end
19
19
 
20
- Cucumber::Rake::Task.new(:selenium, "Run features with Selenium") do |t|
20
+ Cucumber::Rake::Task.new(:selenium_webdriver, "Run features with Selenium") do |t|
21
21
  t.profile = "selenium"
22
22
  end
23
23
 
24
24
  desc 'Run all features'
25
- task :all => [:watir, :selenium]
25
+ task :all => [:watir_webdriver, :selenium_webdriver]
26
26
  end
27
27
 
28
28
  desc 'Run all specs and cukes'
@@ -1,8 +1,239 @@
1
1
  Feature: Elements
2
2
 
3
- Scenario: Clear an element
3
+ Background:
4
4
  Given I am on the static elements page
5
+
6
+ Scenario: Clear an element
5
7
  When I type "abcDEF" into the text field
6
8
  Then the text field should contain "abcDEF"
7
9
  When I clear the text field
8
10
  Then the text field should contain ""
11
+
12
+ Scenario: Link element methods
13
+ When I retrieve a link element
14
+ Then I should know it exists
15
+ And I should know it is visible
16
+ And I should know its' text is "Google Search"
17
+ And I should know it is equal to itself
18
+ And I should know its' tag name is "a"
19
+ And I should know the attribute "readonly" is false
20
+ And I should be able to click it
21
+
22
+ @watir_only
23
+ Scenario: Link element methods for watir
24
+ When I retrieve a link element
25
+ Then I should know its' value is ""
26
+
27
+
28
+ Scenario: Button element methods
29
+ When I retrieve a button element
30
+ Then I should know it exists
31
+ And I should know it is visible
32
+ And I should know its' value is "Click Me"
33
+ And I should know it is equal to itself
34
+ And I should know its' tag name is "input"
35
+ And I should know the attribute "readonly" is false
36
+ And I should be able to click it
37
+
38
+ @watir_only
39
+ Scenario: Button element methods for watir
40
+ When I retrieve a button element
41
+ Then I should know its' text is "Click Me"
42
+
43
+ Scenario: Check Box element methods
44
+ When I retrieve a check box element
45
+ Then I should know it exists
46
+ And I should know it is visible
47
+ And I should know its' text is ""
48
+ And I should know its' value is "1"
49
+ And I should know it is equal to itself
50
+ And I should know its' tag name is "input"
51
+ And I should know the attribute "readonly" is false
52
+ And I should be able to click it
53
+
54
+ Scenario: Div element methods
55
+ When I retrieve the div element
56
+ Then I should know it exists
57
+ And I should know it is visible
58
+ And I should know its' text is "page-object rocks!"
59
+ And I should know it is equal to itself
60
+ And I should know its' tag name is "div"
61
+ And I should know the attribute "readonly" is false
62
+ And I should be able to click it
63
+
64
+ @watir_only
65
+ Scenario: Div element methods for watir
66
+ When I retrieve the div element
67
+ Then I should know its' value is ""
68
+
69
+ @selenium_only
70
+ Scenario: Div element methods for selenium
71
+ When I retrieve the div element
72
+ Then I should know its' value is nil
73
+
74
+ Scenario: Radio Button element methods
75
+ When I retrieve a radio button
76
+ Then I should know it exists
77
+ And I should know it is visible
78
+ And I should know its' text is ""
79
+ And I should know its' value is "Milk"
80
+ And I should know it is equal to itself
81
+ And I should know its' tag name is "input"
82
+ And I should know the attribute "readonly" is false
83
+ And I should be able to click it
84
+
85
+ Scenario: Select List element methods
86
+ When I retrieve a select list
87
+ Then I should know it exists
88
+ And I should know it is visible
89
+ And I should know its' text includes "Test 1"
90
+ And I should know its' value is "option1"
91
+ And I should know it is equal to itself
92
+ And I should know its' tag name is "select"
93
+ And I should know the attribute "readonly" is false
94
+ And I should be able to click it
95
+
96
+ Scenario: Table element methods
97
+ When I retrieve a table element
98
+ Then I should know it is visible
99
+ And I should know its' text includes "Data1"
100
+ And I should know it is equal to itself
101
+ And I should know its' tag name is "table"
102
+ And I should know the attribute "readonly" is false
103
+ And I should be able to click it
104
+
105
+ @watir_only
106
+ Scenario: Table element methods in watir
107
+ When I retrieve a table element
108
+ Then I should know it exists
109
+ And I should know its' value is ""
110
+
111
+ @selenium_only
112
+ Scenario: Table element methods in selenium
113
+ When I retrieve a table element
114
+ Then I should know its' value is nil
115
+
116
+ Scenario: Table Cell element methods
117
+ When I retrieve table cell
118
+ Then I should know it exists
119
+ And I should know it is visible
120
+ And I should know its' text includes "Data4"
121
+ And I should know it is equal to itself
122
+ And I should know its' tag name is "td"
123
+ And I should know the attribute "readonly" is false
124
+ And I should be able to click it
125
+
126
+ @watir_only
127
+ Scenario: Table Cell element methods in watir
128
+ When I retrieve table cell
129
+ Then I should know its' value is ""
130
+
131
+ @selenium_only
132
+ Scenario: Table Cell element methods in selenium
133
+ When I retrieve table cell
134
+ Then I should know its' value is nil
135
+
136
+ Scenario: Text Field element methods
137
+ When I retrieve a text field
138
+ Then I should know it exists
139
+ And I should know it is visible
140
+ And I should know its' text includes ""
141
+ And I should know its' value is ""
142
+ And I should know it is equal to itself
143
+ And I should know its' tag name is "input"
144
+ And I should know the attribute "readonly" is false
145
+ And I should be able to click it
146
+
147
+ Scenario: Text Area element methods
148
+ When I retrieve the text area
149
+ Then I should know it exists
150
+ And I should know it is visible
151
+ And I should know its' text includes ""
152
+ And I should know its' value is ""
153
+ And I should know it is equal to itself
154
+ And I should know its' tag name is "textarea"
155
+ And I should know the attribute "readonly" is false
156
+ And I should be able to click it
157
+
158
+ Scenario: Image element methods
159
+ When I get the image element
160
+ Then I should know it exists
161
+ And I should know it is visible
162
+ And I should know its' text includes ""
163
+ And I should know it is equal to itself
164
+ And I should know its' tag name is "img"
165
+ And I should know the attribute "readonly" is false
166
+ And I should be able to click it
167
+
168
+ @watir_only
169
+ Scenario: Image element methods in watir
170
+ When I get the image element
171
+ Then I should know its' value is ""
172
+
173
+ @selenium_only
174
+ Scenario: Image element methods in selenium
175
+ When I get the image element
176
+ Then I should know its' value is nil
177
+
178
+ Scenario: Hidden Field element methods
179
+ When I retrieve the hidden field element
180
+ Then I should know it exists
181
+ And I should know it is not visible
182
+ And I should know its' text includes ""
183
+ And I should know its' value is "12345"
184
+ And I should know it is equal to itself
185
+ And I should know its' tag name is "input"
186
+ And I should know the attribute "readonly" is false
187
+
188
+ Scenario: Form element methods
189
+ When I locate the form
190
+ Then I should know it exists
191
+ And I should know it is visible
192
+ And I should know its' text includes ""
193
+ And I should know it is equal to itself
194
+ And I should know its' tag name is "form"
195
+ And I should know the attribute "readonly" is false
196
+
197
+ @watir_only
198
+ Scenario: Form element methods in watir
199
+ When I locate the form
200
+ Then I should know its' value is ""
201
+
202
+ @selenium_only
203
+ Scenario: Form element methods in selenium
204
+ When I locate the form
205
+ Then I should know its' value is nil
206
+
207
+ Scenario: List item element methods
208
+ When I retrieve a list item element
209
+ Then I should know it exists
210
+ And I should know it is visible
211
+ And I should know its' text is "Item One"
212
+ And I should know it is equal to itself
213
+ And I should know its' tag name is "li"
214
+ And I should know the attribute "readonly" is false
215
+ And I should be able to click it
216
+
217
+ Scenario: Unordered list element methods
218
+ When I retrieve an unordered list element
219
+ Then I should know it exists
220
+ And I should know it is visible
221
+ And I should know its' text includes "Item One"
222
+ And I should know its' text includes "Item Two"
223
+ And I should know its' text includes "Item Three"
224
+ And I should know it is equal to itself
225
+ And I should know its' tag name is "ul"
226
+ And I should know the attribute "readonly" is false
227
+ And I should be able to click it
228
+
229
+ Scenario: Ordered list element methods
230
+ When I retrieve an ordered list element
231
+ Then I should know it exists
232
+ And I should know it is visible
233
+ And I should know its' text includes "Number One"
234
+ And I should know its' text includes "Number Two"
235
+ And I should know its' text includes "Number Three"
236
+ And I should know it is equal to itself
237
+ And I should know its' tag name is "ol"
238
+ And I should know the attribute "readonly" is false
239
+ And I should be able to click it
@@ -34,4 +34,4 @@ Feature: Handling frames
34
34
 
35
35
  Scenario: Nested frames
36
36
  Given I am on the nested frame elements page
37
- Then I should be able to click the nested link
37
+ Then I should be able to click the link in the frame
@@ -0,0 +1,17 @@
1
+ <html>
2
+ <head>
3
+ <title>modal dialog test page</title>
4
+ </head>
5
+ <body>
6
+
7
+ <script type="text/javascript">
8
+ function modal() {
9
+ var retValue = window.showModalDialog(
10
+ "modal_1.html", self,
11
+ "status:no;resizable:Yes;help:no;maximize:no;minimize:no;scrollbars:no;");
12
+ }
13
+ </script>
14
+
15
+ <input id=launch_modal_button type=button onclick='return modal();' value="Launch a modal" />
16
+ </body>
17
+ </html>
@@ -0,0 +1,38 @@
1
+ <html>
2
+
3
+ <head>
4
+ <title>Modal 1</title>
5
+
6
+ <script>
7
+ function delay_action(other_function) {
8
+ setTimeout(other_function, 3000);
9
+ }
10
+
11
+ function close_window() {
12
+ window.returnValue = 22
13
+ window.close()
14
+ }
15
+
16
+ function modal1() {
17
+ var retValue = window.showModalDialog(
18
+ "modal_2.html", self,
19
+ "status:no;resizable:Yes;help:no;maximize:no;minimize:no;scrollbars:no;");
20
+ }
21
+
22
+ </script>
23
+
24
+ </head>
25
+
26
+ <body>
27
+
28
+ <h2>Modal 1</h2>
29
+
30
+ <h3>Close buttons</h3>
31
+ <input id=close_window type=button onclick="close_window()" value="Close window"/>
32
+ <input id=delayed_close type=button onclick="delay_action('close_window()')" value="Close window with delay" />
33
+
34
+ <h3>Nested modal</h3>
35
+ <input id=launch_modal_button type=button onclick='return modal1();' value="Launch another modal"/>
36
+
37
+ </body>
38
+ </html>
@@ -0,0 +1,27 @@
1
+ <html>
2
+
3
+ <head>
4
+ <title>Modal 2</title>
5
+
6
+ <script>
7
+ function delay_action(other_function) {
8
+ setTimeout(other_function, 3000);
9
+ }
10
+
11
+ function close_window() {
12
+ self.close()
13
+ }
14
+ </script>
15
+
16
+ </head>
17
+
18
+ <body>
19
+
20
+ <h2>Modal 2</h2>
21
+
22
+ <h3>Close buttons</h3>
23
+ <input id=close_window2 type="button" onclick="close_window()" value="Close window"/>
24
+ <input id=delayed_close2 type=button onclick="delay_action('close_window()')" value="Close window with delay" />
25
+
26
+ </body>
27
+ </html>
@@ -0,0 +1,42 @@
1
+ <html>
2
+ <head>
3
+ <title>Nested Elements</title>
4
+ </head>
5
+ <body>
6
+ <h1>Nested Elements</h1>
7
+
8
+ <div id="div_id">
9
+ <a href="success.html">Success</a>
10
+ <form method="get" action="success.html">
11
+ <input type="submit" value="Click Me">
12
+ </form>
13
+ <input size="40" type="text"/>
14
+ <input size="40" type="hidden" value="LeanDog"/>
15
+ <textarea rows="2" cols="20"></textarea>
16
+ <select>
17
+ <option value="option1">Test 1</option>
18
+ <option value="option2">Test 2</option>
19
+ </select>
20
+ <input type="checkbox" value="0"/>
21
+ <input type="radio" value="Milk">
22
+ <div>
23
+ page-object rocks!
24
+ </div>
25
+ <span>
26
+ My alert
27
+ </span>
28
+ <table>
29
+ <tr><td>Data1</td><td>Data2</td></tr>
30
+ </table>
31
+ <img src="images/circle.png">
32
+ <ol>
33
+ <li>Number One</li>
34
+ <li>Number Two</li>
35
+ </ol>
36
+ <ul>
37
+ <li>Item One</li>
38
+ <li>Item Two</li>
39
+ </ul>
40
+ </div>
41
+ </body>
42
+ </html>
@@ -94,6 +94,7 @@
94
94
  <input id=alert_button type=button onclick="alert('I am an alert')" value=Alert>
95
95
  <input id=confirm_button type=button onclick="this.value = confirm('set the value')" value=Confirm>
96
96
  <input id=prompt_button type=button onclick='this.value = prompt("enter your name", "John Doe")' value=Prompt>
97
+
97
98
  <h3>New Window</h3>
98
99
  <a href="success.html" target="_blank">New Window</a>
99
100
  </body>
@@ -0,0 +1,15 @@
1
+ Feature: handing modal dialogs
2
+
3
+ Background:
4
+ Given I am on the modal page
5
+
6
+
7
+ Scenario: Interacting with a modal dialog
8
+ When I open a modal dialog
9
+ Then I should be able to close the modal
10
+
11
+ Scenario: Nested modal dialogs
12
+ When I open a modal dialog
13
+ And I open another modal dialog from that one
14
+ #Then I should be able to close both modals
15
+