page-object 2.2.3 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.coveralls.yml +1 -1
- data/.gitignore +8 -8
- data/.rspec +2 -2
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/.travis.yml +17 -17
- data/ChangeLog +928 -899
- data/Gemfile +13 -13
- data/Guardfile +20 -20
- data/LICENSE +20 -20
- data/README.md +114 -114
- data/Rakefile +29 -29
- data/cucumber.yml +8 -8
- data/lib/page-object.rb +431 -420
- data/lib/page-object/accessors.rb +1201 -1175
- data/lib/page-object/element_locators.rb +21 -21
- data/lib/page-object/elements.rb +62 -61
- data/lib/page-object/elements/area.rb +9 -9
- data/lib/page-object/elements/audio.rb +9 -9
- data/lib/page-object/elements/bold.rb +9 -9
- data/lib/page-object/elements/button.rb +12 -12
- data/lib/page-object/elements/canvas.rb +10 -10
- data/lib/page-object/elements/check_box.rb +9 -9
- data/lib/page-object/elements/date_field.rb +10 -0
- data/lib/page-object/elements/div.rb +9 -9
- data/lib/page-object/elements/element.rb +212 -216
- data/lib/page-object/elements/file_field.rb +9 -9
- data/lib/page-object/elements/form.rb +9 -9
- data/lib/page-object/elements/heading.rb +14 -14
- data/lib/page-object/elements/hidden_field.rb +9 -9
- data/lib/page-object/elements/image.rb +10 -10
- data/lib/page-object/elements/italic.rb +9 -9
- data/lib/page-object/elements/label.rb +9 -9
- data/lib/page-object/elements/link.rb +9 -9
- data/lib/page-object/elements/list_item.rb +9 -9
- data/lib/page-object/elements/media.rb +11 -11
- data/lib/page-object/elements/option.rb +9 -9
- data/lib/page-object/elements/ordered_list.rb +43 -43
- data/lib/page-object/elements/paragraph.rb +9 -9
- data/lib/page-object/elements/radio_button.rb +9 -9
- data/lib/page-object/elements/select_list.rb +42 -42
- data/lib/page-object/elements/span.rb +9 -9
- data/lib/page-object/elements/table.rb +85 -68
- data/lib/page-object/elements/table_cell.rb +10 -10
- data/lib/page-object/elements/table_row.rb +52 -52
- data/lib/page-object/elements/text_area.rb +9 -9
- data/lib/page-object/elements/text_field.rb +10 -10
- data/lib/page-object/elements/unordered_list.rb +42 -42
- data/lib/page-object/elements/video.rb +9 -9
- data/lib/page-object/indexed_properties.rb +41 -41
- data/lib/page-object/javascript/angularjs.rb +14 -14
- data/lib/page-object/javascript/jquery.rb +14 -14
- data/lib/page-object/javascript/prototype.rb +14 -14
- data/lib/page-object/javascript/yui.rb +18 -18
- data/lib/page-object/javascript_framework_facade.rb +80 -80
- data/lib/page-object/locator_generator.rb +183 -182
- data/lib/page-object/nested_elements.rb +17 -17
- data/lib/page-object/page_factory.rb +108 -108
- data/lib/page-object/page_populator.rb +105 -93
- data/lib/page-object/platforms/watir.rb +50 -50
- data/lib/page-object/platforms/watir/page_object.rb +1155 -1124
- data/lib/page-object/section_collection.rb +16 -16
- data/lib/page-object/version.rb +4 -4
- data/lib/page-object/widgets.rb +98 -98
- data/page-object.gemspec +31 -32
- metadata +12 -26
@@ -1,50 +1,50 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Platforms
|
3
|
-
module Watir
|
4
|
-
|
5
|
-
def self.create_page_object(browser)
|
6
|
-
browser = selenium_browser(browser) unless watir?(browser)
|
7
|
-
return Watir::PageObject.new(browser)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.is_for?(browser)
|
11
|
-
require 'watir'
|
12
|
-
watir?(browser) || selenium?(browser)
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.browser_for root
|
16
|
-
return watir_browser(root) if watir?(root)
|
17
|
-
return selenium_browser(root) if selenium?(root)
|
18
|
-
nil
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.root_element_for root
|
22
|
-
Elements::Element.new(root) if is_for?(root)
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.browser_root_for browser
|
26
|
-
browser.element
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def self.watir_browser(root)
|
32
|
-
return root if root.is_a?(::Watir::Browser)
|
33
|
-
root.browser
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.selenium_browser(root)
|
37
|
-
return ::Watir::Browser.new(root) if root.is_a?(::Selenium::WebDriver::Driver)
|
38
|
-
::Watir::Browser.new(Selenium::WebDriver::Driver.new(root.send(:bridge)))
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.watir?(browser)
|
42
|
-
browser.is_a?(::Watir::Browser) || browser.is_a?(::Watir::HTMLElement)
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.selenium?(browser)
|
46
|
-
browser.is_a?(::Selenium::WebDriver::Driver) || browser.is_a?(::Selenium::WebDriver::Element)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
1
|
+
module PageObject
|
2
|
+
module Platforms
|
3
|
+
module Watir
|
4
|
+
|
5
|
+
def self.create_page_object(browser)
|
6
|
+
browser = selenium_browser(browser) unless watir?(browser)
|
7
|
+
return Watir::PageObject.new(browser)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.is_for?(browser)
|
11
|
+
require 'watir'
|
12
|
+
watir?(browser) || selenium?(browser)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.browser_for root
|
16
|
+
return watir_browser(root) if watir?(root)
|
17
|
+
return selenium_browser(root) if selenium?(root)
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.root_element_for root
|
22
|
+
Elements::Element.new(root) if is_for?(root)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.browser_root_for browser
|
26
|
+
browser.element
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def self.watir_browser(root)
|
32
|
+
return root if root.is_a?(::Watir::Browser)
|
33
|
+
root.browser
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.selenium_browser(root)
|
37
|
+
return ::Watir::Browser.new(root) if root.is_a?(::Selenium::WebDriver::Driver)
|
38
|
+
::Watir::Browser.new(Selenium::WebDriver::Driver.new(root.send(:bridge)))
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.watir?(browser)
|
42
|
+
browser.is_a?(::Watir::Browser) || browser.is_a?(::Watir::HTMLElement)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.selenium?(browser)
|
46
|
+
browser.is_a?(::Selenium::WebDriver::Driver) || browser.is_a?(::Selenium::WebDriver::Element)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,1124 +1,1155 @@
|
|
1
|
-
require 'page-object/elements'
|
2
|
-
|
3
|
-
|
4
|
-
module PageObject
|
5
|
-
module Platforms
|
6
|
-
module Watir
|
7
|
-
|
8
|
-
#
|
9
|
-
# Watir implementation of the page object platform driver. You should not use the
|
10
|
-
# class directly. Instead you should include the PageObject module in your page object
|
11
|
-
# and use the methods dynamically added from the PageObject::Accessors module.
|
12
|
-
#
|
13
|
-
class PageObject
|
14
|
-
attr_reader :browser
|
15
|
-
|
16
|
-
def self.define_widget_accessors(widget_tag, widget_class, base_element_tag)
|
17
|
-
define_widget_singular_accessor(base_element_tag, widget_class, widget_tag)
|
18
|
-
define_widget_multiple_accessor(base_element_tag, widget_class, widget_tag)
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize(browser)
|
22
|
-
@browser = browser
|
23
|
-
end
|
24
|
-
|
25
|
-
#
|
26
|
-
# platform method to navigate to a provided url
|
27
|
-
# See PageObject#navigate_to
|
28
|
-
#
|
29
|
-
def navigate_to(url)
|
30
|
-
@browser.goto url
|
31
|
-
end
|
32
|
-
|
33
|
-
#
|
34
|
-
# platform method to get the current url
|
35
|
-
# See PageObject#current_url
|
36
|
-
#
|
37
|
-
def current_url
|
38
|
-
@browser.url
|
39
|
-
end
|
40
|
-
|
41
|
-
#
|
42
|
-
# platform method to retrieve the text from the current page
|
43
|
-
# See PageObject#text
|
44
|
-
#
|
45
|
-
def text
|
46
|
-
@browser.text
|
47
|
-
end
|
48
|
-
|
49
|
-
#
|
50
|
-
# platform method to retrieve the html for the current page
|
51
|
-
# See PageObject#html
|
52
|
-
#
|
53
|
-
def html
|
54
|
-
@browser.html
|
55
|
-
end
|
56
|
-
|
57
|
-
#
|
58
|
-
# platform method to retrieve the title for the current page
|
59
|
-
# See PageObject#title
|
60
|
-
#
|
61
|
-
def title
|
62
|
-
@browser.title
|
63
|
-
end
|
64
|
-
|
65
|
-
#
|
66
|
-
# platform method to wait for a block to return true
|
67
|
-
# See PageObject#wait_until
|
68
|
-
def wait_until(timeout, message = nil, &block)
|
69
|
-
@browser.wait_until(timeout: timeout, message: message, &block)
|
70
|
-
end
|
71
|
-
|
72
|
-
#
|
73
|
-
# platform method to handle an alert popup
|
74
|
-
# See PageObject#alert
|
75
|
-
#
|
76
|
-
def alert(frame=nil, &block)
|
77
|
-
switch_to_frame(frame)
|
78
|
-
yield
|
79
|
-
value = nil
|
80
|
-
if @browser.alert.exists?
|
81
|
-
value = @browser.alert.text
|
82
|
-
@browser.alert.ok
|
83
|
-
end
|
84
|
-
switch_to_default_content(frame)
|
85
|
-
value
|
86
|
-
end
|
87
|
-
|
88
|
-
#
|
89
|
-
# platform method to handle a confirm popup
|
90
|
-
# See PageObject#confirm
|
91
|
-
#
|
92
|
-
def confirm(response, frame=nil, &block)
|
93
|
-
switch_to_frame(frame)
|
94
|
-
yield
|
95
|
-
value = nil
|
96
|
-
if @browser.alert.exists?
|
97
|
-
value = @browser.alert.text
|
98
|
-
response ? @browser.alert.ok : @browser.alert.close
|
99
|
-
end
|
100
|
-
switch_to_default_content(frame)
|
101
|
-
value
|
102
|
-
end
|
103
|
-
|
104
|
-
#
|
105
|
-
# platform method to handle a prompt popup
|
106
|
-
# See PageObject#prompt
|
107
|
-
#
|
108
|
-
def prompt(answer, frame=nil, &block)
|
109
|
-
switch_to_frame(frame)
|
110
|
-
@browser.wd.execute_script "window.prompt = function(text, value) { window.__lastWatirPrompt = { message: text, default_value: value }; return #{answer}; }"
|
111
|
-
yield
|
112
|
-
result = @browser.wd.execute_script "return window.__lastWatirPrompt"
|
113
|
-
switch_to_default_content(frame)
|
114
|
-
result && result.dup.each_key { |k| result[k.to_sym] = result.delete(k) }
|
115
|
-
result
|
116
|
-
end
|
117
|
-
|
118
|
-
#
|
119
|
-
# platform method to execute javascript on the browser
|
120
|
-
# See PageObject#execute_script
|
121
|
-
#
|
122
|
-
def execute_script(script, *args)
|
123
|
-
@browser.execute_script(script, *args)
|
124
|
-
end
|
125
|
-
|
126
|
-
#
|
127
|
-
# platform method to handle attaching to a running window
|
128
|
-
# See PageObject#attach_to_window
|
129
|
-
#
|
130
|
-
def attach_to_window(identifier, &block)
|
131
|
-
win_id = {identifier.keys.first => /#{Regexp.escape(identifier.values.first)}/}
|
132
|
-
@browser.window(win_id).use &block
|
133
|
-
end
|
134
|
-
|
135
|
-
def element_with_focus
|
136
|
-
element = browser.execute_script("return document.activeElement")
|
137
|
-
type = element.type.to_sym if element.tag_name.to_sym == :input
|
138
|
-
cls = ::PageObject::Elements.element_class_for(element.tag_name, type)
|
139
|
-
cls.new(element)
|
140
|
-
end
|
141
|
-
|
142
|
-
#
|
143
|
-
# platform method to switch to a frame and execute a block
|
144
|
-
# See PageObject#in_frame
|
145
|
-
#
|
146
|
-
def in_frame(identifier, frame=nil, &block)
|
147
|
-
frame = [] if frame.nil?
|
148
|
-
frame << {frame: identifier}
|
149
|
-
block.call(frame)
|
150
|
-
end
|
151
|
-
|
152
|
-
#
|
153
|
-
# platform method to switch to an iframe and execute a block
|
154
|
-
# See PageObject#in_frame
|
155
|
-
#
|
156
|
-
def in_iframe(identifier, frame=nil, &block)
|
157
|
-
frame = [] if frame.nil?
|
158
|
-
frame << {iframe: identifier}
|
159
|
-
block.call(frame)
|
160
|
-
end
|
161
|
-
|
162
|
-
#
|
163
|
-
# platform method to refresh the page
|
164
|
-
# See PageObject#refresh
|
165
|
-
#
|
166
|
-
def refresh
|
167
|
-
@browser.refresh
|
168
|
-
end
|
169
|
-
|
170
|
-
#
|
171
|
-
# platform method to go back to the previous page
|
172
|
-
# See PageObject#back
|
173
|
-
#
|
174
|
-
def back
|
175
|
-
@browser.back
|
176
|
-
end
|
177
|
-
|
178
|
-
#
|
179
|
-
# platform method to go forward to the next page
|
180
|
-
# See PageObject#forward
|
181
|
-
#
|
182
|
-
def forward
|
183
|
-
@browser.forward
|
184
|
-
end
|
185
|
-
|
186
|
-
#
|
187
|
-
# platform method to clear the cookies from the browser
|
188
|
-
# See PageObject#clear_cookies
|
189
|
-
#
|
190
|
-
def clear_cookies
|
191
|
-
@browser.cookies.clear
|
192
|
-
end
|
193
|
-
|
194
|
-
#
|
195
|
-
# platform method to save the current screenshot to a file
|
196
|
-
# See PageObject#save_screenshot
|
197
|
-
#
|
198
|
-
def save_screenshot(file_name)
|
199
|
-
@browser.wd.save_screenshot(file_name)
|
200
|
-
end
|
201
|
-
|
202
|
-
#
|
203
|
-
# platform method to get the value stored in a text field
|
204
|
-
# See PageObject::Accessors#text_field
|
205
|
-
#
|
206
|
-
def text_field_value_for(identifier)
|
207
|
-
process_watir_call("text_field(identifier).value", Elements::TextField, identifier)
|
208
|
-
end
|
209
|
-
|
210
|
-
#
|
211
|
-
# platform method to set the value for a text field
|
212
|
-
# See PageObject::Accessors#text_field
|
213
|
-
#
|
214
|
-
def text_field_value_set(identifier, value)
|
215
|
-
process_watir_call("text_field(identifier).set(value)", Elements::TextField, identifier, value)
|
216
|
-
end
|
217
|
-
|
218
|
-
#
|
219
|
-
# platform method to retrieve a text field element
|
220
|
-
# See PageObject::Accessors#text_field
|
221
|
-
#
|
222
|
-
def text_field_for(identifier)
|
223
|
-
find_watir_element("text_field(identifier)", Elements::TextField, identifier)
|
224
|
-
end
|
225
|
-
|
226
|
-
#
|
227
|
-
# platform method to retrieve an array of text field elements
|
228
|
-
#
|
229
|
-
def text_fields_for(identifier)
|
230
|
-
elements = find_watir_elements("text_fields(identifier)", Elements::TextField, identifier)
|
231
|
-
elements.select { |e| e.element.tag_name == 'input' }
|
232
|
-
end
|
233
|
-
|
234
|
-
#
|
235
|
-
# platform method to get the value stored in a
|
236
|
-
# See PageObject::Accessors#
|
237
|
-
#
|
238
|
-
def
|
239
|
-
process_watir_call("
|
240
|
-
end
|
241
|
-
|
242
|
-
#
|
243
|
-
# platform method to
|
244
|
-
# See PageObject::Accessors#
|
245
|
-
#
|
246
|
-
def
|
247
|
-
|
248
|
-
end
|
249
|
-
|
250
|
-
#
|
251
|
-
# platform method to retrieve
|
252
|
-
#
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
#
|
259
|
-
#
|
260
|
-
#
|
261
|
-
def
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
#
|
267
|
-
#
|
268
|
-
#
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
#
|
275
|
-
#
|
276
|
-
#
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
#
|
283
|
-
#
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
#
|
290
|
-
#
|
291
|
-
#
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
#
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
#
|
334
|
-
#
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
#
|
343
|
-
#
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
#
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
#
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
#
|
367
|
-
#
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
#
|
375
|
-
#
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
#
|
383
|
-
#
|
384
|
-
#
|
385
|
-
def
|
386
|
-
|
387
|
-
end
|
388
|
-
|
389
|
-
#
|
390
|
-
# platform method to
|
391
|
-
# See PageObject::Accessors#
|
392
|
-
#
|
393
|
-
def
|
394
|
-
process_watir_call("
|
395
|
-
end
|
396
|
-
|
397
|
-
#
|
398
|
-
# platform method to determine if a
|
399
|
-
# See PageObject::Accessors#
|
400
|
-
#
|
401
|
-
def
|
402
|
-
process_watir_call("
|
403
|
-
end
|
404
|
-
|
405
|
-
#
|
406
|
-
# platform method to return a PageObject::
|
407
|
-
# See PageObject::Accessors#
|
408
|
-
#
|
409
|
-
def
|
410
|
-
find_watir_element("
|
411
|
-
end
|
412
|
-
|
413
|
-
#
|
414
|
-
# platform method to retrieve an array of
|
415
|
-
#
|
416
|
-
def
|
417
|
-
find_watir_elements("
|
418
|
-
end
|
419
|
-
|
420
|
-
#
|
421
|
-
# platform method to
|
422
|
-
# See PageObject::Accessors#
|
423
|
-
#
|
424
|
-
def
|
425
|
-
process_watir_call("
|
426
|
-
end
|
427
|
-
|
428
|
-
#
|
429
|
-
# platform method to
|
430
|
-
# See PageObject::Accessors#
|
431
|
-
#
|
432
|
-
def
|
433
|
-
|
434
|
-
end
|
435
|
-
|
436
|
-
#
|
437
|
-
# platform method to
|
438
|
-
#
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
#
|
445
|
-
#
|
446
|
-
#
|
447
|
-
def
|
448
|
-
|
449
|
-
end
|
450
|
-
|
451
|
-
#
|
452
|
-
# platform method to return a
|
453
|
-
# See PageObject::Accessors#
|
454
|
-
#
|
455
|
-
def
|
456
|
-
|
457
|
-
end
|
458
|
-
|
459
|
-
#
|
460
|
-
# platform method to
|
461
|
-
#
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
#
|
468
|
-
#
|
469
|
-
#
|
470
|
-
def
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
#
|
476
|
-
#
|
477
|
-
#
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
#
|
485
|
-
#
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
#
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
#
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
#
|
509
|
-
#
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
end
|
514
|
-
|
515
|
-
#
|
516
|
-
# platform method to retrieve
|
517
|
-
#
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
#
|
525
|
-
#
|
526
|
-
#
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
#
|
533
|
-
#
|
534
|
-
#
|
535
|
-
def
|
536
|
-
|
537
|
-
end
|
538
|
-
|
539
|
-
#
|
540
|
-
# platform method to retrieve
|
541
|
-
#
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
#
|
549
|
-
#
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
#
|
557
|
-
#
|
558
|
-
#
|
559
|
-
def
|
560
|
-
|
561
|
-
end
|
562
|
-
|
563
|
-
#
|
564
|
-
# platform method to retrieve
|
565
|
-
#
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
#
|
572
|
-
#
|
573
|
-
#
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
end
|
578
|
-
|
579
|
-
#
|
580
|
-
# platform method to retrieve
|
581
|
-
#
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
#
|
588
|
-
#
|
589
|
-
#
|
590
|
-
def
|
591
|
-
|
592
|
-
end
|
593
|
-
|
594
|
-
#
|
595
|
-
# platform method to retrieve
|
596
|
-
#
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
#
|
603
|
-
#
|
604
|
-
#
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
#
|
611
|
-
#
|
612
|
-
#
|
613
|
-
def
|
614
|
-
|
615
|
-
end
|
616
|
-
|
617
|
-
#
|
618
|
-
# platform method to retrieve
|
619
|
-
#
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
#
|
626
|
-
#
|
627
|
-
#
|
628
|
-
def
|
629
|
-
|
630
|
-
end
|
631
|
-
|
632
|
-
#
|
633
|
-
# platform method to retrieve
|
634
|
-
# See PageObject::Accessors#
|
635
|
-
#
|
636
|
-
def
|
637
|
-
|
638
|
-
end
|
639
|
-
|
640
|
-
#
|
641
|
-
# platform method to retrieve
|
642
|
-
#
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
#
|
649
|
-
#
|
650
|
-
#
|
651
|
-
def
|
652
|
-
|
653
|
-
end
|
654
|
-
|
655
|
-
#
|
656
|
-
# platform method to retrieve an
|
657
|
-
# See PageObject::Accessors#
|
658
|
-
#
|
659
|
-
def
|
660
|
-
|
661
|
-
end
|
662
|
-
|
663
|
-
#
|
664
|
-
# platform method to retrieve an
|
665
|
-
#
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
#
|
672
|
-
#
|
673
|
-
#
|
674
|
-
def
|
675
|
-
|
676
|
-
end
|
677
|
-
|
678
|
-
#
|
679
|
-
# platform method to retrieve the
|
680
|
-
# See PageObject::Accessors#
|
681
|
-
#
|
682
|
-
def
|
683
|
-
|
684
|
-
end
|
685
|
-
|
686
|
-
#
|
687
|
-
# platform method to retrieve an
|
688
|
-
#
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
#
|
695
|
-
#
|
696
|
-
#
|
697
|
-
def
|
698
|
-
|
699
|
-
end
|
700
|
-
|
701
|
-
#
|
702
|
-
# platform method to retrieve the
|
703
|
-
# See PageObject::Accessors#
|
704
|
-
#
|
705
|
-
def
|
706
|
-
|
707
|
-
end
|
708
|
-
|
709
|
-
#
|
710
|
-
# platform method to retrieve
|
711
|
-
#
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
#
|
718
|
-
#
|
719
|
-
#
|
720
|
-
def
|
721
|
-
|
722
|
-
end
|
723
|
-
|
724
|
-
#
|
725
|
-
# platform method to retrieve the
|
726
|
-
# See PageObject::Accessors#
|
727
|
-
#
|
728
|
-
def
|
729
|
-
|
730
|
-
end
|
731
|
-
|
732
|
-
#
|
733
|
-
# platform method to retrieve
|
734
|
-
#
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
#
|
741
|
-
#
|
742
|
-
#
|
743
|
-
def
|
744
|
-
|
745
|
-
end
|
746
|
-
|
747
|
-
#
|
748
|
-
# platform method to retrieve the
|
749
|
-
# See PageObject::Accessors#
|
750
|
-
#
|
751
|
-
def
|
752
|
-
|
753
|
-
end
|
754
|
-
|
755
|
-
#
|
756
|
-
# platform method to retrieve
|
757
|
-
#
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
#
|
764
|
-
#
|
765
|
-
#
|
766
|
-
def
|
767
|
-
|
768
|
-
end
|
769
|
-
|
770
|
-
#
|
771
|
-
# platform method to retrieve the
|
772
|
-
# See PageObject::Accessors#
|
773
|
-
#
|
774
|
-
def
|
775
|
-
|
776
|
-
end
|
777
|
-
|
778
|
-
#
|
779
|
-
# platform method to retrieve
|
780
|
-
#
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
#
|
787
|
-
#
|
788
|
-
#
|
789
|
-
def
|
790
|
-
|
791
|
-
end
|
792
|
-
|
793
|
-
#
|
794
|
-
# platform method to retrieve the
|
795
|
-
# See PageObject::Accessors#
|
796
|
-
#
|
797
|
-
def
|
798
|
-
|
799
|
-
end
|
800
|
-
|
801
|
-
#
|
802
|
-
# platform method to retrieve
|
803
|
-
#
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
#
|
810
|
-
#
|
811
|
-
#
|
812
|
-
def
|
813
|
-
|
814
|
-
end
|
815
|
-
|
816
|
-
#
|
817
|
-
# platform method to retrieve the
|
818
|
-
# See PageObject::Accessors#
|
819
|
-
#
|
820
|
-
def
|
821
|
-
|
822
|
-
end
|
823
|
-
|
824
|
-
#
|
825
|
-
# platform method to retrieve
|
826
|
-
#
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
#
|
833
|
-
#
|
834
|
-
#
|
835
|
-
def
|
836
|
-
|
837
|
-
end
|
838
|
-
|
839
|
-
#
|
840
|
-
# platform method to
|
841
|
-
# See PageObject::Accessors#
|
842
|
-
#
|
843
|
-
def
|
844
|
-
|
845
|
-
end
|
846
|
-
|
847
|
-
#
|
848
|
-
#
|
849
|
-
#
|
850
|
-
#
|
851
|
-
def
|
852
|
-
|
853
|
-
end
|
854
|
-
|
855
|
-
#
|
856
|
-
# platform method to
|
857
|
-
#
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
#
|
865
|
-
#
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
#
|
873
|
-
#
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
#
|
880
|
-
# platform method to
|
881
|
-
#
|
882
|
-
def
|
883
|
-
|
884
|
-
end
|
885
|
-
|
886
|
-
#
|
887
|
-
# platform method to
|
888
|
-
#
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
#
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
#
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
#
|
953
|
-
#
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
#
|
960
|
-
#
|
961
|
-
#
|
962
|
-
def
|
963
|
-
|
964
|
-
end
|
965
|
-
|
966
|
-
#
|
967
|
-
# platform method to
|
968
|
-
#
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
#
|
975
|
-
#
|
976
|
-
#
|
977
|
-
def
|
978
|
-
find_watir_element("
|
979
|
-
end
|
980
|
-
|
981
|
-
#
|
982
|
-
# platform method to return an array of
|
983
|
-
#
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
#
|
990
|
-
#
|
991
|
-
#
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
#
|
998
|
-
#
|
999
|
-
#
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
#
|
1006
|
-
#
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
#
|
1013
|
-
#
|
1014
|
-
#
|
1015
|
-
def
|
1016
|
-
|
1017
|
-
end
|
1018
|
-
|
1019
|
-
#
|
1020
|
-
# platform method to retrieve the
|
1021
|
-
# See PageObject::Accessors#
|
1022
|
-
#
|
1023
|
-
def
|
1024
|
-
|
1025
|
-
end
|
1026
|
-
|
1027
|
-
#
|
1028
|
-
# platform method to retrieve
|
1029
|
-
#
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
end
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
@browser.
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1
|
+
require 'page-object/elements'
|
2
|
+
|
3
|
+
|
4
|
+
module PageObject
|
5
|
+
module Platforms
|
6
|
+
module Watir
|
7
|
+
|
8
|
+
#
|
9
|
+
# Watir implementation of the page object platform driver. You should not use the
|
10
|
+
# class directly. Instead you should include the PageObject module in your page object
|
11
|
+
# and use the methods dynamically added from the PageObject::Accessors module.
|
12
|
+
#
|
13
|
+
class PageObject
|
14
|
+
attr_reader :browser
|
15
|
+
|
16
|
+
def self.define_widget_accessors(widget_tag, widget_class, base_element_tag)
|
17
|
+
define_widget_singular_accessor(base_element_tag, widget_class, widget_tag)
|
18
|
+
define_widget_multiple_accessor(base_element_tag, widget_class, widget_tag)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(browser)
|
22
|
+
@browser = browser
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# platform method to navigate to a provided url
|
27
|
+
# See PageObject#navigate_to
|
28
|
+
#
|
29
|
+
def navigate_to(url)
|
30
|
+
@browser.goto url
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# platform method to get the current url
|
35
|
+
# See PageObject#current_url
|
36
|
+
#
|
37
|
+
def current_url
|
38
|
+
@browser.url
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# platform method to retrieve the text from the current page
|
43
|
+
# See PageObject#text
|
44
|
+
#
|
45
|
+
def text
|
46
|
+
@browser.text
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# platform method to retrieve the html for the current page
|
51
|
+
# See PageObject#html
|
52
|
+
#
|
53
|
+
def html
|
54
|
+
@browser.html
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# platform method to retrieve the title for the current page
|
59
|
+
# See PageObject#title
|
60
|
+
#
|
61
|
+
def title
|
62
|
+
@browser.title
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# platform method to wait for a block to return true
|
67
|
+
# See PageObject#wait_until
|
68
|
+
def wait_until(timeout, message = nil, &block)
|
69
|
+
@browser.wait_until(timeout: timeout, message: message, &block)
|
70
|
+
end
|
71
|
+
|
72
|
+
#
|
73
|
+
# platform method to handle an alert popup
|
74
|
+
# See PageObject#alert
|
75
|
+
#
|
76
|
+
def alert(frame=nil, &block)
|
77
|
+
switch_to_frame(frame)
|
78
|
+
yield
|
79
|
+
value = nil
|
80
|
+
if @browser.alert.exists?
|
81
|
+
value = @browser.alert.text
|
82
|
+
@browser.alert.ok
|
83
|
+
end
|
84
|
+
switch_to_default_content(frame)
|
85
|
+
value
|
86
|
+
end
|
87
|
+
|
88
|
+
#
|
89
|
+
# platform method to handle a confirm popup
|
90
|
+
# See PageObject#confirm
|
91
|
+
#
|
92
|
+
def confirm(response, frame=nil, &block)
|
93
|
+
switch_to_frame(frame)
|
94
|
+
yield
|
95
|
+
value = nil
|
96
|
+
if @browser.alert.exists?
|
97
|
+
value = @browser.alert.text
|
98
|
+
response ? @browser.alert.ok : @browser.alert.close
|
99
|
+
end
|
100
|
+
switch_to_default_content(frame)
|
101
|
+
value
|
102
|
+
end
|
103
|
+
|
104
|
+
#
|
105
|
+
# platform method to handle a prompt popup
|
106
|
+
# See PageObject#prompt
|
107
|
+
#
|
108
|
+
def prompt(answer, frame=nil, &block)
|
109
|
+
switch_to_frame(frame)
|
110
|
+
@browser.wd.execute_script "window.prompt = function(text, value) { window.__lastWatirPrompt = { message: text, default_value: value }; return #{answer}; }"
|
111
|
+
yield
|
112
|
+
result = @browser.wd.execute_script "return window.__lastWatirPrompt"
|
113
|
+
switch_to_default_content(frame)
|
114
|
+
result && result.dup.each_key { |k| result[k.to_sym] = result.delete(k) }
|
115
|
+
result
|
116
|
+
end
|
117
|
+
|
118
|
+
#
|
119
|
+
# platform method to execute javascript on the browser
|
120
|
+
# See PageObject#execute_script
|
121
|
+
#
|
122
|
+
def execute_script(script, *args)
|
123
|
+
@browser.execute_script(script, *args)
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# platform method to handle attaching to a running window
|
128
|
+
# See PageObject#attach_to_window
|
129
|
+
#
|
130
|
+
def attach_to_window(identifier, &block)
|
131
|
+
win_id = {identifier.keys.first => /#{Regexp.escape(identifier.values.first)}/}
|
132
|
+
@browser.window(win_id).use &block
|
133
|
+
end
|
134
|
+
|
135
|
+
def element_with_focus
|
136
|
+
element = browser.execute_script("return document.activeElement")
|
137
|
+
type = element.type.to_sym if element.tag_name.to_sym == :input
|
138
|
+
cls = ::PageObject::Elements.element_class_for(element.tag_name, type)
|
139
|
+
cls.new(element)
|
140
|
+
end
|
141
|
+
|
142
|
+
#
|
143
|
+
# platform method to switch to a frame and execute a block
|
144
|
+
# See PageObject#in_frame
|
145
|
+
#
|
146
|
+
def in_frame(identifier, frame=nil, &block)
|
147
|
+
frame = [] if frame.nil?
|
148
|
+
frame << {frame: identifier}
|
149
|
+
block.call(frame)
|
150
|
+
end
|
151
|
+
|
152
|
+
#
|
153
|
+
# platform method to switch to an iframe and execute a block
|
154
|
+
# See PageObject#in_frame
|
155
|
+
#
|
156
|
+
def in_iframe(identifier, frame=nil, &block)
|
157
|
+
frame = [] if frame.nil?
|
158
|
+
frame << {iframe: identifier}
|
159
|
+
block.call(frame)
|
160
|
+
end
|
161
|
+
|
162
|
+
#
|
163
|
+
# platform method to refresh the page
|
164
|
+
# See PageObject#refresh
|
165
|
+
#
|
166
|
+
def refresh
|
167
|
+
@browser.refresh
|
168
|
+
end
|
169
|
+
|
170
|
+
#
|
171
|
+
# platform method to go back to the previous page
|
172
|
+
# See PageObject#back
|
173
|
+
#
|
174
|
+
def back
|
175
|
+
@browser.back
|
176
|
+
end
|
177
|
+
|
178
|
+
#
|
179
|
+
# platform method to go forward to the next page
|
180
|
+
# See PageObject#forward
|
181
|
+
#
|
182
|
+
def forward
|
183
|
+
@browser.forward
|
184
|
+
end
|
185
|
+
|
186
|
+
#
|
187
|
+
# platform method to clear the cookies from the browser
|
188
|
+
# See PageObject#clear_cookies
|
189
|
+
#
|
190
|
+
def clear_cookies
|
191
|
+
@browser.cookies.clear
|
192
|
+
end
|
193
|
+
|
194
|
+
#
|
195
|
+
# platform method to save the current screenshot to a file
|
196
|
+
# See PageObject#save_screenshot
|
197
|
+
#
|
198
|
+
def save_screenshot(file_name)
|
199
|
+
@browser.wd.save_screenshot(file_name)
|
200
|
+
end
|
201
|
+
|
202
|
+
#
|
203
|
+
# platform method to get the value stored in a text field
|
204
|
+
# See PageObject::Accessors#text_field
|
205
|
+
#
|
206
|
+
def text_field_value_for(identifier)
|
207
|
+
process_watir_call("text_field(identifier).value", Elements::TextField, identifier)
|
208
|
+
end
|
209
|
+
|
210
|
+
#
|
211
|
+
# platform method to set the value for a text field
|
212
|
+
# See PageObject::Accessors#text_field
|
213
|
+
#
|
214
|
+
def text_field_value_set(identifier, value)
|
215
|
+
process_watir_call("text_field(identifier).set(value)", Elements::TextField, identifier, value)
|
216
|
+
end
|
217
|
+
|
218
|
+
#
|
219
|
+
# platform method to retrieve a text field element
|
220
|
+
# See PageObject::Accessors#text_field
|
221
|
+
#
|
222
|
+
def text_field_for(identifier)
|
223
|
+
find_watir_element("text_field(identifier)", Elements::TextField, identifier)
|
224
|
+
end
|
225
|
+
|
226
|
+
#
|
227
|
+
# platform method to retrieve an array of text field elements
|
228
|
+
#
|
229
|
+
def text_fields_for(identifier)
|
230
|
+
elements = find_watir_elements("text_fields(identifier)", Elements::TextField, identifier)
|
231
|
+
elements.select { |e| e.element.tag_name == 'input' }
|
232
|
+
end
|
233
|
+
|
234
|
+
#
|
235
|
+
# platform method to get the value stored in a date field
|
236
|
+
# See PageObject::Accessors#date_field
|
237
|
+
#
|
238
|
+
def date_field_value_for(identifier)
|
239
|
+
process_watir_call("date_field(identifier).value", Elements::DateField, identifier)
|
240
|
+
end
|
241
|
+
|
242
|
+
#
|
243
|
+
# platform method to set the value for a date field
|
244
|
+
# See PageObject::Accessors#date_field
|
245
|
+
#
|
246
|
+
def date_field_value_set(identifier, value)
|
247
|
+
process_watir_call("date_field(identifier).set(value)", Elements::DateField, identifier, value)
|
248
|
+
end
|
249
|
+
|
250
|
+
#
|
251
|
+
# platform method to retrieve a date field element
|
252
|
+
# See PageObject::Accessors#date_field
|
253
|
+
#
|
254
|
+
def date_field_for(identifier)
|
255
|
+
find_watir_element("date_field(identifier)", Elements::DateField, identifier)
|
256
|
+
end
|
257
|
+
|
258
|
+
#
|
259
|
+
# platform method to retrieve an array of date field elements
|
260
|
+
#
|
261
|
+
def date_fields_for(identifier)
|
262
|
+
find_watir_elements("date_fields(identifier)", Elements::DateField, identifier)
|
263
|
+
end
|
264
|
+
|
265
|
+
#
|
266
|
+
# platform method to get the value stored in a hidden field
|
267
|
+
# See PageObject::Accessors#hidden_field
|
268
|
+
#
|
269
|
+
def hidden_field_value_for(identifier)
|
270
|
+
process_watir_call("hidden(identifier).value", Elements::HiddenField, identifier)
|
271
|
+
end
|
272
|
+
|
273
|
+
#
|
274
|
+
# platform method to retrieve a hidden field element
|
275
|
+
# See PageObject::Accessors#hidden_field
|
276
|
+
#
|
277
|
+
def hidden_field_for(identifier)
|
278
|
+
find_watir_element("hidden(identifier)", Elements::HiddenField, identifier)
|
279
|
+
end
|
280
|
+
|
281
|
+
#
|
282
|
+
# platform method to retrieve an array of hidden field elements
|
283
|
+
#
|
284
|
+
def hidden_fields_for(identifier)
|
285
|
+
find_watir_elements("hiddens(identifier)", Elements::HiddenField, identifier)
|
286
|
+
end
|
287
|
+
|
288
|
+
#
|
289
|
+
# platform method to set text in a textarea
|
290
|
+
# See PageObject::Accessors#text_area
|
291
|
+
#
|
292
|
+
def text_area_value_set(identifier, value)
|
293
|
+
process_watir_call("textarea(identifier).set(value)", Elements::TextArea,
|
294
|
+
identifier, value)
|
295
|
+
end
|
296
|
+
|
297
|
+
#
|
298
|
+
# platform method to get the text from a textarea
|
299
|
+
# See PageObject::Accessors#text_area
|
300
|
+
#
|
301
|
+
def text_area_value_for(identifier)
|
302
|
+
process_watir_call("textarea(identifier).value", Elements::TextArea, identifier)
|
303
|
+
end
|
304
|
+
|
305
|
+
#
|
306
|
+
# platform method to get the text area element
|
307
|
+
# See PageObject::Accessors#text_area
|
308
|
+
#
|
309
|
+
def text_area_for(identifier)
|
310
|
+
find_watir_element("textarea(identifier)", Elements::TextArea, identifier)
|
311
|
+
end
|
312
|
+
|
313
|
+
#
|
314
|
+
# platform method to retrieve an array of textarea elements
|
315
|
+
#
|
316
|
+
def text_areas_for(identifier)
|
317
|
+
find_watir_elements("textareas(identifier)", Elements::TextArea, identifier)
|
318
|
+
end
|
319
|
+
|
320
|
+
#
|
321
|
+
# platform method to get the currently selected value from a select list
|
322
|
+
# See PageObject::Accessors#select_list
|
323
|
+
#
|
324
|
+
def select_list_value_for(identifier)
|
325
|
+
options = find_watir_elements("select_list(identifier).selected_options",
|
326
|
+
Elements::SelectList, identifier)
|
327
|
+
return nil if options.empty?
|
328
|
+
options.first.text
|
329
|
+
end
|
330
|
+
|
331
|
+
#
|
332
|
+
# platform method to select a value from a select list
|
333
|
+
# See PageObject::Accessors#select_list
|
334
|
+
#
|
335
|
+
def select_list_value_set(identifier, value)
|
336
|
+
process_watir_call("select_list(identifier).select(value)", Elements::SelectList,
|
337
|
+
identifier, value)
|
338
|
+
end
|
339
|
+
|
340
|
+
#
|
341
|
+
# platform method to return the select list element
|
342
|
+
# See PageObject::Accessors#select_list
|
343
|
+
#
|
344
|
+
def select_list_for(identifier)
|
345
|
+
find_watir_element("select_list(identifier)", Elements::SelectList, identifier)
|
346
|
+
end
|
347
|
+
|
348
|
+
#
|
349
|
+
# platform method to retrieve an array of select_list elements
|
350
|
+
#
|
351
|
+
def select_lists_for(identifier)
|
352
|
+
find_watir_elements("select_lists(identifier)", Elements::SelectList, identifier)
|
353
|
+
end
|
354
|
+
|
355
|
+
#
|
356
|
+
# platform method to click a link
|
357
|
+
# See PageObject::Accessors#link
|
358
|
+
#
|
359
|
+
def click_link_for(identifier)
|
360
|
+
call = "link(identifier)"
|
361
|
+
process_watir_call("#{call}.click if identifier", Elements::Link, identifier)
|
362
|
+
end
|
363
|
+
|
364
|
+
#
|
365
|
+
# platform method to return a PageObject::Elements::Link object
|
366
|
+
# see PageObject::Accessors#link
|
367
|
+
#
|
368
|
+
def link_for(identifier)
|
369
|
+
call = "link(identifier)"
|
370
|
+
find_watir_element(call, Elements::Link, identifier)
|
371
|
+
end
|
372
|
+
|
373
|
+
#
|
374
|
+
# platform method to retrieve an array of link elements
|
375
|
+
#
|
376
|
+
def links_for(identifier)
|
377
|
+
call = "links(identifier)"
|
378
|
+
find_watir_elements(call, Elements::Link, identifier)
|
379
|
+
end
|
380
|
+
|
381
|
+
#
|
382
|
+
# platform method to check a checkbox
|
383
|
+
# See PageObject::Accessors#checkbox
|
384
|
+
#
|
385
|
+
def check_checkbox(identifier)
|
386
|
+
process_watir_call("checkbox(identifier).set", Elements::CheckBox, identifier)
|
387
|
+
end
|
388
|
+
|
389
|
+
#
|
390
|
+
# platform method to uncheck a checkbox
|
391
|
+
# See PageObject::Accessors#checkbox
|
392
|
+
#
|
393
|
+
def uncheck_checkbox(identifier)
|
394
|
+
process_watir_call("checkbox(identifier).clear", Elements::CheckBox, identifier)
|
395
|
+
end
|
396
|
+
|
397
|
+
#
|
398
|
+
# platform method to determine if a checkbox is checked
|
399
|
+
# See PageObject::Accessors#checkbox
|
400
|
+
#
|
401
|
+
def checkbox_checked?(identifier)
|
402
|
+
process_watir_call("checkbox(identifier).set?", Elements::CheckBox, identifier)
|
403
|
+
end
|
404
|
+
|
405
|
+
#
|
406
|
+
# platform method to return a PageObject::Elements::CheckBox element
|
407
|
+
# See PageObject::Accessors#checkbox
|
408
|
+
#
|
409
|
+
def checkbox_for(identifier)
|
410
|
+
find_watir_element("checkbox(identifier)", Elements::CheckBox, identifier)
|
411
|
+
end
|
412
|
+
|
413
|
+
#
|
414
|
+
# platform method to retrieve an array of checkbox elements
|
415
|
+
#
|
416
|
+
def checkboxs_for(identifier)
|
417
|
+
find_watir_elements("checkboxes(identifier)", Elements::CheckBox, identifier)
|
418
|
+
end
|
419
|
+
|
420
|
+
#
|
421
|
+
# platform method to select a radio button
|
422
|
+
# See PageObject::Accessors#radio_button
|
423
|
+
#
|
424
|
+
def select_radio(identifier)
|
425
|
+
process_watir_call("radio(identifier).set", Elements::RadioButton, identifier)
|
426
|
+
end
|
427
|
+
|
428
|
+
#
|
429
|
+
# platform method to determine if a radio button is selected
|
430
|
+
# See PageObject::Accessors#radio_button
|
431
|
+
#
|
432
|
+
def radio_selected?(identifier)
|
433
|
+
process_watir_call("radio(identifier).set?", Elements::RadioButton, identifier)
|
434
|
+
end
|
435
|
+
|
436
|
+
#
|
437
|
+
# platform method to return a PageObject::Eements::RadioButton element
|
438
|
+
# See PageObject::Accessors#radio_button
|
439
|
+
#
|
440
|
+
def radio_button_for(identifier)
|
441
|
+
find_watir_element("radio(identifier)", Elements::RadioButton, identifier)
|
442
|
+
end
|
443
|
+
|
444
|
+
#
|
445
|
+
# platform method to retrieve an array of radio button elements
|
446
|
+
#
|
447
|
+
def radio_buttons_for(identifier)
|
448
|
+
find_watir_elements("radios(identifier)", Elements::RadioButton, identifier)
|
449
|
+
end
|
450
|
+
|
451
|
+
#
|
452
|
+
# platform method to return the text for a div
|
453
|
+
# See PageObject::Accessors#div
|
454
|
+
#
|
455
|
+
def div_text_for(identifier)
|
456
|
+
process_watir_call("div(identifier).text", Elements::Div, identifier, nil, 'div')
|
457
|
+
end
|
458
|
+
|
459
|
+
#
|
460
|
+
# platform method to return a PageObject::Elements::Div element
|
461
|
+
# See PageObject::Accessors#div
|
462
|
+
#
|
463
|
+
def div_for(identifier)
|
464
|
+
find_watir_element("div(identifier)", Elements::Div, identifier, 'div')
|
465
|
+
end
|
466
|
+
|
467
|
+
#
|
468
|
+
# platform method to retrieve an array of div elements
|
469
|
+
#
|
470
|
+
def divs_for(identifier)
|
471
|
+
find_watir_elements("divs(identifier)", Elements::Div, identifier, 'div')
|
472
|
+
end
|
473
|
+
|
474
|
+
#
|
475
|
+
# platform method to return the text for a span
|
476
|
+
# See PageObject::Accessors#span
|
477
|
+
#
|
478
|
+
def span_text_for(identifier)
|
479
|
+
process_watir_call("span(identifier).text", Elements::Span, identifier, nil, 'span')
|
480
|
+
end
|
481
|
+
|
482
|
+
#
|
483
|
+
# platform method to return a PageObject::Elements::Span element
|
484
|
+
# See PageObject::Accessors#span
|
485
|
+
#
|
486
|
+
def span_for(identifier)
|
487
|
+
find_watir_element("span(identifier)", Elements::Span, identifier, 'span')
|
488
|
+
end
|
489
|
+
|
490
|
+
#
|
491
|
+
# platform method to retrieve an array of span elements
|
492
|
+
#
|
493
|
+
def spans_for(identifier)
|
494
|
+
find_watir_elements("spans(identifier)", Elements::Span, identifier, 'span')
|
495
|
+
end
|
496
|
+
|
497
|
+
#
|
498
|
+
# platform method to click a button
|
499
|
+
# See PageObject::Accessors#button
|
500
|
+
#
|
501
|
+
def click_button_for(identifier)
|
502
|
+
call = "button(identifier)"
|
503
|
+
process_watir_call("#{call}.click", Elements::Button, identifier)
|
504
|
+
end
|
505
|
+
|
506
|
+
#
|
507
|
+
# platform method to retrieve a button element
|
508
|
+
# See PageObject::Accessors#button
|
509
|
+
#
|
510
|
+
def button_for(identifier)
|
511
|
+
call = "button(identifier)"
|
512
|
+
find_watir_element(call, Elements::Button, identifier)
|
513
|
+
end
|
514
|
+
|
515
|
+
#
|
516
|
+
# platform method to retrieve an array of button elements
|
517
|
+
#
|
518
|
+
def buttons_for(identifier)
|
519
|
+
call = "buttons(identifier)"
|
520
|
+
find_watir_elements(call, Elements::Button, identifier)
|
521
|
+
end
|
522
|
+
|
523
|
+
#
|
524
|
+
# platform method to return the text for a table
|
525
|
+
# See PageObject::Accessors#table
|
526
|
+
#
|
527
|
+
def table_text_for(identifier)
|
528
|
+
process_watir_call("table(identifier).text", Elements::Table, identifier, nil, 'table')
|
529
|
+
end
|
530
|
+
|
531
|
+
#
|
532
|
+
# platform method to retrieve a table element
|
533
|
+
# See PageObject::Accessors#table
|
534
|
+
#
|
535
|
+
def table_for(identifier)
|
536
|
+
find_watir_element("table(identifier)", Elements::Table, identifier, 'table')
|
537
|
+
end
|
538
|
+
|
539
|
+
#
|
540
|
+
# platform method to retrieve an array of table elements
|
541
|
+
#
|
542
|
+
def tables_for(identifier)
|
543
|
+
find_watir_elements("tables(identifier)", Elements::Table, identifier, 'table')
|
544
|
+
end
|
545
|
+
|
546
|
+
#
|
547
|
+
# platform method to retrieve the text from a table cell
|
548
|
+
# See PageObject::Accessors#cell
|
549
|
+
#
|
550
|
+
def cell_text_for(identifier)
|
551
|
+
process_watir_call("td(identifier).text", Elements::TableCell, identifier,
|
552
|
+
nil, 'td')
|
553
|
+
end
|
554
|
+
|
555
|
+
#
|
556
|
+
# platform method to retrieve a table cell element
|
557
|
+
# See PageObject::Accessors#cell
|
558
|
+
#
|
559
|
+
def cell_for(identifier)
|
560
|
+
find_watir_element("td(identifier)", Elements::TableCell, identifier, 'td')
|
561
|
+
end
|
562
|
+
|
563
|
+
#
|
564
|
+
# platform method to retrieve an array of table cell elements
|
565
|
+
#
|
566
|
+
def cells_for(identifier)
|
567
|
+
find_watir_elements("tds(identifier)", Elements::TableCell, identifier, 'td')
|
568
|
+
end
|
569
|
+
|
570
|
+
#
|
571
|
+
# platform method to retrieve the text from a table row
|
572
|
+
# See PageObject::Accessors#row
|
573
|
+
#
|
574
|
+
def row_text_for(identifier)
|
575
|
+
process_watir_call("tr(identifier).text", Elements::TableRow, identifier,
|
576
|
+
nil, 'tr')
|
577
|
+
end
|
578
|
+
|
579
|
+
#
|
580
|
+
# platform method to retrieve a table row element
|
581
|
+
# See PageObject::Accessors#row
|
582
|
+
#
|
583
|
+
def row_for(identifier)
|
584
|
+
find_watir_element("tr(identifier)", Elements::TableRow, identifier, 'tr')
|
585
|
+
end
|
586
|
+
|
587
|
+
#
|
588
|
+
# platform method to retrieve an array of table row elements
|
589
|
+
#
|
590
|
+
def rows_for(identifier)
|
591
|
+
find_watir_elements("trs(identifier)", Elements::TableRow, identifier, 'tr')
|
592
|
+
end
|
593
|
+
|
594
|
+
#
|
595
|
+
# platform method to retrieve load status of an image element
|
596
|
+
# See PageObject::Accessors#image
|
597
|
+
#
|
598
|
+
def image_loaded_for(identifier)
|
599
|
+
process_watir_call("image(identifier).loaded?", Elements::Image, identifier)
|
600
|
+
end
|
601
|
+
|
602
|
+
#
|
603
|
+
# platform method to retrieve an image element
|
604
|
+
# See PageObject::Accessors#image
|
605
|
+
#
|
606
|
+
def image_for(identifier)
|
607
|
+
find_watir_element("image(identifier)", Elements::Image, identifier)
|
608
|
+
end
|
609
|
+
|
610
|
+
#
|
611
|
+
# platform method to retrieve an array of image elements
|
612
|
+
#
|
613
|
+
def images_for(identifier)
|
614
|
+
find_watir_elements("images(identifier)", Elements::Image, identifier)
|
615
|
+
end
|
616
|
+
|
617
|
+
#
|
618
|
+
# platform method to retrieve a form element
|
619
|
+
# See PageObject::Accessors#form
|
620
|
+
#
|
621
|
+
def form_for(identifier)
|
622
|
+
find_watir_element("form(identifier)", Elements::Form, identifier)
|
623
|
+
end
|
624
|
+
|
625
|
+
#
|
626
|
+
# platform method to retrieve an array of forms
|
627
|
+
#
|
628
|
+
def forms_for(identifier)
|
629
|
+
find_watir_elements("forms(identifier)", Elements::Form, identifier)
|
630
|
+
end
|
631
|
+
|
632
|
+
#
|
633
|
+
# platform method to retrieve the text from a list item
|
634
|
+
# See PageObject::Accessors#list_item
|
635
|
+
#
|
636
|
+
def list_item_text_for(identifier)
|
637
|
+
process_watir_call("li(identifier).text", Elements::ListItem, identifier, nil, 'li')
|
638
|
+
end
|
639
|
+
|
640
|
+
#
|
641
|
+
# platform method to retrieve a list item element
|
642
|
+
# See PageObject::Accessors#list_item
|
643
|
+
#
|
644
|
+
def list_item_for(identifier)
|
645
|
+
find_watir_element("li(identifier)", Elements::ListItem, identifier, 'li')
|
646
|
+
end
|
647
|
+
|
648
|
+
#
|
649
|
+
# platform method to retrieve an array of list items
|
650
|
+
#
|
651
|
+
def list_items_for(identifier)
|
652
|
+
find_watir_elements("lis(identifier)", Elements::ListItem, identifier, 'li')
|
653
|
+
end
|
654
|
+
|
655
|
+
#
|
656
|
+
# platform method to retrieve the text from an unordered list
|
657
|
+
# See PageObject::Accessors#unordered_list
|
658
|
+
#
|
659
|
+
def unordered_list_text_for(identifier)
|
660
|
+
process_watir_call("ul(identifier).text", Elements::UnorderedList, identifier, nil, 'ul')
|
661
|
+
end
|
662
|
+
|
663
|
+
#
|
664
|
+
# platform method to retrieve an unordered list element
|
665
|
+
# See PageObject::Accessors#unordered_list
|
666
|
+
#
|
667
|
+
def unordered_list_for(identifier)
|
668
|
+
find_watir_element("ul(identifier)", Elements::UnorderedList, identifier, 'ul')
|
669
|
+
end
|
670
|
+
|
671
|
+
#
|
672
|
+
# platform method to retrieve an array of unordered lists
|
673
|
+
#
|
674
|
+
def unordered_lists_for(identifier)
|
675
|
+
find_watir_elements("uls(identifier)", Elements::UnorderedList, identifier, 'ul')
|
676
|
+
end
|
677
|
+
|
678
|
+
#
|
679
|
+
# platform method to retrieve the text from an ordered list
|
680
|
+
# See PageObject::Accessors#ordered_list
|
681
|
+
#
|
682
|
+
def ordered_list_text_for(identifier)
|
683
|
+
process_watir_call("ol(identifier).text", Elements::OrderedList, identifier, nil, 'ol')
|
684
|
+
end
|
685
|
+
|
686
|
+
#
|
687
|
+
# platform method to retrieve an ordered list element
|
688
|
+
# See PageObject::Accessors#ordered_list
|
689
|
+
#
|
690
|
+
def ordered_list_for(identifier)
|
691
|
+
find_watir_element("ol(identifier)", Elements::OrderedList, identifier, 'ol')
|
692
|
+
end
|
693
|
+
|
694
|
+
#
|
695
|
+
# platform method to retrieve an array of ordered lists
|
696
|
+
#
|
697
|
+
def ordered_lists_for(identifier)
|
698
|
+
find_watir_elements("ols(identifier)", Elements::OrderedList, identifier, 'ol')
|
699
|
+
end
|
700
|
+
|
701
|
+
#
|
702
|
+
# platform method to retrieve the text for a h1
|
703
|
+
# See PageObject::Accessors#h1
|
704
|
+
#
|
705
|
+
def h1_text_for(identifier)
|
706
|
+
process_watir_call("h1(identifier).text", Elements::Heading, identifier, nil, 'h1')
|
707
|
+
end
|
708
|
+
|
709
|
+
#
|
710
|
+
# platform method to retrieve the h1 element
|
711
|
+
# See PageObject::Accessors#h1
|
712
|
+
#
|
713
|
+
def h1_for(identifier)
|
714
|
+
find_watir_element("h1(identifier)", Elements::Heading, identifier, 'h1')
|
715
|
+
end
|
716
|
+
|
717
|
+
#
|
718
|
+
# platform method to retrieve an array of h1s
|
719
|
+
#
|
720
|
+
def h1s_for(identifier)
|
721
|
+
find_watir_elements("h1s(identifier)", Elements::Heading, identifier, 'h1')
|
722
|
+
end
|
723
|
+
|
724
|
+
#
|
725
|
+
# platform method to retrieve the text for a h2
|
726
|
+
# See PageObject::Accessors#h2
|
727
|
+
#
|
728
|
+
def h2_text_for(identifier)
|
729
|
+
process_watir_call("h2(identifier).text", Elements::Heading, identifier, nil, 'h2')
|
730
|
+
end
|
731
|
+
|
732
|
+
#
|
733
|
+
# platform method to retrieve the h2 element
|
734
|
+
# See PageObject::Accessors#h2
|
735
|
+
#
|
736
|
+
def h2_for(identifier)
|
737
|
+
find_watir_element("h2(identifier)", Elements::Heading, identifier, 'h2')
|
738
|
+
end
|
739
|
+
|
740
|
+
#
|
741
|
+
# platform method to retrieve an array of h2s
|
742
|
+
#
|
743
|
+
def h2s_for(identifier)
|
744
|
+
find_watir_elements("h2s(identifier)", Elements::Heading, identifier, 'h2')
|
745
|
+
end
|
746
|
+
|
747
|
+
#
|
748
|
+
# platform method to retrieve the text for a h3
|
749
|
+
# See PageObject::Accessors#h3
|
750
|
+
#
|
751
|
+
def h3_text_for(identifier)
|
752
|
+
process_watir_call("h3(identifier).text", Elements::Heading, identifier, nil, 'h3')
|
753
|
+
end
|
754
|
+
|
755
|
+
#
|
756
|
+
# platform method to retrieve the h3 element
|
757
|
+
# See PageObject::Accessors#h3
|
758
|
+
#
|
759
|
+
def h3_for(identifier)
|
760
|
+
find_watir_element("h3(identifier)", Elements::Heading, identifier, 'h3')
|
761
|
+
end
|
762
|
+
|
763
|
+
#
|
764
|
+
# platform method to retrieve an array of h3s
|
765
|
+
#
|
766
|
+
def h3s_for(identifier)
|
767
|
+
find_watir_elements("h3s(identifier)", Elements::Heading, identifier, 'h3')
|
768
|
+
end
|
769
|
+
|
770
|
+
#
|
771
|
+
# platform method to retrieve the text for a h4
|
772
|
+
# See PageObject::Accessors#h4
|
773
|
+
#
|
774
|
+
def h4_text_for(identifier)
|
775
|
+
process_watir_call("h4(identifier).text", Elements::Heading, identifier, nil, 'h4')
|
776
|
+
end
|
777
|
+
|
778
|
+
#
|
779
|
+
# platform method to retrieve the h4 element
|
780
|
+
# See PageObject::Accessors#h4
|
781
|
+
#
|
782
|
+
def h4_for(identifier)
|
783
|
+
find_watir_element("h4(identifier)", Elements::Heading, identifier, 'h4')
|
784
|
+
end
|
785
|
+
|
786
|
+
#
|
787
|
+
# platform method to retrieve an array of h4s
|
788
|
+
#
|
789
|
+
def h4s_for(identifier)
|
790
|
+
find_watir_elements("h4s(identifier)", Elements::Heading, identifier, 'h4')
|
791
|
+
end
|
792
|
+
|
793
|
+
#
|
794
|
+
# platform method to retrieve the text for a h5
|
795
|
+
# See PageObject::Accessors#h5
|
796
|
+
#
|
797
|
+
def h5_text_for(identifier)
|
798
|
+
process_watir_call("h5(identifier).text", Elements::Heading, identifier, nil, 'h5')
|
799
|
+
end
|
800
|
+
|
801
|
+
#
|
802
|
+
# platform method to retrieve the h5 element
|
803
|
+
# See PageObject::Accessors#h5
|
804
|
+
#
|
805
|
+
def h5_for(identifier)
|
806
|
+
find_watir_element("h5(identifier)", Elements::Heading, identifier, 'h5')
|
807
|
+
end
|
808
|
+
|
809
|
+
#
|
810
|
+
# platform method to retrieve an array of h5s
|
811
|
+
#
|
812
|
+
def h5s_for(identifier)
|
813
|
+
find_watir_elements("h5s(identifier)", Elements::Heading, identifier, 'h5')
|
814
|
+
end
|
815
|
+
|
816
|
+
#
|
817
|
+
# platform method to retrieve the text for a h6
|
818
|
+
# See PageObject::Accessors#h6
|
819
|
+
#
|
820
|
+
def h6_text_for(identifier)
|
821
|
+
process_watir_call("h6(identifier).text", Elements::Heading, identifier, nil, 'h6')
|
822
|
+
end
|
823
|
+
|
824
|
+
#
|
825
|
+
# platform method to retrieve the h6 element
|
826
|
+
# See PageObject::Accessors#h6
|
827
|
+
#
|
828
|
+
def h6_for(identifier)
|
829
|
+
find_watir_element("h6(identifier)", Elements::Heading, identifier, 'h6')
|
830
|
+
end
|
831
|
+
|
832
|
+
#
|
833
|
+
# platform method to retrieve an array of h6s
|
834
|
+
#
|
835
|
+
def h6s_for(identifier)
|
836
|
+
find_watir_elements("h6s(identifier)", Elements::Heading, identifier, 'h6')
|
837
|
+
end
|
838
|
+
|
839
|
+
#
|
840
|
+
# platform method to retrieve the text for a paragraph
|
841
|
+
# See PageObject::Accessors#paragraph
|
842
|
+
#
|
843
|
+
def paragraph_text_for(identifier)
|
844
|
+
process_watir_call("p(identifier).text", Elements::Paragraph, identifier, nil, 'p')
|
845
|
+
end
|
846
|
+
|
847
|
+
#
|
848
|
+
# platform method to retrieve the paragraph element
|
849
|
+
# See PageObject::Accessors#paragraph
|
850
|
+
#
|
851
|
+
def paragraph_for(identifier)
|
852
|
+
find_watir_element("p(identifier)", Elements::Paragraph, identifier, 'p')
|
853
|
+
end
|
854
|
+
|
855
|
+
#
|
856
|
+
# platform method to retrieve an array of paragraph elements
|
857
|
+
#
|
858
|
+
def paragraphs_for(identifier)
|
859
|
+
find_watir_elements("ps(identifier)", Elements::Paragraph, identifier, 'p')
|
860
|
+
end
|
861
|
+
|
862
|
+
#
|
863
|
+
# platform method to return the text for a label
|
864
|
+
# See PageObject::Accessors#label
|
865
|
+
#
|
866
|
+
def label_text_for(identifier)
|
867
|
+
process_watir_call("label(identifier).text", Elements::Label, identifier, nil, 'label')
|
868
|
+
end
|
869
|
+
|
870
|
+
#
|
871
|
+
# platform method to return a PageObject::Elements::Label element
|
872
|
+
# See PageObject::Accessors#label
|
873
|
+
#
|
874
|
+
def label_for(identifier)
|
875
|
+
find_watir_element("label(identifier)", Elements::Label, identifier, 'label')
|
876
|
+
end
|
877
|
+
|
878
|
+
#
|
879
|
+
#
|
880
|
+
# platform method to retrieve an array of label elements
|
881
|
+
#
|
882
|
+
def labels_for(identifier)
|
883
|
+
find_watir_elements("labels(identifier)", Elements::Label, identifier, 'label')
|
884
|
+
end
|
885
|
+
|
886
|
+
#
|
887
|
+
# platform method to set the file on a file_field element
|
888
|
+
# See PageObject::Accessors#file_field
|
889
|
+
#
|
890
|
+
def file_field_value_set(identifier, value)
|
891
|
+
process_watir_call("file_field(identifier).set(value)", Elements::FileField,
|
892
|
+
identifier, value)
|
893
|
+
end
|
894
|
+
|
895
|
+
#
|
896
|
+
# platform method to retrieve a file_field element
|
897
|
+
# See PageObject::Accessors#file_field
|
898
|
+
#
|
899
|
+
def file_field_for(identifier)
|
900
|
+
find_watir_element("file_field(identifier)", Elements::FileField, identifier)
|
901
|
+
end
|
902
|
+
|
903
|
+
#
|
904
|
+
# platform method to retrieve an array of file field elements
|
905
|
+
#
|
906
|
+
def file_fields_for(identifier)
|
907
|
+
find_watir_elements("file_fields(identifier)", Elements::FileField, identifier)
|
908
|
+
end
|
909
|
+
|
910
|
+
#
|
911
|
+
# platform method to click on an area
|
912
|
+
#
|
913
|
+
def click_area_for(identifier)
|
914
|
+
process_watir_call("area(identifier).click", Elements::Area, identifier, nil, 'area')
|
915
|
+
end
|
916
|
+
|
917
|
+
#
|
918
|
+
# platform method to retrieve an area element
|
919
|
+
#
|
920
|
+
def area_for(identifier)
|
921
|
+
find_watir_element("area(identifier)", Elements::Area, identifier, 'area')
|
922
|
+
end
|
923
|
+
|
924
|
+
#
|
925
|
+
# platform method to retrieve an array of area elements
|
926
|
+
#
|
927
|
+
def areas_for(identifier)
|
928
|
+
find_watir_elements("areas(identifier)", Elements::Area, identifier, 'area')
|
929
|
+
end
|
930
|
+
|
931
|
+
#
|
932
|
+
# platform method to retrieve a canvas element
|
933
|
+
#
|
934
|
+
def canvas_for(identifier)
|
935
|
+
find_watir_element("canvas(identifier)", Elements::Canvas, identifier, 'canvas')
|
936
|
+
end
|
937
|
+
|
938
|
+
#
|
939
|
+
# platform method to retrieve an array of canvas elements
|
940
|
+
#
|
941
|
+
def canvass_for(identifier)
|
942
|
+
find_watir_elements("canvases(identifier)", Elements::Canvas, identifier, 'canvas')
|
943
|
+
end
|
944
|
+
|
945
|
+
#
|
946
|
+
# platform method to retrieve an audio element
|
947
|
+
#
|
948
|
+
def audio_for(identifier)
|
949
|
+
find_watir_element("audio(identifier)", Elements::Audio, identifier, 'audio')
|
950
|
+
end
|
951
|
+
|
952
|
+
#
|
953
|
+
# platform method to retrieve an array of audio elements
|
954
|
+
#
|
955
|
+
def audios_for(identifier)
|
956
|
+
find_watir_elements("audios(identifier)", Elements::Audio, identifier, 'audio')
|
957
|
+
end
|
958
|
+
|
959
|
+
#
|
960
|
+
# platform method to retrieve a video element
|
961
|
+
#
|
962
|
+
def video_for(identifier)
|
963
|
+
find_watir_element("video(identifier)", Elements::Video, identifier, 'video')
|
964
|
+
end
|
965
|
+
|
966
|
+
#
|
967
|
+
# platform method to retrieve an array of video elements
|
968
|
+
#
|
969
|
+
def videos_for(identifier)
|
970
|
+
find_watir_elements("videos(identifier)", Elements::Video, identifier, 'video')
|
971
|
+
end
|
972
|
+
|
973
|
+
#
|
974
|
+
# platform method to return a PageObject::Elements::Element element
|
975
|
+
# See PageObject::Accessors#element
|
976
|
+
#
|
977
|
+
def element_for(tag, identifier)
|
978
|
+
find_watir_element("#{tag.to_s}(identifier)", Elements::Element, identifier, tag.to_s)
|
979
|
+
end
|
980
|
+
|
981
|
+
#
|
982
|
+
# platform method to return an array of PageObject::Elements::Element elements
|
983
|
+
# See PageObject::Accessors#element
|
984
|
+
#
|
985
|
+
def elements_for(tag, identifier)
|
986
|
+
find_watir_elements("#{tag.to_s}s(identifier)", Elements::Element, identifier, tag.to_s)
|
987
|
+
end
|
988
|
+
|
989
|
+
#
|
990
|
+
# platform method to return a PageObject rooted at an element
|
991
|
+
# See PageObject::Accessors#page_section
|
992
|
+
#
|
993
|
+
def page_for(identifier, page_class)
|
994
|
+
find_watir_page(identifier, page_class)
|
995
|
+
end
|
996
|
+
|
997
|
+
#
|
998
|
+
# platform method to return a collection of PageObjects rooted at elements
|
999
|
+
# See PageObject::Accessors#page_sections
|
1000
|
+
#
|
1001
|
+
def pages_for(identifier, page_class)
|
1002
|
+
SectionCollection[*find_watir_pages(identifier, page_class)]
|
1003
|
+
end
|
1004
|
+
|
1005
|
+
#
|
1006
|
+
# platform method to return a svg element
|
1007
|
+
#
|
1008
|
+
def svg_for(identifier)
|
1009
|
+
find_watir_element("element(identifier)", Elements::Element, identifier)
|
1010
|
+
end
|
1011
|
+
|
1012
|
+
#
|
1013
|
+
# platform method to return an array of svg elements
|
1014
|
+
#
|
1015
|
+
def svgs_for(identifier)
|
1016
|
+
find_watir_elements("element(identifier)", Elements::Element, identifier)
|
1017
|
+
end
|
1018
|
+
|
1019
|
+
#
|
1020
|
+
# platform method to retrieve the text for a b
|
1021
|
+
# See PageObject::Accessors#b
|
1022
|
+
#
|
1023
|
+
def b_text_for(identifier)
|
1024
|
+
process_watir_call("b(identifier).text", Elements::Bold, identifier, nil, 'b')
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
#
|
1028
|
+
# platform method to retrieve the b element
|
1029
|
+
# See PageObject::Accessors#b
|
1030
|
+
#
|
1031
|
+
def b_for(identifier)
|
1032
|
+
find_watir_element("b(identifier)", Elements::Bold, identifier, 'b')
|
1033
|
+
end
|
1034
|
+
|
1035
|
+
#
|
1036
|
+
# platform method to retrieve an array of bs
|
1037
|
+
#
|
1038
|
+
def bs_for(identifier)
|
1039
|
+
find_watir_elements("bs(identifier)", Elements::Bold, identifier, 'b')
|
1040
|
+
end
|
1041
|
+
|
1042
|
+
#
|
1043
|
+
# platform method to retrieve the text for a i
|
1044
|
+
# See PageObject::Accessors#i
|
1045
|
+
#
|
1046
|
+
def i_text_for(identifier)
|
1047
|
+
process_watir_call("i(identifier).text", Elements::Italic, identifier, nil, 'i')
|
1048
|
+
end
|
1049
|
+
|
1050
|
+
#
|
1051
|
+
# platform method to retrieve the i element
|
1052
|
+
# See PageObject::Accessors#i
|
1053
|
+
#
|
1054
|
+
def i_for(identifier)
|
1055
|
+
find_watir_element("i(identifier)", Elements::Italic, identifier, 'i')
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
#
|
1059
|
+
# platform method to retrieve an array of is
|
1060
|
+
#
|
1061
|
+
def is_for(identifier)
|
1062
|
+
find_watir_elements("is(identifier)", Elements::Italic, identifier, 'i')
|
1063
|
+
end
|
1064
|
+
|
1065
|
+
private
|
1066
|
+
|
1067
|
+
def find_watir_elements(the_call, type, identifier, tag_name=nil)
|
1068
|
+
identifier, frame_identifiers = parse_identifiers(identifier, type, tag_name)
|
1069
|
+
elements = @browser.instance_eval "#{nested_frames(frame_identifiers)}#{the_call}"
|
1070
|
+
switch_to_default_content(frame_identifiers)
|
1071
|
+
elements.map { |element| type.new(element) }
|
1072
|
+
end
|
1073
|
+
|
1074
|
+
def find_watir_element(the_call, type, identifier, tag_name=nil)
|
1075
|
+
identifier, frame_identifiers = parse_identifiers(identifier, type, tag_name)
|
1076
|
+
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}#{the_call}"
|
1077
|
+
switch_to_default_content(frame_identifiers)
|
1078
|
+
type.new(element)
|
1079
|
+
end
|
1080
|
+
|
1081
|
+
def find_watir_pages(identifier, page_class)
|
1082
|
+
identifier, frame_identifiers = parse_identifiers(identifier, Elements::Element, 'element')
|
1083
|
+
elements = @browser.instance_eval "#{nested_frames(frame_identifiers)}elements(identifier)"
|
1084
|
+
switch_to_default_content(frame_identifiers)
|
1085
|
+
elements.map { |element| page_class.new(element) }
|
1086
|
+
end
|
1087
|
+
|
1088
|
+
def find_watir_page(identifier, page_class)
|
1089
|
+
identifier, frame_identifiers = parse_identifiers(identifier, Elements::Element, 'element')
|
1090
|
+
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}element(identifier)"
|
1091
|
+
switch_to_default_content(frame_identifiers)
|
1092
|
+
page_class.new(element)
|
1093
|
+
end
|
1094
|
+
|
1095
|
+
def process_watir_call(the_call, type, identifier, value=nil, tag_name=nil)
|
1096
|
+
identifier, frame_identifiers = parse_identifiers(identifier, type, tag_name)
|
1097
|
+
value = @browser.instance_eval "#{nested_frames(frame_identifiers)}#{the_call}"
|
1098
|
+
switch_to_default_content(frame_identifiers)
|
1099
|
+
value
|
1100
|
+
end
|
1101
|
+
|
1102
|
+
def parse_identifiers(identifier, element, tag_name=nil)
|
1103
|
+
new_identifiers = identifier.dup
|
1104
|
+
frame_identifiers = new_identifiers.delete(:frame)
|
1105
|
+
return new_identifiers, frame_identifiers
|
1106
|
+
end
|
1107
|
+
|
1108
|
+
def nested_frames(frame_identifiers)
|
1109
|
+
return if frame_identifiers.nil?
|
1110
|
+
frame_str = ''
|
1111
|
+
frame_identifiers.each do |frame|
|
1112
|
+
type = frame.keys.first
|
1113
|
+
identifier = frame.values.first.map do |key, value|
|
1114
|
+
if value.is_a?(Regexp)
|
1115
|
+
":#{key} => #{value.inspect}"
|
1116
|
+
elsif value.is_a?(Integer) || value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
1117
|
+
":#{key} => #{value}"
|
1118
|
+
else
|
1119
|
+
":#{key} => '#{value}'"
|
1120
|
+
end
|
1121
|
+
end.join(', ')
|
1122
|
+
frame_str += "#{type.to_s}(#{identifier})."
|
1123
|
+
end
|
1124
|
+
frame_str
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
def switch_to_default_content(frame_identifiers)
|
1128
|
+
@browser.browser.wd.switch_to.default_content unless frame_identifiers.nil?
|
1129
|
+
end
|
1130
|
+
|
1131
|
+
def switch_to_frame(frame_identifiers)
|
1132
|
+
unless frame_identifiers.nil?
|
1133
|
+
frame_identifiers.each do |frame|
|
1134
|
+
frame_id = frame.values.first
|
1135
|
+
value = frame_id.values.first
|
1136
|
+
@browser.wd.switch_to.frame(value)
|
1137
|
+
end
|
1138
|
+
end
|
1139
|
+
end
|
1140
|
+
|
1141
|
+
def self.define_widget_multiple_accessor(base_element_tag, widget_class, widget_tag)
|
1142
|
+
send(:define_method, "#{widget_tag}s_for") do |identifier|
|
1143
|
+
find_watir_elements("#{base_element_tag}s(identifier)", widget_class, identifier, base_element_tag)
|
1144
|
+
end
|
1145
|
+
end
|
1146
|
+
|
1147
|
+
def self.define_widget_singular_accessor(base_element_tag, widget_class, widget_tag)
|
1148
|
+
send(:define_method, "#{widget_tag}_for") do |identifier|
|
1149
|
+
find_watir_element("#{base_element_tag}(identifier)", widget_class, identifier, base_element_tag)
|
1150
|
+
end
|
1151
|
+
end
|
1152
|
+
end
|
1153
|
+
end
|
1154
|
+
end
|
1155
|
+
end
|