Jonas
|
14
|
1
|
# The accessors available for SeleniumOnRails::TestBuilder tests.
|
|
2
|
#
|
|
3
|
# For each +store_foo+ there's +assert_foo+, +assert_not_foo+, +verify_foo+,
|
|
4
|
# +verify_not_foo+, +wait_for_foo+, +wait_for_not_foo+.
|
|
5
|
module SeleniumOnRails::TestBuilderAccessors
|
|
6
|
# Has an alert occurred?
|
|
7
|
#
|
|
8
|
# Related Assertions, automatically generated:
|
|
9
|
# * +assert_alert_present+
|
|
10
|
# * +assert_alert_not_present+
|
|
11
|
# * +verify_alert_present+
|
|
12
|
# * +verify_alert_not_present+
|
|
13
|
# * +wait_for_alert_present+
|
|
14
|
# * +wait_for_alert_not_present+
|
|
15
|
def store_alert_present variable_name
|
|
16
|
command 'storeAlertPresent', variable_name
|
|
17
|
end
|
|
18
|
|
|
19
|
# Has a prompt occurred?
|
|
20
|
#
|
|
21
|
# Related Assertions, automatically generated:
|
|
22
|
# * +assert_prompt_present+
|
|
23
|
# * +assert_prompt_not_present+
|
|
24
|
# * +verify_prompt_present+
|
|
25
|
# * +verify_prompt_not_present+
|
|
26
|
# * +wait_for_prompt_present+
|
|
27
|
# * +wait_for_prompt_not_present+
|
|
28
|
def store_prompt_present variable_name
|
|
29
|
command 'storePromptPresent', variable_name
|
|
30
|
end
|
|
31
|
|
|
32
|
# Has <tt>confirm()</tt> been called?
|
|
33
|
#
|
|
34
|
# Related Assertions, automatically generated:
|
|
35
|
# * +assert_confirmation_present+
|
|
36
|
# * +assert_confirmation_not_present+
|
|
37
|
# * +verify_confirmation_present+
|
|
38
|
# * +verify_confirmation_not_present+
|
|
39
|
# * +wait_for_confirmation_present+
|
|
40
|
# * +wait_for_confirmation_not_present+
|
|
41
|
def store_confirmation_present variable_name
|
|
42
|
command 'storeConfirmationPresent', variable_name
|
|
43
|
end
|
|
44
|
|
|
45
|
# Retrieves the message of a JavaScript alert generated during the previous
|
|
46
|
# action, or fail if there were no alerts.
|
|
47
|
#
|
|
48
|
# Getting an alert has the same effect as manually clicking OK. If an alert
|
|
49
|
# is generated but you do not get/verify it, the next Selenium action will
|
|
50
|
# fail.
|
|
51
|
#
|
|
52
|
# NOTE: under Selenium, JavaScript alerts will NOT pop up a visible alert
|
|
53
|
# dialog.
|
|
54
|
#
|
|
55
|
# NOTE: Selenium does NOT support JavaScript alerts that are generated in a
|
|
56
|
# page's <tt>onload()</tt> event handler. In this case a visible dialog WILL be
|
|
57
|
# generated and Selenium will hang until someone manually clicks OK.
|
|
58
|
#
|
|
59
|
# Related Assertions, automatically generated:
|
|
60
|
# * <tt>assert_alert(pattern)</tt>
|
|
61
|
# * <tt>assert_not_alert(pattern)</tt>
|
|
62
|
# * <tt>verify_alert_present(pattern)</tt>
|
|
63
|
# * <tt>verify_not_alert(pattern)</tt>
|
|
64
|
# * <tt>wait_for_alert(pattern)</tt>
|
|
65
|
# * <tt>wait_for_not_alert(pattern)</tt>
|
|
66
|
def store_alert variable_name
|
|
67
|
command 'storeAlert', variable_name
|
|
68
|
end
|
|
69
|
|
|
70
|
# Retrieves the message of a JavaScript confirmation dialog generated during
|
|
71
|
# the previous action.
|
|
72
|
#
|
|
73
|
# By default, the confirm function will return +true+, having the same effect
|
|
74
|
# as manually clicking OK. This can be changed by prior execution of the
|
|
75
|
# +choose_cancel_on_next_confirmation+ command. If a confirmation is
|
|
76
|
# generated but you do not get/verify it, the next Selenium action will fail.
|
|
77
|
#
|
|
78
|
# NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible
|
|
79
|
# dialog.
|
|
80
|
#
|
|
81
|
# NOTE: Selenium does NOT support JavaScript confirmations that are generated
|
|
82
|
# in a page's <tt>onload()</tt> event handler. In this case a visible dialog WILL be
|
|
83
|
# generated and Selenium will hang until you manually click OK.
|
|
84
|
#
|
|
85
|
# Related Assertions, automatically generated:
|
|
86
|
# * <tt>assert_confirmation(pattern)</tt>
|
|
87
|
# * <tt>assert_not_confirmation(pattern)</tt>
|
|
88
|
# * <tt>verify_confirmation_present(pattern)</tt>
|
|
89
|
# * <tt>verify_not_confirmation(pattern)</tt>
|
|
90
|
# * <tt>wait_for_confirmation(pattern)</tt>
|
|
91
|
# * <tt>wait_for_not_confirmation(pattern)</tt>
|
|
92
|
def store_confirmation variable_name
|
|
93
|
command 'storeConfirmation', variable_name
|
|
94
|
end
|
|
95
|
|
|
96
|
# Retrieves the message of a JavaScript question prompt dialog generated
|
|
97
|
# during the previous action.
|
|
98
|
#
|
|
99
|
# Successful handling of the prompt requires prior execution of the
|
|
100
|
# +answer_on_next_prompt+ command. If a prompt is generated but you do not
|
|
101
|
# get/verify it, the next Selenium action will fail.
|
|
102
|
#
|
|
103
|
# NOTE: under Selenium, JavaScript prompts will NOT pop up a visible dialog.
|
|
104
|
#
|
|
105
|
# NOTE: Selenium does NOT support JavaScript prompts that are generated in a
|
|
106
|
# page's <tt>onload()</tt> event handler. In this case a visible dialog WILL be
|
|
107
|
# generated and Selenium will hang until someone manually clicks OK.
|
|
108
|
#
|
|
109
|
# Related Assertions, automatically generated:
|
|
110
|
# * <tt>assert_prompt(pattern)</tt>
|
|
111
|
# * <tt>assert_not_prompt(pattern)</tt>
|
|
112
|
# * <tt>verify_prompt_present(pattern)</tt>
|
|
113
|
# * <tt>verify_not_prompt(pattern)</tt>
|
|
114
|
# * <tt>wait_for_prompt(pattern)</tt>
|
|
115
|
# * <tt>wait_for_not_prompt(pattern)</tt>
|
|
116
|
def store_prompt variable_name
|
|
117
|
command 'storePrompt', variable_name
|
|
118
|
end
|
|
119
|
|
|
120
|
# Gets the absolute URL of the current page.
|
|
121
|
#
|
|
122
|
# Related Assertions, automatically generated:
|
|
123
|
# * <tt>assert_absolute_location(pattern)</tt>
|
|
124
|
# * <tt>assert_not_absolute_location(pattern)</tt>
|
|
125
|
# * <tt>verify_absolute_location_present(pattern)</tt>
|
|
126
|
# * <tt>verify_not_absolute_location(pattern)</tt>
|
|
127
|
# * <tt>wait_for_absolute_location(pattern)</tt>
|
|
128
|
# * <tt>wait_for_not_absolute_location(pattern)</tt>
|
|
129
|
def store_absolute_location variable_name
|
|
130
|
command 'storeAbsoluteLocation', variable_name
|
|
131
|
end
|
|
132
|
|
|
133
|
# Verify the location of the current page ends with the expected location.
|
|
134
|
# If an URL querystring is provided, this is checked as well.
|
|
135
|
#
|
|
136
|
# Related Assertions, automatically generated:
|
|
137
|
# * <tt>assert_location(pattern)</tt>
|
|
138
|
# * <tt>assert_not_location(pattern)</tt>
|
|
139
|
# * <tt>verify_location_present(pattern)</tt>
|
|
140
|
# * <tt>verify_not_location(pattern)</tt>
|
|
141
|
# * <tt>wait_for_location(pattern)</tt>
|
|
142
|
# * <tt>wait_for_not_location(pattern)</tt>
|
|
143
|
def store_location expected_location, variable_name
|
|
144
|
command 'storeLocation', expected_location, variable_name
|
|
145
|
end
|
|
146
|
|
|
147
|
# Gets the title of the current page.
|
|
148
|
#
|
|
149
|
# Related Assertions, automatically generated:
|
|
150
|
# * <tt>assert_title(pattern)</tt>
|
|
151
|
# * <tt>assert_not_title(pattern)</tt>
|
|
152
|
# * <tt>verify_title_present(pattern)</tt>
|
|
153
|
# * <tt>verify_not_title(pattern)</tt>
|
|
154
|
# * <tt>wait_for_title(pattern)</tt>
|
|
155
|
# * <tt>wait_for_not_title(pattern)</tt>
|
|
156
|
def store_title variable_name
|
|
157
|
command 'storeTitle', variable_name
|
|
158
|
end
|
|
159
|
|
|
160
|
# Gets the entire text of the page.
|
|
161
|
#
|
|
162
|
# Related Assertions, automatically generated:
|
|
163
|
# * <tt>assert_body_text(pattern)</tt>
|
|
164
|
# * <tt>assert_not_body_text(pattern)</tt>
|
|
165
|
# * <tt>verify_body_text_present(pattern)</tt>
|
|
166
|
# * <tt>verify_not_body_text(pattern)</tt>
|
|
167
|
# * <tt>wait_for_body_text(pattern)</tt>
|
|
168
|
# * <tt>wait_for_not_body_text(pattern)</tt>
|
|
169
|
def store_body_text variable_name
|
|
170
|
command 'storeBodyText', variable_name
|
|
171
|
end
|
|
172
|
|
|
173
|
# Gets the (whitespace-trimmed) value of an input field (or anything else
|
|
174
|
# with a value parameter). For checkbox/radio elements, the value will be
|
|
175
|
# "on" or "off" depending on whether the element is checked or not.
|
|
176
|
#
|
|
177
|
# Related Assertions, automatically generated:
|
|
178
|
# * <tt>assert_value(locator, pattern)</tt>
|
|
179
|
# * <tt>assert_not_value(locator, pattern)</tt>
|
|
180
|
# * <tt>verify_value_present(locator, pattern)</tt>
|
|
181
|
# * <tt>verify_not_value(locator, pattern)</tt>
|
|
182
|
# * <tt>wait_for_value(locator, pattern)</tt>
|
|
183
|
# * <tt>wait_for_not_value(locator, pattern)</tt>
|
|
184
|
def store_value locator, variable_name
|
|
185
|
command 'storeValue', locator, variable_name
|
|
186
|
end
|
|
187
|
|
|
188
|
# Gets the text of an element. This works for any element that contains text.
|
|
189
|
# This command uses either the +textContent+ (Mozilla-like browsers) or the
|
|
190
|
# +innerText+ (IE-like browsers) of the element, which is the rendered text
|
|
191
|
# shown to the user.
|
|
192
|
#
|
|
193
|
# Related Assertions, automatically generated:
|
|
194
|
# * <tt>assert_text(locator, pattern)</tt>
|
|
195
|
# * <tt>assert_not_text(locator, pattern)</tt>
|
|
196
|
# * <tt>verify_text_present(locator, pattern)</tt>
|
|
197
|
# * <tt>verify_not_text(locator, pattern)</tt>
|
|
198
|
# * <tt>wait_for_text(locator, pattern)</tt>
|
|
199
|
# * <tt>wait_for_not_text(locator, pattern)</tt>
|
|
200
|
def store_text locator, variable_name
|
|
201
|
command 'storeText', locator, variable_name
|
|
202
|
end
|
|
203
|
|
|
204
|
# Gets the result of evaluating the specified JavaScript snippet. The snippet
|
|
205
|
# may have multiple lines, but only the result of the last line will be
|
|
206
|
# returned.
|
|
207
|
#
|
|
208
|
# Note that, by default, the snippet will run in the context of the
|
|
209
|
# "selenium" object itself, so +this+ will refer to the Selenium object, and
|
|
210
|
# +window+ will refer to the top-level runner test window, not the window of
|
|
211
|
# your application.
|
|
212
|
#
|
|
213
|
# If you need a reference to the window of your application, you can refer to
|
|
214
|
# <tt>this.browserbot.getCurrentWindow()</tt> and if you need to use a locator to
|
|
215
|
# refer to a single element in your application page, you can use
|
|
216
|
# <tt>this.page().findElement("foo")</tt> where <tt>"foo"</tt> is your locator.
|
|
217
|
#
|
|
218
|
# Related Assertions, automatically generated:
|
|
219
|
# * <tt>assert_eval(script, pattern)</tt>
|
|
220
|
# * <tt>assert_not_eval(script, pattern)</tt>
|
|
221
|
# * <tt>verify_eval_present(script, pattern)</tt>
|
|
222
|
# * <tt>verify_not_eval(script, pattern)</tt>
|
|
223
|
# * <tt>wait_for_eval(script, pattern)</tt>
|
|
224
|
# * <tt>wait_for_not_eval(script, pattern)</tt>
|
|
225
|
def store_eval script, variable_name
|
|
226
|
command 'storeEval', script, variable_name
|
|
227
|
end
|
|
228
|
|
|
229
|
# Gets whether a toggle-button (checkbox/radio) is checked. Fails if the
|
|
230
|
# specified element doesn't exist or isn't a toggle-button.
|
|
231
|
#
|
|
232
|
# Related Assertions, automatically generated:
|
|
233
|
# * <tt>assert_checked(locator, pattern)</tt>
|
|
234
|
# * <tt>assert_not_checked(locator, pattern)</tt>
|
|
235
|
# * <tt>verify_checked_present(locator, pattern)</tt>
|
|
236
|
# * <tt>verify_not_checked(locator, pattern)</tt>
|
|
237
|
# * <tt>wait_for_checked(locator, pattern)</tt>
|
|
238
|
# * <tt>wait_for_not_checked(locator, pattern)</tt>
|
|
239
|
def store_checked locator, variable_name
|
|
240
|
command 'storeChecked', locator, variable_name
|
|
241
|
end
|
|
242
|
|
|
243
|
# Gets the text from a cell of a table.
|
|
244
|
#
|
|
245
|
# Related Assertions, automatically generated:
|
|
246
|
# * <tt>assert_table(locator, row, column, pattern)</tt>
|
|
247
|
# * <tt>assert_not_table(locator, row, column, pattern)</tt>
|
|
248
|
# * <tt>verify_table_present(locator, row, column, pattern)</tt>
|
|
249
|
# * <tt>verify_not_table(locator, row, column, pattern)</tt>
|
|
250
|
# * <tt>wait_for_table(locator, row, column, pattern)</tt>
|
|
251
|
# * <tt>wait_for_not_table(locator, row, column, pattern)</tt>
|
|
252
|
def store_table locator, row, column, variable_name
|
|
253
|
command 'storeTable', "#{locator}.#{row}.#{column}", variable_name
|
|
254
|
end
|
|
255
|
|
|
256
|
# Verifies that the selected option of a drop-down satisfies the
|
|
257
|
# +option_locator+.
|
|
258
|
#
|
|
259
|
# +option_locator+ is typically just an option label (e.g. "John Smith").
|
|
260
|
#
|
|
261
|
# See the +select+ command for more information about option locators.
|
|
262
|
#
|
|
263
|
# NOTE: +store_selected+ is currently not supported by Selenium Core.
|
|
264
|
#
|
|
265
|
# Related Assertions, automatically generated:
|
|
266
|
# * <tt>assert_selected(locator, option_locator)</tt>
|
|
267
|
# * <tt>assert_not_selected(locator, option_locator)</tt>
|
|
268
|
# * <tt>verify_selected_present(locator, option_locator)</tt>
|
|
269
|
# * <tt>verify_not_selected(locator, option_locator)</tt>
|
|
270
|
# * <tt>wait_for_selected(locator, option_locator)</tt>
|
|
271
|
# * <tt>wait_for_not_selected(locator, option_locator)</tt>
|
|
272
|
def store_selected locator, option_locator, variable_name
|
|
273
|
raise 'Not supported in Selenium Core at the moment'
|
|
274
|
end
|
|
275
|
|
|
276
|
# Gets all option labels for selected options in the specified select or
|
|
277
|
# multi-select element.
|
|
278
|
#
|
|
279
|
# The +pattern+ for the automatically generated assertions can either take an
|
|
280
|
# array or a pattern.
|
|
281
|
# assert_selected_options 'fruits', ['apple', 'pear']
|
|
282
|
# assert_selected_options 'fruits', 'a*,p*'
|
|
283
|
#
|
|
284
|
# Related Assertions, automatically generated:
|
|
285
|
# * <tt>assert_selected_options(locator, pattern)</tt>
|
|
286
|
# * <tt>assert_not_selected_options(locator, pattern)</tt>
|
|
287
|
# * <tt>verify_selected_options_present(locator, pattern)</tt>
|
|
288
|
# * <tt>verify_not_selected_options(locator, pattern)</tt>
|
|
289
|
# * <tt>wait_for_selected_options(locator, pattern)</tt>
|
|
290
|
# * <tt>wait_for_not_selected_options(locator, pattern)</tt>
|
|
291
|
def store_selected_options locator, variable_name
|
|
292
|
command 'storeSelectedOptions', locator, variable_name
|
|
293
|
end
|
|
294
|
|
|
295
|
# Gets all option labels in the specified select drop-down.
|
|
296
|
#
|
|
297
|
# The +pattern+ for the automatically generated assertions can either take an
|
|
298
|
# array or a pattern.
|
|
299
|
# assert_select_options 'fruits', ['apple', 'pear']
|
|
300
|
# assert_select_options 'fruits', 'a*,p*'
|
|
301
|
#
|
|
302
|
# Related Assertions, automatically generated:
|
|
303
|
# * <tt>assert_select_options(locator, pattern)</tt>
|
|
304
|
# * <tt>assert_not_select_options(locator, pattern)</tt>
|
|
305
|
# * <tt>verify_select_options_present(locator, pattern)</tt>
|
|
306
|
# * <tt>verify_not_select_options(locator, pattern)</tt>
|
|
307
|
# * <tt>wait_for_select_options(locator, pattern)</tt>
|
|
308
|
# * <tt>wait_for_not_select_options(locator, pattern)</tt>
|
|
309
|
def store_select_options locator, variable_name
|
|
310
|
command 'storeSelectOptions', locator, variable_name
|
|
311
|
end
|
|
312
|
|
|
313
|
# Gets the value of an element attribute.
|
|
314
|
#
|
|
315
|
# Related Assertions, automatically generated:
|
|
316
|
# * <tt>assert_attribute(locator, attribute_name, pattern)</tt>
|
|
317
|
# * <tt>assert_not_attribute(locator, attribute_name, pattern)</tt>
|
|
318
|
# * <tt>verify_attribute_present(locator, attribute_name, pattern)</tt>
|
|
319
|
# * <tt>verify_not_attribute(locator, attribute_name, pattern)</tt>
|
|
320
|
# * <tt>wait_for_attribute(locator, attribute_name, pattern)</tt>
|
|
321
|
# * <tt>wait_for_not_attribute(locator, attribute_name, pattern)</tt>
|
|
322
|
def store_attribute locator, attribute_name, variable_name
|
|
323
|
command 'storeAttribute', "#{locator}@#{attribute_name}", variable_name
|
|
324
|
end
|
|
325
|
|
|
326
|
# Verifies that the specified text pattern appears somewhere on the rendered
|
|
327
|
# page shown to the user.
|
|
328
|
#
|
|
329
|
# Related Assertions, automatically generated:
|
|
330
|
# * <tt>assert_text_present(pattern)</tt>
|
|
331
|
# * <tt>assert_text_not_present(pattern)</tt>
|
|
332
|
# * <tt>verify_text_present(pattern)</tt>
|
|
333
|
# * <tt>verify_text_not_present(pattern)</tt>
|
|
334
|
# * <tt>wait_for_text_present(pattern)</tt>
|
|
335
|
# * <tt>wait_for_text_not_present(pattern)</tt>
|
|
336
|
def store_text_present pattern, variable_name
|
|
337
|
command 'storeTextPresent', pattern, variable_name
|
|
338
|
end
|
|
339
|
|
|
340
|
# Verifies that the specified element is somewhere on the page.
|
|
341
|
#
|
|
342
|
# Related Assertions, automatically generated:
|
|
343
|
# * <tt>assert_element_present(locator)</tt>
|
|
344
|
# * <tt>assert_element_not_present(locator)</tt>
|
|
345
|
# * <tt>verify_element_present(locator)</tt>
|
|
346
|
# * <tt>verify_element_not_present(locator)</tt>
|
|
347
|
# * <tt>wait_for_element_present(locator)</tt>
|
|
348
|
# * <tt>wait_for_element_not_present(locator)</tt>
|
|
349
|
def store_element_present locator, variable_name
|
|
350
|
command 'storeElementPresent', locator, variable_name
|
|
351
|
end
|
|
352
|
|
|
353
|
# Determines if the specified element is visible. An element can be rendered
|
|
354
|
# invisible by setting the CSS "visibility" property to "hidden", or the
|
|
355
|
# "display" property to "none", either for the element itself or one if its
|
|
356
|
# ancestors. This method will fail if the element is not present.
|
|
357
|
#
|
|
358
|
# Related Assertions, automatically generated:
|
|
359
|
# * <tt>assert_visible(locator)</tt>
|
|
360
|
# * <tt>assert_not_visible(locator)</tt>
|
|
361
|
# * <tt>verify_visible(locator)</tt>
|
|
362
|
# * <tt>verify_not_visible(locator)</tt>
|
|
363
|
# * <tt>wait_for_visible(locator)</tt>
|
|
364
|
# * <tt>wait_for_not_visible(locator)</tt>
|
|
365
|
def store_visible locator, variable_name
|
|
366
|
command 'storeVisible', locator, variable_name
|
|
367
|
end
|
|
368
|
|
|
369
|
# Determines whether the specified input element is editable, i.e. hasn't
|
|
370
|
# been disabled. This method will fail if the specified element isn't an
|
|
371
|
# input element.
|
|
372
|
#
|
|
373
|
# Related Assertions, automatically generated:
|
|
374
|
# * <tt>assert_editable(locator)</tt>
|
|
375
|
# * <tt>assert_not_editable(locator)</tt>
|
|
376
|
# * <tt>verify_editable(locator)</tt>
|
|
377
|
# * <tt>verify_not_editable(locator)</tt>
|
|
378
|
# * <tt>wait_for_editable(locator)</tt>
|
|
379
|
# * <tt>wait_for_not_editable(locator)</tt>
|
|
380
|
def store_editable locator, variable_name
|
|
381
|
command 'storeEditable', locator, variable_name
|
|
382
|
end
|
|
383
|
|
|
384
|
# Returns the IDs of all buttons on the page.
|
|
385
|
#
|
|
386
|
# If a given button has no ID, it will appear as "" in this array.
|
|
387
|
#
|
|
388
|
# The +pattern+ for the automatically generated assertions can either take an
|
|
389
|
# array or a pattern.
|
|
390
|
# assert_all_buttons ['but1', 'but2']
|
|
391
|
# assert_all_buttons 'but?,but?*'
|
|
392
|
#
|
|
393
|
# Related Assertions, automatically generated:
|
|
394
|
# * <tt>assert_all_buttons(pattern)</tt>
|
|
395
|
# * <tt>assert_not_all_buttons(pattern)</tt>
|
|
396
|
# * <tt>verify_all_buttons(pattern)</tt>
|
|
397
|
# * <tt>verify_not_all_buttons(pattern)</tt>
|
|
398
|
# * <tt>wait_for_all_buttons(pattern)</tt>
|
|
399
|
# * <tt>wait_for_not_all_buttons(pattern)</tt>
|
|
400
|
def store_all_buttons variable_name
|
|
401
|
command 'storeAllButtons', variable_name
|
|
402
|
end
|
|
403
|
|
|
404
|
# Returns the IDs of all links on the page.
|
|
405
|
#
|
|
406
|
# If a given link has no ID, it will appear as "" in this array.
|
|
407
|
#
|
|
408
|
# The +pattern+ for the automatically generated assertions can either take an
|
|
409
|
# array or a pattern.
|
|
410
|
# assert_all_links ['link1', 'link2']
|
|
411
|
# assert_all_links 'link?,link?*'
|
|
412
|
#
|
|
413
|
# Related Assertions, automatically generated:
|
|
414
|
# * <tt>assert_all_links(pattern)</tt>
|
|
415
|
# * <tt>assert_not_all_links(pattern)</tt>
|
|
416
|
# * <tt>verify_all_links(pattern)</tt>
|
|
417
|
# * <tt>verify_not_all_links(pattern)</tt>
|
|
418
|
# * <tt>wait_for_all_links(pattern)</tt>
|
|
419
|
# * <tt>wait_for_not_all_links(pattern)</tt>
|
|
420
|
def store_all_links variable_name
|
|
421
|
command 'storeAllLinks', variable_name
|
|
422
|
end
|
|
423
|
|
|
424
|
# Returns the IDs of all input fields on the page.
|
|
425
|
#
|
|
426
|
# If a given field has no ID, it will appear as "" in this array.
|
|
427
|
#
|
|
428
|
# The +pattern+ for the automatically generated assertions can either take an
|
|
429
|
# array or a pattern.
|
|
430
|
# assert_all_fields ['field1', 'field2']
|
|
431
|
# assert_all_fields 'field?,field?*'
|
|
432
|
#
|
|
433
|
# Related Assertions, automatically generated:
|
|
434
|
# * <tt>assert_all_fields(pattern)</tt>
|
|
435
|
# * <tt>assert_not_all_fields(pattern)</tt>
|
|
436
|
# * <tt>verify_all_fields(pattern)</tt>
|
|
437
|
# * <tt>verify_not_all_fields(pattern)</tt>
|
|
438
|
# * <tt>wait_for_all_fields(pattern)</tt>
|
|
439
|
# * <tt>wait_for_not_all_fields(pattern)</tt>
|
|
440
|
def store_all_fields variable_name
|
|
441
|
command 'storeAllFields', variable_name
|
|
442
|
end
|
|
443
|
|
|
444
|
# Returns the entire HTML source between the opening and closing "html" tags.
|
|
445
|
#
|
|
446
|
# Related Assertions, automatically generated:
|
|
447
|
# * <tt>assert_html_source(pattern)</tt>
|
|
448
|
# * <tt>assert_not_html_source(pattern)</tt>
|
|
449
|
# * <tt>verify_html_source(pattern)</tt>
|
|
450
|
# * <tt>verify_not_html_source(pattern)</tt>
|
|
451
|
# * <tt>wait_for_html_source(pattern)</tt>
|
|
452
|
# * <tt>wait_for_not_html_source(pattern)</tt>
|
|
453
|
def store_html_source variable_name
|
|
454
|
command 'storeHtmlSource', variable_name
|
|
455
|
end
|
|
456
|
|
|
457
|
# Returns the specified expression.
|
|
458
|
#
|
|
459
|
# This is useful because of JavaScript preprocessing.
|
|
460
|
#
|
|
461
|
# Related Assertions, automatically generated:
|
|
462
|
# * <tt>assert_expression(expression, pattern)</tt>
|
|
463
|
# * <tt>assert_not_expression(expression, pattern)</tt>
|
|
464
|
# * <tt>verify_expression(expression, pattern)</tt>
|
|
465
|
# * <tt>verify_not_expression(expression, pattern)</tt>
|
|
466
|
# * <tt>wait_for_expression(expression, pattern)</tt>
|
|
467
|
# * <tt>wait_for_not_expression(expression, pattern)</tt>
|
|
468
|
def store_expression expression, variable_name
|
|
469
|
command 'storeExpression', expression, variable_name
|
|
470
|
end
|
|
471
|
|
|
472
|
private
|
|
473
|
# Generates all assertions for the accessors.
|
|
474
|
def self.generate_methods
|
|
475
|
public_instance_methods.each do |method|
|
|
476
|
case method
|
|
477
|
when 'store_alert_present',
|
|
478
|
'store_prompt_present',
|
|
479
|
'store_confirmation_present'
|
|
480
|
each_assertion method do |assertion_method, command_name|
|
|
481
|
define_method assertion_method do
|
|
482
|
command command_name
|
|
483
|
end
|
|
484
|
end
|
|
485
|
when 'store_alert',
|
|
486
|
'store_confirmation',
|
|
487
|
'store_prompt',
|
|
488
|
'store_title',
|
|
489
|
'store_body_text',
|
|
490
|
'store_text_present',
|
|
491
|
'store_element_present',
|
|
492
|
'store_visible',
|
|
493
|
'store_editable',
|
|
494
|
'store_html_source'
|
|
495
|
each_assertion method do |assertion_method, command_name|
|
|
496
|
define_method assertion_method do |pattern|
|
|
497
|
command command_name, pattern
|
|
498
|
end
|
|
499
|
end
|
|
500
|
when 'store_value',
|
|
501
|
'store_text',
|
|
502
|
'store_eval',
|
|
503
|
'store_checked',
|
|
504
|
'store_selected',
|
|
505
|
'store_expression'
|
|
506
|
each_assertion method do |assertion_method, command_name|
|
|
507
|
define_method assertion_method do |arg1, arg2|
|
|
508
|
command command_name, arg1, arg2
|
|
509
|
end
|
|
510
|
end
|
|
511
|
when 'store_all_buttons',
|
|
512
|
'store_all_links',
|
|
513
|
'store_all_fields'
|
|
514
|
each_assertion method do |assertion_method, command_name|
|
|
515
|
define_method assertion_method do |pattern|
|
|
516
|
command command_name, collection_arg(pattern)
|
|
517
|
end
|
|
518
|
end
|
|
519
|
when 'store_select_options',
|
|
520
|
'store_selected_options'
|
|
521
|
each_assertion method do |assertion_method, command_name|
|
|
522
|
define_method assertion_method do |locator, pattern|
|
|
523
|
command command_name, locator, collection_arg(pattern)
|
|
524
|
end
|
|
525
|
end
|
|
526
|
when 'store_attribute'
|
|
527
|
each_assertion method do |assertion_method, command_name|
|
|
528
|
define_method assertion_method do |locator, attribute_name, pattern|
|
|
529
|
command command_name, "#{locator}@#{attribute_name}", pattern
|
|
530
|
end
|
|
531
|
end
|
|
532
|
when 'store_table'
|
|
533
|
each_assertion method do |assertion_method, command_name|
|
|
534
|
define_method assertion_method do |locator, row, column, pattern|
|
|
535
|
command command_name, "#{locator}.#{row}.#{column}", pattern
|
|
536
|
end
|
|
537
|
end
|
|
538
|
when 'store_absolute_location',
|
|
539
|
'store_location'
|
|
540
|
each_assertion method do |assertion_method, command_name|
|
|
541
|
define_method assertion_method do |pattern|
|
|
542
|
if method == 'store_absolute_location' and pattern.is_a? Hash
|
|
543
|
pattern[:only_path] = false
|
|
544
|
end
|
|
545
|
|
|
546
|
command command_name, url_arg(pattern)
|
|
547
|
end
|
|
548
|
end
|
|
549
|
when /^store_/
|
|
550
|
raise 'internal error'
|
|
551
|
end
|
|
552
|
end
|
|
553
|
end
|
|
554
|
|
|
555
|
# Generates all the assertions needed given a +store_method+.
|
|
556
|
def self.each_assertion store_method
|
|
557
|
before_negation = nil
|
|
558
|
after_negation = store_method.split('_')[1..-1] #throw away 'store'
|
|
559
|
if after_negation.last == 'present'
|
|
560
|
before_negation, after_negation = after_negation, after_negation.pop
|
|
561
|
end
|
|
562
|
|
|
563
|
['assert', 'verify', ['wait','for']].each do |action|
|
|
564
|
[nil, 'not'].each do |negation|
|
|
565
|
name = [action, before_negation, negation, after_negation].flatten.reject{|a|a.nil?}
|
|
566
|
method_name = name.join '_'
|
|
567
|
command = name.inject(name.shift.clone) {|n, p| n << p.capitalize}
|
|
568
|
yield method_name, command
|
|
569
|
end
|
|
570
|
end
|
|
571
|
end
|
|
572
|
|
|
573
|
generate_methods
|
|
574
|
end
|
|
575
|
|