awetestlib 0.1.5-x86-mingw32 → 0.1.6-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +55 -0
- data/awetestlib.windows.gemspec +2 -1
- data/awetestlib_osx.gemspec +1 -0
- data/lib/awetestlib/logging.rb +4 -4
- data/lib/awetestlib/regression/runner.rb +8 -2
- data/lib/awetestlib/regression/tables.rb +30 -5
- data/lib/awetestlib/regression/user_input.rb +550 -633
- data/lib/awetestlib/regression/utilities.rb +7 -0
- data/lib/version.rb +2 -2
- data/tmp/placeholder.html +71 -0
- metadata +20 -4
@@ -2,36 +2,28 @@ module Awetestlib
|
|
2
2
|
module Regression
|
3
3
|
module UserInput
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
Click a specific DOM element by one of its attributes and that attribute's value.
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
# html for a link element:
|
26
|
-
# <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
|
27
|
-
click(browser, :link, :text, 'Pickaxe')
|
28
|
-
|
29
|
-
=end
|
30
|
-
|
5
|
+
# @!group Core
|
6
|
+
|
7
|
+
# Click a specific DOM element identified by one of its attributes and that attribute's value.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# # html for a link element:
|
11
|
+
# # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
|
12
|
+
#
|
13
|
+
# click(browser, :link, :text, 'Pickaxe')
|
14
|
+
#
|
15
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
16
|
+
# @param [Symbol] element The kind of element to click. Must be one of the elements recognized by Watir.
|
17
|
+
# Some common values are :link, :button, :image, :div, :span.
|
18
|
+
# @param [Symbol] how The element attribute used to identify the specific element.
|
19
|
+
# Valid values depend on the kind of element.
|
20
|
+
# Common values: :text, :id, :title, :name, :class, :href (:link only)
|
21
|
+
# @param [String|Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
22
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
23
|
+
#
|
31
24
|
def click(browser, element, how, what, desc = '')
|
32
25
|
#debug_to_log("#{__method__}: #{element}, #{how}, #{what}")
|
33
|
-
msg = "Click #{element} :#{how}=>'#{what}'"
|
34
|
-
msg << ", '#{desc}'" if desc.length > 0
|
26
|
+
msg = build_message("Click #{element} :#{how}=>'#{what}'", desc)
|
35
27
|
msg1 = "#{element}(#{how}, '#{what}')"
|
36
28
|
begin
|
37
29
|
case element
|
@@ -66,38 +58,180 @@ _Example_
|
|
66
58
|
failed_to_log("Unable to #{msg}. '#{$!}'")
|
67
59
|
end
|
68
60
|
|
69
|
-
|
70
|
-
:category: A_rdoc_test
|
71
|
-
Click a specific DOM element by one of its attributes and that attribute's value and
|
72
|
-
do not wait for the browser to finish reloading. Used when a modal popup or alert is expected. Allows the script
|
73
|
-
to keep running so the popup can be handled.
|
61
|
+
# @!endgroup Core
|
74
62
|
|
75
|
-
|
63
|
+
# @!group Click
|
76
64
|
|
77
|
-
|
65
|
+
# Click a button element identified by the value of its _id_ attribute. A button is an HTML element with tag 'input' and type 'submit' or 'button'.
|
66
|
+
# @param [Watir::Browser, Watir::Container] browser A reference to the browser window or container element to be tested.
|
67
|
+
# @param [String|Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the element.
|
68
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
69
|
+
#
|
70
|
+
def click_button_by_id(browser, what, desc = '')
|
71
|
+
click(browser, :button, :id, what, desc)
|
72
|
+
end
|
78
73
|
|
79
|
-
|
80
|
-
|
74
|
+
# Click a button element identified by the value of its index within the container referred to by <b>+browser+</b>.
|
75
|
+
# @param [Watir::Browser, Watir::Container] browser A reference to the browser window or container element to be tested.
|
76
|
+
# @param [Fixnum] what An integer that indicates the index of the element within the container.
|
77
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
78
|
+
def click_link_by_index(browser, what, desc = '')
|
79
|
+
click(browser, :link, :index, what, desc)
|
80
|
+
end
|
81
81
|
|
82
|
-
|
83
|
-
|
82
|
+
# Click a link element identified by the value of its _href_ attribute. Take care to escape characters in the url that are reserved by Regexp.
|
83
|
+
# @param (see #click_button_by_id)
|
84
|
+
def click_link_by_href(browser, what, desc = '')
|
85
|
+
click(browser, :link, :href, what, desc)
|
86
|
+
end
|
84
87
|
|
85
|
-
|
88
|
+
alias click_href click_link_by_href
|
86
89
|
|
87
|
-
|
90
|
+
# Click a link element identified by the value of its _href_ attribute and do not wait for the browser to reach ready state.
|
91
|
+
# Take care to escape characters in the url that are reserved by Regexp.
|
92
|
+
# @param (see #click_button_by_id)
|
93
|
+
def click_link_no_wait_by_href(browser, what, desc = '')
|
94
|
+
click_no_wait(browser, :link, :href, what, desc)
|
95
|
+
end
|
88
96
|
|
89
|
-
|
97
|
+
# Click a button element identified by the value of its index within the container referred to by <b>+browser+</b>.
|
98
|
+
# @param (see #click_link_by_index)
|
99
|
+
def click_button_by_index(browser, what, desc = '')
|
100
|
+
click(browser, :button, :index, what, desc)
|
101
|
+
end
|
90
102
|
|
91
|
-
|
92
|
-
|
93
|
-
|
103
|
+
# Click a button element identified by the value of its _name_ attribute. A button is an HTML element with tag 'input' and type 'submit' or 'button'.
|
104
|
+
# @param (see #click_button_by_id)
|
105
|
+
def click_button_by_name(browser, what, desc = '')
|
106
|
+
click(browser, :button, :name, what, desc)
|
107
|
+
end
|
94
108
|
|
95
|
-
|
109
|
+
# Click a button element identified by the value of its _text_ attribute. A button is an HTML element with tag 'input' and type 'submit' or 'button'.
|
110
|
+
# @param (see #click_button_by_id)
|
111
|
+
def click_button_by_text(browser, what, desc = '')
|
112
|
+
click(browser, :button, :text, what, desc)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Click a button element identified by the value of its _class_ attribute. A button is an HTML element with tag 'input' and type 'submit' or 'button'.
|
116
|
+
# @param (see #click_button_by_id)
|
117
|
+
def click_button_by_class(browser, what, desc = '')
|
118
|
+
click(browser, :button, :class, what, desc)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Click a button element identified by the value of its _value_ attribute. A button is an HTML element with tag 'input' and type 'submit' or 'button'.
|
122
|
+
# @param (see #click_button_by_id)
|
123
|
+
def click_button_by_value(browser, what, desc = '')
|
124
|
+
click(browser, :button, :value, what, desc)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Click a button element identified by the value of its _title_ attribute. A button is an HTML element with tag 'input' and type 'submit' or 'button'.
|
128
|
+
# @param (see #click_button_by_id)
|
129
|
+
def click_button_by_title(browser, what, desc = '')
|
130
|
+
click(browser, :button, :title, what, desc)
|
131
|
+
end
|
132
|
+
|
133
|
+
# Click a link element identified by the value of its _id_ attribute.
|
134
|
+
# @param (see #click_button_by_id)
|
135
|
+
def click_link_by_id(browser, what, desc = '')
|
136
|
+
click(browser, :link, :id, what, desc)
|
137
|
+
end
|
138
|
+
|
139
|
+
alias click_id click_link_by_id
|
140
|
+
|
141
|
+
# Click a link element identified by the value of its _name_ attribute.
|
142
|
+
# @param (see #click_button_by_id)
|
143
|
+
def click_link_by_name(browser, what, desc = '')
|
144
|
+
click(browser, :link, :name, what, desc)
|
145
|
+
end
|
146
|
+
|
147
|
+
alias click_name click_link_by_name
|
148
|
+
|
149
|
+
# Click a file_field element identified by the value of its _id_ attribute.
|
150
|
+
# @param (see #click_button_by_id)
|
151
|
+
def click_file_field_by_id(browser, what, desc = '')
|
152
|
+
click(browser, :file_field, :id, what, desc)
|
153
|
+
end
|
154
|
+
|
155
|
+
# Click an image element identified by the value of its _id_ attribute.
|
156
|
+
# @param (see #click_button_by_id)
|
157
|
+
def click_img_by_alt(browser, what, desc = '')
|
158
|
+
click(browser, :image, :alt, what, desc)
|
159
|
+
end
|
160
|
+
|
161
|
+
# Click an image element identified by the value of its _title_ attribute.
|
162
|
+
# @param (see #click_button_by_id)
|
163
|
+
def click_img_by_title(browser, what, desc = '')
|
164
|
+
click(browser, :image, :title, what, desc)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Click an image element identified by the value of its _src_ attribute.
|
168
|
+
# Take care to escape characters in the source url that are reserved by Regexp.
|
169
|
+
# @param (see #click_button_by_id)
|
170
|
+
def click_img_by_src(browser, what, desc = '')
|
171
|
+
click(browser, :image, :src, what, desc)
|
172
|
+
end
|
173
|
+
|
174
|
+
# Click a link element identified by the value of its _value_ attribute.
|
175
|
+
# @param (see #click_button_by_id)
|
176
|
+
def click_link_by_value(browser, what, desc = '')
|
177
|
+
click(browser, :link, :value, what, desc)
|
178
|
+
end
|
96
179
|
|
180
|
+
# Click a link element identified by the value in its text (innerHTML).
|
181
|
+
# @param (see #click_button_by_id)
|
182
|
+
def click_link_by_text(browser, what, desc = '')
|
183
|
+
click(browser, :link, :text, what, desc)
|
184
|
+
end
|
185
|
+
|
186
|
+
alias click_link click_link_by_text
|
187
|
+
alias click_text click_link_by_text
|
188
|
+
alias click_js_button click_link_by_text
|
189
|
+
|
190
|
+
# Click a link element identified by the value of its _class_ attribute.
|
191
|
+
# @param (see #click_button_by_id)
|
192
|
+
def click_link_by_class(browser, what, desc = '')
|
193
|
+
click(browser, :link, :class, what, desc)
|
194
|
+
end
|
195
|
+
|
196
|
+
alias click_class click_link_by_class
|
197
|
+
|
198
|
+
# Click a span element identified by the value in its text (innerHTML).
|
199
|
+
# @param (see #click_button_by_id)
|
200
|
+
def click_span_by_text(browser, what, desc = '')
|
201
|
+
click(browser, :span, :text, what)
|
202
|
+
end
|
203
|
+
|
204
|
+
alias click_span_with_text click_span_by_text
|
205
|
+
|
206
|
+
# Click a link element identified by the value of its _title_ attribute.
|
207
|
+
# @param (see #click_button_by_id)
|
208
|
+
def click_link_by_title(browser, what, desc = '')
|
209
|
+
click(browser, :link, :title, what, desc)
|
210
|
+
end
|
211
|
+
|
212
|
+
alias click_title click_link_by_title
|
213
|
+
|
214
|
+
# @!endgroup Click
|
215
|
+
|
216
|
+
# @!group Core
|
217
|
+
|
218
|
+
# Click a specific DOM element by one of its attributes and that attribute's value and
|
219
|
+
# do not wait for the browser to finish reloading. Used when a modal popup or alert is expected. Allows the script
|
220
|
+
# to keep running so the popup can be handled.
|
221
|
+
#
|
222
|
+
# @example
|
223
|
+
# # html for a link element:
|
224
|
+
# # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
|
225
|
+
#
|
226
|
+
# click_no_wait(browser, :link, :text, 'Pickaxe')
|
227
|
+
#
|
228
|
+
# @see #click
|
229
|
+
#
|
230
|
+
# @param (see #click)
|
231
|
+
#
|
97
232
|
def click_no_wait(browser, element, how, what, desc = '')
|
98
233
|
debug_to_log("#{__method__}: #{element}, #{how}, #{what}")
|
99
|
-
msg = "Click no wait #{element} :#{how}=>'#{what}'"
|
100
|
-
msg << ", '#{desc}'" if desc.length > 0
|
234
|
+
msg = build_message("Click no wait #{element} :#{how}=>'#{what}'", desc)
|
101
235
|
msg1 = "#{element}(#{how}, '#{what}'"
|
102
236
|
begin
|
103
237
|
case element
|
@@ -139,197 +273,172 @@ _Example_
|
|
139
273
|
sleep_for(1)
|
140
274
|
end
|
141
275
|
|
142
|
-
|
143
|
-
def click_button_by_id(browser, strg, desc = '')
|
144
|
-
click(browser, :button, :id, strg, desc)
|
145
|
-
end
|
276
|
+
# @!endgroup Core
|
146
277
|
|
147
|
-
|
148
|
-
def click_link_by_index(browser, strg, desc = '')
|
149
|
-
click(browser, :link, :index, strg, desc)
|
150
|
-
end
|
278
|
+
alias click_href_no_wait click_link_no_wait_by_href
|
151
279
|
|
152
|
-
|
153
|
-
def click_link_by_href(browser, strg, desc = '')
|
154
|
-
click(browser, :link, :href, strg, desc)
|
155
|
-
end
|
280
|
+
# @!group Click No Wait
|
156
281
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
282
|
+
# Click a button element identified by the value of its _id_ attribute
|
283
|
+
# and do not wait for the browser to reach ready state.
|
284
|
+
# @param (see #click_button_by_id)
|
285
|
+
def click_button_no_wait_by_id(browser, what, desc = '')
|
286
|
+
click_no_wait(browser, :button, :id, what, desc)
|
161
287
|
end
|
162
288
|
|
163
|
-
alias
|
164
|
-
|
165
|
-
|
166
|
-
|
289
|
+
alias click_button_by_id_no_wait click_button_no_wait_by_id
|
290
|
+
|
291
|
+
# Click a button element identified by the value of its _name_ attribute
|
292
|
+
# and do not wait for the browser to reach ready state.
|
293
|
+
# @param (see #click_button_by_id)
|
294
|
+
def click_button_no_wait_by_name(browser, what, desc = '')
|
295
|
+
click_no_wait(browser, :button, :name, what, desc)
|
167
296
|
end
|
168
297
|
|
169
|
-
|
170
|
-
|
171
|
-
|
298
|
+
# Click a button element identified by the value of its _class_ attribute
|
299
|
+
# and do not wait for the browser to reach ready state.
|
300
|
+
# @param (see #click_button_by_id)
|
301
|
+
def click_button_no_wait_by_class(browser, what, desc = '')
|
302
|
+
click_no_wait(browser, :button, :class, what, desc)
|
172
303
|
end
|
173
304
|
|
174
|
-
|
175
|
-
|
176
|
-
|
305
|
+
alias click_button_by_class_no_wait click_button_no_wait_by_class
|
306
|
+
|
307
|
+
# Click a link element identified by the value of its _id_ attribute
|
308
|
+
# and do not wait for the browser to reach ready state.
|
309
|
+
# @param (see #click_button_by_id)
|
310
|
+
def click_link_no_wait_by_id(browser, what, desc = '')
|
311
|
+
click_no_wait(browser, :link, :id, what, desc)
|
177
312
|
end
|
178
313
|
|
179
|
-
|
180
|
-
|
181
|
-
|
314
|
+
alias click_no_wait_id click_link_no_wait_by_id
|
315
|
+
alias click_no_wait_by_id click_link_no_wait_by_id
|
316
|
+
alias click_id_no_wait click_link_no_wait_by_id
|
317
|
+
alias click_no_wait_link_by_id click_link_no_wait_by_id
|
318
|
+
|
319
|
+
# Click an image element identified by the value of its _alt_ attribute
|
320
|
+
# and do not wait for the browser to reach ready state.
|
321
|
+
# @param (see #click_button_by_id)
|
322
|
+
def click_img_no_wait_by_alt(browser, what, desc = '')
|
323
|
+
click_no_wait(browser, :image, :alt, what, desc)
|
182
324
|
end
|
183
325
|
|
184
|
-
|
185
|
-
|
186
|
-
|
326
|
+
alias click_img_by_alt_no_wait click_img_no_wait_by_alt
|
327
|
+
|
328
|
+
# Click a button element identified by the value in its text (innerHTML)
|
329
|
+
# and do not wait for the browser to reach ready state.
|
330
|
+
# @param (see #click_button_by_id)
|
331
|
+
def click_button_no_wait_by_text(browser, what, desc = '')
|
332
|
+
click_no_wait(browser, :button, :text, what, desc)
|
187
333
|
end
|
188
334
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
335
|
+
# Click a button element identified by the value of its _value_ attribute
|
336
|
+
# and do not wait for the browser to reach ready state.
|
337
|
+
# @param (see #click_button_by_id)
|
338
|
+
def click_button_no_wait_by_value(browser, what, desc = '')
|
339
|
+
click_no_wait(browser, :button, :value, what, desc)
|
193
340
|
end
|
194
341
|
|
195
|
-
|
196
|
-
|
197
|
-
|
342
|
+
# Click a button element identified by the value of its _name_ attribute
|
343
|
+
# and do not wait for the browser to reach ready state.
|
344
|
+
# @param (see #click_button_by_id)
|
345
|
+
def click_link_by_name_no_wait(browser, what, desc = '')
|
346
|
+
click_no_wait(browser, :link, :name, what, desc)
|
198
347
|
end
|
199
348
|
|
200
|
-
alias
|
201
|
-
|
202
|
-
|
203
|
-
|
349
|
+
alias click_no_wait_name click_link_by_name_no_wait
|
350
|
+
alias click_name_no_wait click_link_by_name_no_wait
|
351
|
+
|
352
|
+
# Click a link element identified by the value in its text (innerHTML)
|
353
|
+
# and do not wait for the browser to reach ready state.
|
354
|
+
# @param (see #click_button_by_id)
|
355
|
+
def click_link_by_text_no_wait(browser, what, desc = '')
|
356
|
+
click_no_wait(browser, :link, :text, what, desc)
|
204
357
|
end
|
205
358
|
|
206
|
-
|
207
|
-
|
208
|
-
|
359
|
+
alias click_no_wait_text click_link_by_text_no_wait
|
360
|
+
alias click_text_no_wait click_link_by_text_no_wait
|
361
|
+
|
362
|
+
# Click a link element identified by the value of its _title_ attribute
|
363
|
+
# and do not wait for the browser to reach ready state.
|
364
|
+
# @param (see #click_button_by_id)
|
365
|
+
def click_title_no_wait(browser, what, desc = '')
|
366
|
+
click_no_wait(browser, :link, :title, what, desc)
|
209
367
|
end
|
210
368
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
369
|
+
# @!endgroup Click No Wait
|
370
|
+
|
371
|
+
# @!group Xpath
|
372
|
+
|
373
|
+
# Click a button element identified by the value of its _id_ attribute using the xpath functionality in Watir.
|
374
|
+
# A button is an HTML element with tag 'input' and type 'submit' or 'button'.
|
375
|
+
# @note Normally used only when the element is not located by other methods.
|
376
|
+
# @param (see #click_button_by_id)
|
377
|
+
def click_button_by_xpath_and_id(browser, what, desc = '')
|
378
|
+
msg = "Click button by xpath and id '#{what}' #{desc}"
|
379
|
+
if browser.button(:xpath, "//a[@id = '#{what}']").click
|
215
380
|
passed_to_log(msg)
|
216
381
|
true
|
217
382
|
else
|
218
383
|
failed_to_log(msg)
|
219
384
|
end
|
220
385
|
rescue
|
221
|
-
failed_to_log("Unable to click button by xpath and id '#{
|
386
|
+
failed_to_log("Unable to click button by xpath and id '#{what}' #{desc} '#{$!}' (#{__LINE__})")
|
222
387
|
end
|
223
388
|
|
224
389
|
alias click_button_by_xpath click_button_by_xpath_and_id
|
225
390
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
*browser* - a reference to the browser window to be tested
|
233
|
-
|
234
|
-
*strg* - a string or a regular expression to be found in the id attribute that uniquely identifies the element.
|
235
|
-
|
236
|
-
*desc* - a string containing a message or description intended to appear in the log and/or report output
|
237
|
-
|
238
|
-
|
239
|
-
_Example_
|
240
|
-
|
241
|
-
# html for a link element:
|
242
|
-
# <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
|
243
|
-
click_link_by_text(browser, 'Pickaxe', 'Open the page for the Pickaxe book')
|
244
|
-
|
245
|
-
=end
|
246
|
-
|
247
|
-
def click_link_by_id(browser, strg, desc = '')
|
248
|
-
click(browser, :link, :id, strg, desc)
|
249
|
-
end
|
250
|
-
|
251
|
-
# :category: A_rdoc_test
|
252
|
-
alias click_id click_link_by_id
|
253
|
-
|
254
|
-
# :category: User Input
|
255
|
-
def click_link_by_name(browser, strg, desc = '')
|
256
|
-
click(browser, :link, :name, strg, desc)
|
257
|
-
end
|
258
|
-
|
259
|
-
alias click_name click_link_by_name
|
260
|
-
# :category: User Input
|
261
|
-
def click_link_by_xpath_and_id(browser, strg, desc = '')
|
262
|
-
msg = "Click link by xpath and id '#{strg}' #{desc}"
|
263
|
-
if browser.link(:xpath, "//a[@id = '#{strg}']").click
|
391
|
+
# Click a link element identified by the value of its _id_ attribute using the xpath functionality in Watir.
|
392
|
+
# @note Normally used only when the element is not located by other methods.
|
393
|
+
# @param (see #click_button_by_id)
|
394
|
+
def click_link_by_xpath_and_id(browser, what, desc = '')
|
395
|
+
msg = "Click link by xpath and id '#{what}' #{desc}"
|
396
|
+
if browser.link(:xpath, "//a[@id = '#{what}']").click
|
264
397
|
passed_to_log(msg)
|
265
398
|
true
|
266
399
|
else
|
267
400
|
failed_to_log(msg)
|
268
401
|
end
|
269
402
|
rescue
|
270
|
-
failed_to_log("Unable
|
403
|
+
failed_to_log("Unable to #{msg} '#{$!}' (#{__LINE__})")
|
271
404
|
end
|
272
405
|
|
273
406
|
alias click_link_by_xpath click_link_by_xpath_and_id
|
274
407
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
alias click_no_wait_by_id click_link_no_wait_by_id
|
282
|
-
alias click_id_no_wait click_link_no_wait_by_id
|
283
|
-
alias click_no_wait_link_by_id click_link_no_wait_by_id
|
284
|
-
|
285
|
-
# :category: User Input
|
286
|
-
def click_file_field_by_id(browser, strg, desc = '')
|
287
|
-
click(browser, :file_field, :id, strg, desc)
|
288
|
-
end
|
289
|
-
|
290
|
-
# :category: User Input
|
291
|
-
def click_img_by_alt(browser, strg, desc = '')
|
292
|
-
click(browser, :image, :alt, strg, desc)
|
293
|
-
end
|
294
|
-
|
295
|
-
# :category: User Input
|
296
|
-
def click_img_by_title(browser, strg, desc = '')
|
297
|
-
click(browser, :image, :title, strg, desc)
|
298
|
-
end
|
299
|
-
|
300
|
-
# :category: User Input
|
301
|
-
def click_img_by_xpath_and_name(browser, strg, desc = '')
|
302
|
-
msg = "Click image by xpath where name='#{strg}' #{desc}"
|
303
|
-
if browser.link(:xpath, "//input[@name = '#{strg}']").click
|
408
|
+
# Click a link element identified by the value of its _id_ attribute using the xpath functionality in Watir.
|
409
|
+
# @note Normally used only when the element is not located by other methods.
|
410
|
+
# @param (see #click_button_by_id)
|
411
|
+
def click_img_by_xpath_and_name(browser, what, desc = '')
|
412
|
+
msg = "Click image by xpath where name='#{what}' #{desc}"
|
413
|
+
if browser.link(:xpath, "//input[@name = '#{what}']").click
|
304
414
|
passed_to_log(msg)
|
305
415
|
true
|
306
416
|
else
|
307
417
|
failed_to_log(msg)
|
308
418
|
end
|
309
419
|
rescue
|
310
|
-
failed_to_log("Unable to click image by xpath where name='#{
|
420
|
+
failed_to_log("Unable to click image by xpath where name='#{what}' #{desc} '#{$!}'")
|
311
421
|
end
|
312
422
|
|
313
423
|
alias click_img_by_xpath click_img_by_xpath_and_name
|
314
424
|
alias click_image_by_xpath click_img_by_xpath_and_name
|
315
425
|
alias click_image_by_xpath_and_name click_img_by_xpath_and_name
|
316
426
|
|
317
|
-
|
318
|
-
def click_img_no_wait_by_alt(browser, strg, desc = '')
|
319
|
-
click_no_wait(browser, :image, :alt, strg, desc)
|
320
|
-
end
|
427
|
+
# @!endgroup Xpath
|
321
428
|
|
322
|
-
|
323
|
-
# :category: User Input
|
324
|
-
def click_img_by_src(browser, strg, desc = '')
|
325
|
-
click(browser, :image, :src, strg, desc)
|
326
|
-
end
|
429
|
+
# @!group Core
|
327
430
|
|
328
|
-
|
329
|
-
|
330
|
-
|
431
|
+
# Click an image element identified by the value of its _src_ attribute and its index
|
432
|
+
# within the array of image elements with src containing <b>+what+</b> and
|
433
|
+
# within the container referred to by <b>+browser+</b>.
|
434
|
+
# @param [Watir::Browser, Watir::Container] browser A reference to the browser window or container element to be tested.
|
435
|
+
# @param [String|Regexp] what A string or a regular expression to be found in the specified attribute that uniquely identifies the element.
|
436
|
+
# @param [Fixnum] index An integer that indicates the index of the element within the array of image elements with src containing <b>+what+</b>.
|
437
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
438
|
+
def click_img_by_src_and_index(browser, what, index, desc = '')
|
439
|
+
msg = "Click image by src='#{what}' and index=#{index}"
|
331
440
|
msg << " #{desc}" if desc.length > 0
|
332
|
-
browser.image(:src =>
|
441
|
+
browser.image(:src => what, :index => index).click
|
333
442
|
if validate(browser, @myName, __LINE__)
|
334
443
|
passed_to_log(msg)
|
335
444
|
true
|
@@ -338,206 +447,122 @@ _Example_
|
|
338
447
|
failed_to_log("Unable to #{msg} '#{$!}'")
|
339
448
|
end
|
340
449
|
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
# html for a link element:
|
362
|
-
# <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
|
363
|
-
click_link_by_text(browser, 'Pickaxe', 'Open the page for the Pickaxe book')
|
364
|
-
|
365
|
-
=end
|
366
|
-
|
367
|
-
def click_link_by_text(browser, strg, desc = '')
|
368
|
-
click(browser, :link, :text, strg, desc)
|
369
|
-
end
|
370
|
-
|
371
|
-
alias click_link click_link_by_text
|
372
|
-
# :category: A_rdoc_test
|
373
|
-
alias click_text click_link_by_text
|
374
|
-
alias click_js_button click_link_by_text
|
375
|
-
|
376
|
-
# :category: User Input
|
377
|
-
def click_link_by_class(browser, strg, desc = '')
|
378
|
-
click(browser, :link, :class, strg, desc)
|
379
|
-
end
|
380
|
-
|
381
|
-
alias click_class click_link_by_class
|
382
|
-
|
383
|
-
# :category: User Input
|
384
|
-
def click_button_no_wait_by_text(browser, strg, desc = '')
|
385
|
-
click_no_wait(browser, :button, :text, strg, desc)
|
386
|
-
end
|
387
|
-
|
388
|
-
# :category: User Input
|
389
|
-
def click_button_no_wait_by_value(browser, strg, desc = '')
|
390
|
-
click_no_wait(browser, :button, :value, strg, desc)
|
391
|
-
end
|
392
|
-
|
393
|
-
# :category: User Input
|
394
|
-
def click_link_by_name_no_wait(browser, strg, desc = '')
|
395
|
-
click_no_wait(browser, :link, :name, strg, desc)
|
396
|
-
end
|
397
|
-
|
398
|
-
alias click_no_wait_name click_link_by_name_no_wait
|
399
|
-
alias click_name_no_wait click_link_by_name_no_wait
|
400
|
-
|
401
|
-
# :category: User Input
|
402
|
-
def click_link_by_text_no_wait(browser, strg, desc = '')
|
403
|
-
click_no_wait(browser, :link, :text, strg, desc)
|
404
|
-
end
|
405
|
-
|
406
|
-
alias click_no_wait_text click_link_by_text_no_wait
|
407
|
-
alias click_text_no_wait click_link_by_text_no_wait
|
408
|
-
|
409
|
-
# :category: User Input
|
410
|
-
def click_span_by_text(browser, strg, desc = '')
|
411
|
-
if not desc and not strg.match(/Save|Open|Close|Submit|Cancel/)
|
412
|
-
desc = 'to navigate to selection'
|
413
|
-
end
|
414
|
-
msg = "Click span containing text '#{strg}'."
|
415
|
-
msg << " #{desc}" if desc.length > 0
|
416
|
-
if validate(browser, @myName, __LINE__)
|
417
|
-
passed_to_log("#{msg}")
|
418
|
-
end
|
419
|
-
rescue
|
420
|
-
failed_to_log("Unable to #{msg}: '#{$!}'")
|
421
|
-
end
|
422
|
-
|
423
|
-
# TODO no logging yet. slow.# :category: User Input
|
424
|
-
def click_span_with_text(browser, trgt, desc = '')
|
425
|
-
msg = "Find and click span containing text '#{trgt}'."
|
426
|
-
msg << " #{desc}" if desc.length > 0
|
427
|
-
spans = browser.spans
|
428
|
-
x = 0
|
429
|
-
spans.each do |span|
|
430
|
-
x += 1
|
431
|
-
debug_to_log("Span #{x}: #{span.text}")
|
432
|
-
aText = span.text
|
433
|
-
if aText and aText.size > 0
|
434
|
-
if aText =~ /#{trgt}/
|
435
|
-
break
|
436
|
-
end
|
437
|
-
end
|
438
|
-
end
|
439
|
-
spans[x].click
|
440
|
-
end
|
441
|
-
|
442
|
-
# :category: User Input
|
443
|
-
def click_link_by_title(browser, strg, desc = '')
|
444
|
-
click(browser, :link, :title, strg, desc)
|
445
|
-
end
|
446
|
-
|
447
|
-
alias click_title click_link_by_title
|
448
|
-
# :category: User Input
|
449
|
-
def click_title_no_wait(browser, strg, desc = '')
|
450
|
-
click_no_wait(browser, :link, :title, strg, desc)
|
451
|
-
end
|
452
|
-
|
453
|
-
# :category: User Input
|
454
|
-
def click_table_row_with_text_by_id(browser, ptrn, strg, column = nil)
|
455
|
-
msg = "id=#{ptrn} row with text='#{strg}"
|
456
|
-
table = get_table_by_id(browser, /#{ptrn}/)
|
450
|
+
# @!endgroup Core
|
451
|
+
|
452
|
+
# @!group Core
|
453
|
+
|
454
|
+
# Click the first row which contains a particular string in a table identified by attribute and value.
|
455
|
+
# A specific column in the table can also be specified.
|
456
|
+
#
|
457
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
458
|
+
# @param [Symbol] how The element attribute used to identify the specific element.
|
459
|
+
# Valid values depend on the kind of element.
|
460
|
+
# Common values: :text, :id, :title, :name, :class, :href (:link only)
|
461
|
+
# @param [String|Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
462
|
+
# @param [String] text Full text string to be found in the table row.
|
463
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
464
|
+
# @param [Fixnum] column Integer indicating the column to search for the text string.
|
465
|
+
# If not supplied all columns will be checked.
|
466
|
+
#
|
467
|
+
def click_table_row_with_text(browser, how, what, text, desc = '', column = nil)
|
468
|
+
msg = build_message("Click row with text #{text} in table :#{how}=>'#{what}.", desc)
|
469
|
+
table = get_table(browser, how, what, desc)
|
457
470
|
if table
|
458
|
-
index = get_index_of_row_with_text(table,
|
471
|
+
index = get_index_of_row_with_text(table, text, column)
|
459
472
|
if index
|
460
473
|
table[index].click
|
461
474
|
if validate(browser, @myName, __LINE__)
|
462
|
-
passed_to_log(
|
475
|
+
passed_to_log(msg)
|
463
476
|
index
|
464
477
|
end
|
465
478
|
else
|
466
|
-
failed_to_log("
|
479
|
+
failed_to_log("#{msg} Row not found.")
|
467
480
|
end
|
468
481
|
else
|
469
|
-
failed_to_log("
|
482
|
+
failed_to_log("#{msg} Table not found.")
|
470
483
|
end
|
471
484
|
rescue
|
472
|
-
failed_to_log("Unable to
|
485
|
+
failed_to_log("Unable to #{msg}: '#{$!}'")
|
473
486
|
end
|
474
487
|
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
488
|
+
# Double click the first row which contains a particular string in a table identified by attribute and value.
|
489
|
+
# A specific column in the table can also be specified.
|
490
|
+
# Uses fire_event method in Watir to send 'onDblClick' event.
|
491
|
+
#
|
492
|
+
# @param (see #click_table_row_with_text)
|
493
|
+
#
|
494
|
+
def double_click_table_row_with_text(browser, how, what, text, desc = '', column = nil)
|
495
|
+
msg = build_message("Double click row with text #{text} in table :#{how}=>'#{what}.", desc)
|
496
|
+
table = get_table(browser, how, what, desc)
|
479
497
|
if table
|
480
|
-
index = get_index_of_row_with_text(table,
|
498
|
+
index = get_index_of_row_with_text(table, text, column)
|
481
499
|
if index
|
482
|
-
table[index].
|
500
|
+
table[index].fire_event('ondblclick')
|
483
501
|
if validate(browser, @myName, __LINE__)
|
484
|
-
passed_to_log(
|
502
|
+
passed_to_log(msg)
|
485
503
|
index
|
486
504
|
end
|
487
505
|
else
|
488
|
-
failed_to_log("
|
506
|
+
failed_to_log("#{msg} Row not found.")
|
489
507
|
end
|
490
508
|
else
|
491
|
-
failed_to_log("
|
509
|
+
failed_to_log("#{msg} Table not found.")
|
492
510
|
end
|
493
511
|
rescue
|
494
|
-
failed_to_log("Unable to
|
512
|
+
failed_to_log("Unable to #{msg}: '#{$!}'")
|
495
513
|
end
|
496
514
|
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
end
|
514
|
-
rescue
|
515
|
-
failed_to_log("Unable to double click table #{msg}: '#{$!}' (#{__LINE__}) ")
|
515
|
+
# @!endgroup Core
|
516
|
+
|
517
|
+
# @!group Tables
|
518
|
+
|
519
|
+
# Click the first row which contains a particular string in a table identified by the value in its _id_ attribute.
|
520
|
+
# A specific column in the table can also be specified.
|
521
|
+
#
|
522
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
523
|
+
# @param [String|Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
524
|
+
# @param [String] text Full text string to be found in the table row.
|
525
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
526
|
+
# @param [Fixnum] column Integer indicating the column to search for the text string.
|
527
|
+
# If not supplied all columns will be checked.
|
528
|
+
#
|
529
|
+
def click_table_row_with_text_by_id(browser, what, text, desc = '', column = nil)
|
530
|
+
click_table_row_with_text(browser, :id, what, text, desc, column)
|
516
531
|
end
|
517
532
|
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
533
|
+
# Click the first row which contains a particular string in a table identified by its index
|
534
|
+
# in the array of tables contained in <b>+browser+</b>.
|
535
|
+
# A specific column in the table can also be specified.
|
536
|
+
#
|
537
|
+
# @param (see #click_table_row_with_text_by_id)
|
538
|
+
#
|
539
|
+
def click_table_row_with_text_by_index(browser, what, text, desc = '', column = nil)
|
540
|
+
click_table_row_with_text(browser, :id, what, text, desc, column)
|
541
|
+
end
|
542
|
+
|
543
|
+
# Double click the first row which contains a particular string in a table identified by the value in its _id_ attribute.
|
544
|
+
# A specific column in the table can also be specified.
|
545
|
+
#
|
546
|
+
# @param (see #click_table_row_with_text_by_id)
|
547
|
+
#
|
548
|
+
def double_click_table_row_with_text_by_id(browser, what, text, desc = '', column = nil)
|
549
|
+
double_click_table_row_with_text(browser, :id, what, text, desc, column)
|
550
|
+
end
|
551
|
+
|
552
|
+
# Double click the first row which contains a particular string in a table identified by its index
|
553
|
+
# in the array of tables contained in <b>+browser+</b>.
|
554
|
+
# A specific column in the table can also be specified.
|
555
|
+
#
|
556
|
+
# @param (see #click_table_row_with_text_by_id)
|
557
|
+
#
|
558
|
+
def double_click_table_row_with_text_by_index(browser, idx, what, column = nil)
|
559
|
+
double_click_table_row_with_text(browser, :index, what, text, desc, column)
|
539
560
|
end
|
540
561
|
|
562
|
+
# @!endgroup Tables
|
563
|
+
|
564
|
+
# @!group Core
|
565
|
+
|
541
566
|
def click_popup_button(title, button, waitTime= 9, user_input=nil)
|
542
567
|
#TODO: is winclicker still viable/available?
|
543
568
|
wc = WinClicker.new
|
@@ -565,240 +590,94 @@ _Example_
|
|
565
590
|
# end
|
566
591
|
end
|
567
592
|
|
568
|
-
def
|
569
|
-
msg
|
570
|
-
list = browser.select_list(how, what)
|
571
|
-
case which
|
572
|
-
when :text
|
573
|
-
list.select(value)
|
574
|
-
when :value
|
575
|
-
list.select_value(value)
|
576
|
-
when :index
|
577
|
-
all = list.getAllContents
|
578
|
-
txt = all[value]
|
579
|
-
list.select(txt)
|
580
|
-
else
|
581
|
-
na = "#{__method__} cannot support select by '#{which}'. (#{msg})"
|
582
|
-
debug_to_log(na, __LINE__, true)
|
583
|
-
raise na
|
584
|
-
end
|
585
|
-
passed_to_log(msg)
|
586
|
-
rescue
|
587
|
-
failed_to_log("#Unable to #{msg}': '#{$!}'")
|
588
|
-
end
|
589
|
-
|
590
|
-
def select_option_from_list(list, what, what_strg, desc = '')
|
593
|
+
def select_option_from_list(list, which, value, desc = '', nofail = false)
|
594
|
+
msg = build_message("Select :#{which}=>'#{value}", desc)
|
591
595
|
ok = true
|
592
|
-
msg = "#{__method__.to_s.titleize} "
|
593
596
|
if list
|
594
|
-
|
595
|
-
case what
|
597
|
+
case which
|
596
598
|
when :text
|
597
|
-
list.select(
|
599
|
+
list.select(value) #TODO: regex?
|
598
600
|
when :value
|
599
|
-
list.select_value(
|
601
|
+
list.select_value(value) #TODO: regex?
|
600
602
|
when :index
|
601
|
-
list.select(list.getAllContents[
|
603
|
+
list.select(list.getAllContents[value.to_i])
|
602
604
|
else
|
603
|
-
msg
|
604
|
-
failed_to_log(msg)
|
605
|
+
failed_to_log("#{msg} Select by #{which} not supported.")
|
605
606
|
ok = false
|
606
607
|
end
|
607
608
|
if ok
|
608
|
-
msg << "#{what}='#{what_strg}' selected. #{desc}"
|
609
609
|
passed_to_log(msg)
|
610
610
|
true
|
611
|
+
else
|
612
|
+
if nofail
|
613
|
+
passed_to_log("#{msg} Option not found. No Fail specified.")
|
614
|
+
true
|
615
|
+
else
|
616
|
+
failed_to_log("#{msg} Option not found.")
|
617
|
+
end
|
611
618
|
end
|
612
619
|
else
|
613
|
-
failed_to_log("#{
|
620
|
+
failed_to_log("#{msg} Select list not found.")
|
614
621
|
end
|
615
622
|
rescue
|
616
|
-
failed_to_log("
|
623
|
+
failed_to_log("Unable to #{msg} '#{$!}'")
|
617
624
|
end
|
618
625
|
|
619
|
-
=
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
*browser* - a reference to the browser window to be tested
|
626
|
-
|
627
|
-
*how* - the element attribute used to identify the specific element. Valid values depend on the kind of element.
|
628
|
-
Common values: :text, :id, :title, :name, :class, :href (:link only)
|
629
|
-
|
630
|
-
*what* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
631
|
-
|
632
|
-
*desc* - a string containing a message or description intended to appear in the log and/or report output
|
633
|
-
|
634
|
-
_Example_
|
626
|
+
def select_option(browser, how, what, which, value, desc = '', nofail = false)
|
627
|
+
list = browser.select_list(how, what)
|
628
|
+
msg = build_message(" from list with :#{how}=>'#{what}", desc)
|
629
|
+
select_option_from_list(list, which, value, msg, nofail)
|
630
|
+
end
|
635
631
|
|
636
|
-
|
637
|
-
# <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
|
638
|
-
click_no_wait(browser, :link, :text, 'Pickaxe')
|
632
|
+
# @!endgroup Core
|
639
633
|
|
640
|
-
|
634
|
+
# @!group Select
|
641
635
|
|
642
|
-
def select_option_by_id_and_option_text(browser,
|
643
|
-
|
644
|
-
msg << " #{desc}" if desc.length > 0
|
645
|
-
list = browser.select_list(:id, strg)
|
646
|
-
list.select(option)
|
647
|
-
# browser.select_list(:id, strg).select(option) #(browser.select_list(:id, strg).getAllContents[option])
|
648
|
-
if validate(browser, @myName, __LINE__)
|
649
|
-
passed_to_log(msg)
|
650
|
-
true
|
651
|
-
end
|
652
|
-
rescue
|
653
|
-
if !nofail
|
654
|
-
failed_to_log("#{msg} '#{$!}'")
|
655
|
-
end
|
636
|
+
def select_option_by_id_and_option_text(browser, what, option, nofail = false, desc = '')
|
637
|
+
select_option(browser, :id, what, :text, option, desc, nofail)
|
656
638
|
end
|
657
639
|
|
658
640
|
alias select_option_by_id select_option_by_id_and_option_text
|
659
641
|
alias select_option_by_id_and_text select_option_by_id_and_option_text
|
660
642
|
|
661
|
-
def select_option_by_name_and_option_text(browser,
|
662
|
-
|
663
|
-
msg << " #{desc}" if desc.length > 0
|
664
|
-
begin
|
665
|
-
list = browser.select_list(:name, strg)
|
666
|
-
rescue => e
|
667
|
-
if not rescue_me(e, __method__, "#{__LINE__}: select_list(:name,'#{strg}')", "#{browser.class}")
|
668
|
-
raise e
|
669
|
-
end
|
670
|
-
end
|
671
|
-
begin
|
672
|
-
list.select(option)
|
673
|
-
rescue => e
|
674
|
-
if not rescue_me(e, __method__, "#{__LINE__}: select_list#select('#{option}')", "#{browser.class}")
|
675
|
-
raise e
|
676
|
-
end
|
677
|
-
end
|
678
|
-
if validate(browser, @myName, __LINE__)
|
679
|
-
passed_to_log(msg)
|
680
|
-
true
|
681
|
-
end
|
682
|
-
rescue
|
683
|
-
failed_to_log("#{msg} '#{$!}'")
|
643
|
+
def select_option_by_name_and_option_text(browser, what, option, desc = '')
|
644
|
+
select_option(browser, :name, what, :text, option, desc)
|
684
645
|
end
|
685
646
|
|
686
647
|
alias select_option_by_name select_option_by_name_and_option_text
|
687
648
|
|
688
|
-
def select_option_by_title_and_option_text(browser,
|
689
|
-
|
690
|
-
msg << " #{desc}" if desc.length > 0
|
691
|
-
browser.select_list(:title, strg).select(option)
|
692
|
-
if validate(browser, @myName, __LINE__)
|
693
|
-
passed_to_log(msg)
|
694
|
-
end
|
695
|
-
rescue
|
696
|
-
failed_to_log("#{msg} '#{$!}'")
|
649
|
+
def select_option_by_title_and_option_text(browser, what, option, desc = '')
|
650
|
+
select_option(browser, :title, what, :text, option, desc)
|
697
651
|
end
|
698
652
|
|
699
|
-
def select_option_by_class_and_option_text(browser,
|
700
|
-
|
701
|
-
msg << " #{desc}" if desc.length > 0
|
702
|
-
browser.select_list(:class, strg).select(option)
|
703
|
-
if validate(browser, @myName, __LINE__)
|
704
|
-
passed_to_log(msg)
|
705
|
-
true
|
706
|
-
end
|
707
|
-
rescue
|
708
|
-
failed_to_log("#{msg} '#{$!}'")
|
653
|
+
def select_option_by_class_and_option_text(browser, what, option, desc = '')
|
654
|
+
select_option(browser, :class, what, :text, option, desc)
|
709
655
|
end
|
710
656
|
|
711
|
-
def select_option_by_name_and_option_value(browser,
|
712
|
-
|
713
|
-
msg << " #{desc}" if desc.length > 0
|
714
|
-
begin
|
715
|
-
list = browser.select_list(:name, strg)
|
716
|
-
rescue => e
|
717
|
-
if not rescue_me(e, __method__, "#{__LINE__}: select_list(:name,'#{strg}')", "#{browser.class}")
|
718
|
-
raise e
|
719
|
-
end
|
720
|
-
end
|
721
|
-
begin
|
722
|
-
list.select_value(option)
|
723
|
-
rescue => e
|
724
|
-
if not rescue_me(e, __method__, "#{__LINE__}: select_list#select_value('#{option}')", "#{browser.class}")
|
725
|
-
raise e
|
726
|
-
end
|
727
|
-
end
|
728
|
-
if validate(browser, @myName, __LINE__)
|
729
|
-
passed_to_log(msg)
|
730
|
-
true
|
731
|
-
end
|
732
|
-
rescue
|
733
|
-
failed_to_log("#{msg} '#{$!}'")
|
657
|
+
def select_option_by_name_and_option_value(browser, what, option, desc = '')
|
658
|
+
select_option(browser, :name, what, :value, option, desc)
|
734
659
|
end
|
735
660
|
|
736
|
-
def select_option_by_id_and_option_value(browser,
|
737
|
-
|
738
|
-
msg << " #{desc}" if desc.length > 0
|
739
|
-
begin
|
740
|
-
list = browser.select_list(:id, strg)
|
741
|
-
rescue => e
|
742
|
-
if not rescue_me(e, __method__, "#{__LINE__}: select_list(:text,'#{strg}')", "#{browser.class}")
|
743
|
-
raise e
|
744
|
-
end
|
745
|
-
end
|
746
|
-
sleep(0.5) unless @targetBrowser.abbrev == 'IE'
|
747
|
-
begin
|
748
|
-
list.select_value(option)
|
749
|
-
rescue => e
|
750
|
-
if not rescue_me(e, __method__, "#{__LINE__}: select_list#select_value('#{option}')", "#{browser.class}")
|
751
|
-
raise e
|
752
|
-
end
|
753
|
-
end
|
754
|
-
if validate(browser, @myName, __LINE__)
|
755
|
-
passed_to_log(msg)
|
756
|
-
true
|
757
|
-
end
|
758
|
-
rescue
|
759
|
-
failed_to_log("#{msg} '#{$!}'")
|
661
|
+
def select_option_by_id_and_option_value(browser, what, option, desc = '')
|
662
|
+
select_option(browser, :id, what, :value, option, desc)
|
760
663
|
end
|
761
664
|
|
762
|
-
def select_option_by_id_and_index(browser,
|
763
|
-
|
764
|
-
msg << " #{desc}" if desc.length > 0
|
765
|
-
list = browser.select_list(:id, strg)
|
766
|
-
all = list.getAllContents
|
767
|
-
txt = all[idx]
|
768
|
-
browser.select_list(:id, strg).set(browser.select_list(:id, strg).getAllContents[idx])
|
769
|
-
if validate(browser, @myName, __LINE__)
|
770
|
-
passed_to_log(msg)
|
771
|
-
true
|
772
|
-
end
|
773
|
-
rescue
|
774
|
-
failed_to_log("#{msg} '#{$!}'")
|
665
|
+
def select_option_by_id_and_index(browser, what, option, desc = '')
|
666
|
+
select_option(browser, :id, what, :index, option, desc)
|
775
667
|
end
|
776
668
|
|
777
|
-
def select_option_by_name_and_index(browser,
|
778
|
-
|
779
|
-
msg = "Select list name=#{strg} index='#{idx}' selected."
|
780
|
-
msg << " #{desc}" if desc.length > 0
|
781
|
-
browser.select_list(:name, strg).set(browser.select_list(:name, strg).getAllContents[idx])
|
782
|
-
if validate(browser, @myName, __LINE__)
|
783
|
-
passed_to_log(msg)
|
784
|
-
true
|
785
|
-
end
|
786
|
-
rescue
|
787
|
-
failed_to_log("#{msg} '#{$!}'")
|
669
|
+
def select_option_by_name_and_index(browser, what, option, desc = '')
|
670
|
+
select_option(browser, :name, what, :index, option, desc)
|
788
671
|
end
|
789
672
|
|
790
|
-
def select_option_by_xpath_and_index(browser,
|
791
|
-
|
792
|
-
msg << " #{desc}" if desc.length > 0
|
793
|
-
browser.select_list(:xpath, strg).set(browser.select_list(:xpath, strg).getAllContents[idx])
|
794
|
-
if validate(browser, nil, __LINE__)
|
795
|
-
passed_to_log(msg)
|
796
|
-
true
|
797
|
-
end
|
798
|
-
rescue
|
799
|
-
failed_to_log("#{msg} '#{$!}'")
|
673
|
+
def select_option_by_xpath_and_index(browser, what, option, desc = '')
|
674
|
+
select_option(browser, :xpath, what, :index, option, desc)
|
800
675
|
end
|
801
676
|
|
677
|
+
# @!endgroup Select
|
678
|
+
|
679
|
+
# @!group Core
|
680
|
+
|
802
681
|
def set(browser, element, how, what, value = nil, desc = '')
|
803
682
|
msg = "Set #{element} #{how}=>'#{what}' "
|
804
683
|
msg << ", :value=>#{value} " if value
|
@@ -819,28 +698,50 @@ _Example_
|
|
819
698
|
failed_to_log("#{msg} '#{$!}'")
|
820
699
|
end
|
821
700
|
|
701
|
+
def set_file_field(browser, how, what, filespec, desc = '')
|
702
|
+
msg = "Set file field #{how}=>#{what} to '#{filespec}."
|
703
|
+
msg << " #{desc}" if desc.length > 0
|
704
|
+
ff = browser.file_field(how, what)
|
705
|
+
if ff
|
706
|
+
ff.set filespec
|
707
|
+
sleep_for(8)
|
708
|
+
if validate(browser, @myName, __LINE__)
|
709
|
+
passed_to_log(msg)
|
710
|
+
true
|
711
|
+
end
|
712
|
+
else
|
713
|
+
failed_to_log("#{msg} File field not found.")
|
714
|
+
end
|
715
|
+
rescue
|
716
|
+
failed_to_log("Unable to #{msg} '#{$!}'")
|
717
|
+
end
|
718
|
+
|
719
|
+
# @!endgroup Core
|
720
|
+
|
721
|
+
# @!group Set
|
722
|
+
|
822
723
|
def set_checkbox(browser, how, what, value, desc = '')
|
823
724
|
set(browser, :checkbox, how, what, value, desc)
|
824
725
|
end
|
825
726
|
|
826
|
-
def set_checkbox_by_class(browser,
|
827
|
-
set(browser, :checkbox, :class,
|
727
|
+
def set_checkbox_by_class(browser, what, value = nil, desc = '')
|
728
|
+
set(browser, :checkbox, :class, what, value, desc)
|
828
729
|
end
|
829
730
|
|
830
|
-
def set_checkbox_by_id(browser,
|
831
|
-
set(browser, :checkbox, :id,
|
731
|
+
def set_checkbox_by_id(browser, what, value = nil, desc = '')
|
732
|
+
set(browser, :checkbox, :id, what, value, desc)
|
832
733
|
end
|
833
734
|
|
834
|
-
def set_checkbox_by_name(browser,
|
835
|
-
set(browser, :checkbox, :name,
|
735
|
+
def set_checkbox_by_name(browser, what, value = nil, desc = '')
|
736
|
+
set(browser, :checkbox, :name, what, value, desc)
|
836
737
|
end
|
837
738
|
|
838
|
-
def set_checkbox_by_title(browser,
|
839
|
-
set(browser, :checkbox, :title,
|
739
|
+
def set_checkbox_by_title(browser, what, value = nil, desc = '')
|
740
|
+
set(browser, :checkbox, :title, what, value, desc)
|
840
741
|
end
|
841
742
|
|
842
|
-
def set_checkbox_by_value(browser,
|
843
|
-
set(browser, :checkbox, :value,
|
743
|
+
def set_checkbox_by_value(browser, what, desc = '')
|
744
|
+
set(browser, :checkbox, :value, what, nil, desc)
|
844
745
|
end
|
845
746
|
|
846
747
|
def set_radio(browser, how, what, value = nil, desc = '')
|
@@ -859,28 +760,28 @@ _Example_
|
|
859
760
|
failed_to_log("#{msg} '#{$!}'")
|
860
761
|
end
|
861
762
|
|
862
|
-
def set_radio_by_class(browser,
|
863
|
-
set(browser, :radio, :class,
|
763
|
+
def set_radio_by_class(browser, what, value = nil, desc = '')
|
764
|
+
set(browser, :radio, :class, what, value, desc)
|
864
765
|
end
|
865
766
|
|
866
|
-
def set_radio_by_id(browser,
|
867
|
-
set(browser, :radio, :id,
|
767
|
+
def set_radio_by_id(browser, what, value = nil, desc = '')
|
768
|
+
set(browser, :radio, :id, what, value, desc)
|
868
769
|
end
|
869
770
|
|
870
771
|
def set_radio_by_index(browser, index, desc = '')
|
871
772
|
set(browser, :radio, :index, index, value, desc)
|
872
773
|
end
|
873
774
|
|
874
|
-
def set_radio_by_name(browser,
|
875
|
-
set(browser, :radio, :name,
|
775
|
+
def set_radio_by_name(browser, what, value = nil, desc = '')
|
776
|
+
set(browser, :radio, :name, what, value, desc)
|
876
777
|
end
|
877
778
|
|
878
|
-
def set_radio_by_title(browser,
|
879
|
-
set(browser, :radio, :title,
|
779
|
+
def set_radio_by_title(browser, what, value = nil, desc = '')
|
780
|
+
set(browser, :radio, :title, what, value, desc)
|
880
781
|
end
|
881
782
|
|
882
|
-
def set_radio_by_value(browser,
|
883
|
-
set(browser, :radio, :value,
|
783
|
+
def set_radio_by_value(browser, what, desc = '')
|
784
|
+
set(browser, :radio, :value, what, nil, desc)
|
884
785
|
end
|
885
786
|
|
886
787
|
def set_radio_no_wait_by_index(browser, index, desc = '')
|
@@ -913,10 +814,22 @@ _Example_
|
|
913
814
|
set_radio_two_attributes(browser, :value, value, :index, index, desc)
|
914
815
|
end
|
915
816
|
|
916
|
-
def set_radio_by_name_and_value(browser,
|
917
|
-
set_radio(browser, :name,
|
817
|
+
def set_radio_by_name_and_value(browser, what, value, desc = '')
|
818
|
+
set_radio(browser, :name, what, value, desc)
|
819
|
+
end
|
820
|
+
|
821
|
+
def set_file_field_by_name(browser, what, path, desc = '')
|
822
|
+
set_file_field(browser, :name, what, path, desc)
|
918
823
|
end
|
919
824
|
|
825
|
+
def set_file_field_by_id(browser, what, path, desc = '')
|
826
|
+
set_file_field(browser, :id, what, path, desc)
|
827
|
+
end
|
828
|
+
|
829
|
+
# @!endgroup Set
|
830
|
+
|
831
|
+
# @!group Core
|
832
|
+
|
920
833
|
def clear(browser, element, how, what, value = nil, desc = '')
|
921
834
|
msg = "Clear #{element} #{how}=>'#{what}' "
|
922
835
|
msg << ", value=>#{value} " if value
|
@@ -939,22 +852,28 @@ _Example_
|
|
939
852
|
failed_to_log("#{msg} '#{$!}'")
|
940
853
|
end
|
941
854
|
|
855
|
+
# @!endgroup Core
|
856
|
+
|
857
|
+
# @!group Clear
|
858
|
+
|
942
859
|
def clear_checkbox(browser, how, what, value = nil, desc = '')
|
943
860
|
clear(browser, :checkbox, how, what, value, desc)
|
944
861
|
end
|
945
862
|
|
946
|
-
def clear_checkbox_by_name(browser,
|
947
|
-
clear(browser, :checkbox, :name,
|
863
|
+
def clear_checkbox_by_name(browser, what, value = nil, desc = '')
|
864
|
+
clear(browser, :checkbox, :name, what, value, desc)
|
948
865
|
end
|
949
866
|
|
950
|
-
def clear_checkbox_by_id(browser,
|
951
|
-
clear(browser, :checkbox, :id,
|
867
|
+
def clear_checkbox_by_id(browser, what, value = nil, desc = '')
|
868
|
+
clear(browser, :checkbox, :id, what, value, desc)
|
952
869
|
end
|
953
870
|
|
954
871
|
def clear_radio(browser, how, what, value = nil, desc = '')
|
955
872
|
clear(browser, :radio, how, what, value, desc)
|
956
873
|
end
|
957
874
|
|
875
|
+
# @!endgroup Clear
|
876
|
+
|
958
877
|
# Set skip_value_check = true when string is altered by application and/or
|
959
878
|
# this method will be followed by validate_text
|
960
879
|
def clear_textfield(browser, how, which, skip_value_check = false)
|
@@ -981,32 +900,6 @@ _Example_
|
|
981
900
|
failed_to_log("Textfield id='#{id}' could not be cleared: '#{$!}'. (#{__LINE__})")
|
982
901
|
end
|
983
902
|
|
984
|
-
def set_file_field(browser, how, what, filespec, desc = '')
|
985
|
-
msg = "Set file field #{how}=>#{what} to '#{filespec}."
|
986
|
-
msg << " #{desc}" if desc.length > 0
|
987
|
-
ff = browser.file_field(how, what)
|
988
|
-
if ff
|
989
|
-
ff.set filespec
|
990
|
-
sleep_for(8)
|
991
|
-
if validate(browser, @myName, __LINE__)
|
992
|
-
passed_to_log(msg)
|
993
|
-
true
|
994
|
-
end
|
995
|
-
else
|
996
|
-
failed_to_log("#{msg} File field not found.")
|
997
|
-
end
|
998
|
-
rescue
|
999
|
-
failed_to_log("Unable to #{msg} '#{$!}'")
|
1000
|
-
end
|
1001
|
-
|
1002
|
-
def set_file_field_by_name(browser, strg, path, desc = '')
|
1003
|
-
set_file_field(browser, :name, strg, path, desc)
|
1004
|
-
end
|
1005
|
-
|
1006
|
-
def set_file_field_by_id(browser, strg, path, desc = '')
|
1007
|
-
set_file_field(browser, :id, strg, path, desc)
|
1008
|
-
end
|
1009
|
-
|
1010
903
|
=begin rdoc
|
1011
904
|
:category: A_rdoc_test
|
1012
905
|
Enter a string into a text field element identified by an attribute type and a value.
|
@@ -1098,7 +991,7 @@ _Example_
|
|
1098
991
|
|
1099
992
|
=begin rdoc
|
1100
993
|
:category: A_rdoc_test
|
1101
|
-
Enter a string into a text field element identified by the value in its id attribute.
|
994
|
+
Enter a string into a text field element identifiedelement identified by the value in its id attribute.
|
1102
995
|
|
1103
996
|
_Parameters_::
|
1104
997
|
|
@@ -1128,8 +1021,8 @@ _Example_
|
|
1128
1021
|
set_text_field(browser, :title, title, value, desc, skip_value_check)
|
1129
1022
|
end
|
1130
1023
|
|
1131
|
-
def set_textfield_by_class(browser,
|
1132
|
-
set_text_field(browser, :class,
|
1024
|
+
def set_textfield_by_class(browser, what, value, desc = '', skip_value_check = false)
|
1025
|
+
set_text_field(browser, :class, what, value, desc, skip_value_check)
|
1133
1026
|
end
|
1134
1027
|
|
1135
1028
|
=begin rdoc
|
@@ -1169,34 +1062,26 @@ _Example_
|
|
1169
1062
|
failed_to_log("Unable to '#{msg}': '#{$!}'")
|
1170
1063
|
end
|
1171
1064
|
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
_Example_
|
1193
|
-
|
1194
|
-
# html for a link element:
|
1195
|
-
# <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
|
1196
|
-
fire_event(browser, :link, :text, 'Pickaxe', 'onMouseOver')
|
1197
|
-
|
1198
|
-
=end
|
1199
|
-
|
1065
|
+
# @!group Core
|
1066
|
+
|
1067
|
+
# Fire an event on a specific DOM element identified by one of its attributes and that attribute's value.
|
1068
|
+
#
|
1069
|
+
# @example
|
1070
|
+
# # html for a link element:
|
1071
|
+
# # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
|
1072
|
+
#
|
1073
|
+
# fire_event(browser, :link, :text, 'Pickaxe', 'onMouseOver')
|
1074
|
+
#
|
1075
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
1076
|
+
# @param [Symbol] element The kind of element to click. Must be one of the elements recognized by Watir.
|
1077
|
+
# Some common values are :link, :button, :image, :div, :span.
|
1078
|
+
# @param [Symbol] how The element attribute used to identify the specific element.
|
1079
|
+
# Valid values depend on the kind of element.
|
1080
|
+
# Common values: :text, :id, :title, :name, :class, :href (:link only)
|
1081
|
+
# @param [String|Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
1082
|
+
# @param [String] event A string identifying the event to be fired.
|
1083
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
1084
|
+
#
|
1200
1085
|
def fire_event(browser, element, how, what, event, desc = '')
|
1201
1086
|
msg = "#{element.to_s.titlecase}: #{how}=>'#{what}' event:'#{event}'"
|
1202
1087
|
msg1 = "#{element.to_s.titlecase}(#{how}, '#{what}')"
|
@@ -1227,28 +1112,60 @@ _Example_
|
|
1227
1112
|
rescue
|
1228
1113
|
failed_to_log("Unable to fire event: #{msg}. '#{$!}' #{desc}")
|
1229
1114
|
end
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1115
|
+
|
1116
|
+
# @!endgroup Core
|
1117
|
+
|
1118
|
+
# @!group Fire Event
|
1119
|
+
|
1120
|
+
# Fire an event on a link element identified by the value in its text (innerHTML)
|
1121
|
+
#
|
1122
|
+
# @example
|
1123
|
+
# # html for a link element:
|
1124
|
+
# # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
|
1125
|
+
#
|
1126
|
+
# fire_event_on_link_by_text(browser, 'Pickaxe', 'onMouseOver')
|
1127
|
+
#
|
1128
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
1129
|
+
# @param [String|Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
1130
|
+
# @param [String] event A string identifying the event to be fired.
|
1131
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
1132
|
+
#
|
1133
|
+
def fire_event_on_link_by_text(browser, what, event, desc = '')
|
1134
|
+
fire_event(browser, :link, :text, what, event, desc)
|
1233
1135
|
end
|
1234
1136
|
|
1235
1137
|
alias fire_event_text fire_event_on_link_by_text
|
1236
1138
|
alias fire_event_by_text fire_event_on_link_by_text
|
1237
1139
|
|
1238
|
-
|
1239
|
-
|
1140
|
+
# Fire an event on a link element identified by the value in its _id_ attribute.
|
1141
|
+
#
|
1142
|
+
# @example
|
1143
|
+
# # html for a link element:
|
1144
|
+
# # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a>
|
1145
|
+
#
|
1146
|
+
# fire_event_on_link_by_id(browser, 'one', 'onMouseOver')
|
1147
|
+
#
|
1148
|
+
# @param (see #fire_event_on_link_by_text)
|
1149
|
+
#
|
1150
|
+
def fire_event_on_link_by_id(browser, what, event, desc = '')
|
1151
|
+
fire_event(browser, :link, :id, what, event, desc)
|
1240
1152
|
end
|
1241
1153
|
|
1242
1154
|
alias fire_event_id fire_event_on_link_by_id
|
1243
1155
|
alias fire_event_by_id fire_event_on_link_by_id
|
1244
1156
|
|
1245
|
-
|
1246
|
-
|
1157
|
+
# Fire an event on a image element identified by the value in its _src_ attribute.
|
1158
|
+
# Take care to escape characters in the source url that are reserved by Regexp.
|
1159
|
+
# @param (see #fire_event_on_link_by_text)
|
1160
|
+
#
|
1161
|
+
def fire_event_on_image_by_src(browser, what, event, desc = '')
|
1162
|
+
fire_event(browser, :img, :src, what, event, desc)
|
1247
1163
|
end
|
1248
1164
|
|
1249
1165
|
alias fire_event_src fire_event_on_image_by_src
|
1250
1166
|
alias fire_event_image_by_src fire_event_on_image_by_src
|
1251
1167
|
|
1168
|
+
# @!endgroup Fire Event
|
1252
1169
|
|
1253
1170
|
end
|
1254
1171
|
end
|