page-object 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +25 -0
- data/Rakefile +3 -3
- data/features/element.feature +232 -1
- data/features/frames.feature +1 -1
- data/features/html/modal.html +17 -0
- data/features/html/modal_1.html +38 -0
- data/features/html/modal_2.html +27 -0
- data/features/html/nested_elements.html +42 -0
- data/features/html/static_elements.html +1 -0
- data/features/modal_dialog.feature +15 -0
- data/features/nested_elements.feature +73 -0
- data/features/step_definitions/frames_steps.rb +1 -1
- data/features/step_definitions/modal_dialog_steps.rb +62 -0
- data/features/step_definitions/nested_elements_steps.rb +165 -0
- data/features/support/page.rb +1 -0
- data/features/support/url_helper.rb +8 -0
- data/lib/page-object.rb +26 -0
- data/lib/page-object/accessors.rb +36 -36
- data/lib/page-object/elements/button.rb +3 -3
- data/lib/page-object/elements/check_box.rb +7 -7
- data/lib/page-object/elements/element.rb +16 -10
- data/lib/page-object/elements/form.rb +7 -7
- data/lib/page-object/elements/image.rb +7 -7
- data/lib/page-object/elements/link.rb +3 -3
- data/lib/page-object/elements/ordered_list.rb +7 -7
- data/lib/page-object/elements/radio_button.rb +7 -7
- data/lib/page-object/elements/select_list.rb +7 -7
- data/lib/page-object/elements/table.rb +7 -7
- data/lib/page-object/elements/table_row.rb +7 -7
- data/lib/page-object/elements/text_area.rb +7 -7
- data/lib/page-object/elements/text_field.rb +7 -7
- data/lib/page-object/elements/unordered_list.rb +7 -7
- data/lib/page-object/nested_elements.rb +72 -0
- data/lib/page-object/platforms.rb +2 -2
- data/lib/page-object/platforms/selenium_webdriver.rb +17 -0
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/button.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/check_box.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/element.rb +1 -1
- data/lib/page-object/platforms/{watir → selenium_webdriver}/form.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/image.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/link.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/ordered_list.rb +2 -2
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/page_object.rb +59 -59
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/radio_button.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/select_list.rb +2 -2
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/table.rb +2 -2
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/table_row.rb +2 -2
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/text_area.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/text_field.rb +1 -1
- data/lib/page-object/platforms/{selenium → selenium_webdriver}/unordered_list.rb +2 -2
- data/lib/page-object/platforms/watir_webdriver.rb +17 -0
- data/lib/page-object/platforms/{watir → watir_webdriver}/check_box.rb +1 -1
- data/lib/page-object/platforms/{watir → watir_webdriver}/element.rb +1 -1
- data/lib/page-object/platforms/{selenium → watir_webdriver}/form.rb +1 -1
- data/lib/page-object/platforms/{watir → watir_webdriver}/image.rb +1 -1
- data/lib/page-object/platforms/{watir → watir_webdriver}/ordered_list.rb +2 -2
- data/lib/page-object/platforms/watir_webdriver/page_object.rb +486 -0
- data/lib/page-object/platforms/{watir → watir_webdriver}/radio_button.rb +1 -1
- data/lib/page-object/platforms/{watir → watir_webdriver}/select_list.rb +3 -3
- data/lib/page-object/platforms/{watir → watir_webdriver}/table.rb +2 -2
- data/lib/page-object/platforms/{watir → watir_webdriver}/table_row.rb +2 -2
- data/lib/page-object/platforms/{watir → watir_webdriver}/text_area.rb +1 -1
- data/lib/page-object/platforms/{watir → watir_webdriver}/text_field.rb +1 -1
- data/lib/page-object/platforms/{watir → watir_webdriver}/unordered_list.rb +2 -2
- data/lib/page-object/version.rb +1 -1
- data/page-object.gemspec +1 -1
- data/spec/page-object/elements/button_spec.rb +1 -1
- data/spec/page-object/elements/check_box_spec.rb +1 -1
- data/spec/page-object/elements/element_spec.rb +9 -5
- data/spec/page-object/elements/form_spec.rb +2 -2
- data/spec/page-object/elements/image_spec.rb +4 -4
- data/spec/page-object/elements/link_spec.rb +1 -1
- data/spec/page-object/elements/nested_element_spec.rb +185 -0
- data/spec/page-object/elements/ordered_list_spec.rb +6 -6
- data/spec/page-object/elements/radio_button_spec.rb +1 -1
- data/spec/page-object/elements/select_list_spec.rb +5 -5
- data/spec/page-object/elements/table_row_spec.rb +6 -6
- data/spec/page-object/elements/table_spec.rb +2 -2
- data/spec/page-object/elements/text_area_spec.rb +1 -1
- data/spec/page-object/elements/text_field_spec.rb +1 -1
- data/spec/page-object/elements/unordered_list_spec.rb +6 -6
- data/spec/page-object/page-object_spec.rb +12 -2
- data/spec/page-object/platforms/{selenium → selenium_webdriver}/selenium_page_object_spec.rb +2 -2
- data/spec/page-object/platforms/selenium_webdriver_spec.rb +29 -0
- data/spec/page-object/platforms/{watir_spec.rb → watir_webdriver_spec.rb} +11 -6
- metadata +58 -39
- data/lib/page-object/platforms/selenium.rb +0 -16
- data/lib/page-object/platforms/watir.rb +0 -16
- data/lib/page-object/platforms/watir/page_object.rb +0 -482
- data/spec/page-object/platforms/selenium_spec.rb +0 -26
@@ -1,16 +0,0 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Platforms
|
3
|
-
module Selenium
|
4
|
-
|
5
|
-
def self.create_page_object(browser)
|
6
|
-
require 'page-object/platforms/selenium/page_object'
|
7
|
-
return Object::PageObject::Platforms::Selenium::PageObject.new(browser)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.is_for?(browser)
|
11
|
-
browser.is_a? Object::Selenium::WebDriver::Driver
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
PageObject::Platforms.register(:selenium, PageObject::Platforms::Selenium)
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module PageObject
|
2
|
-
module Platforms
|
3
|
-
module Watir
|
4
|
-
def self.create_page_object(browser)
|
5
|
-
require 'page-object/platforms/watir/page_object'
|
6
|
-
PageObject::WatirPageObject.new(browser)
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.is_for?(browser)
|
10
|
-
browser.is_a?(Object::Watir::Browser)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
PageObject::Platforms.register(:watir, PageObject::Platforms::Watir)
|
@@ -1,482 +0,0 @@
|
|
1
|
-
require 'watir-webdriver/extensions/alerts'
|
2
|
-
require 'page-object/elements'
|
3
|
-
require 'page-object/core_ext/string'
|
4
|
-
|
5
|
-
|
6
|
-
module PageObject
|
7
|
-
#
|
8
|
-
# Watir implementation of the page object platform driver. You should not use the
|
9
|
-
# class directly. Instead you should include the PageObject module in your page object
|
10
|
-
# and use the methods dynamically added from the PageObject::Accessors module.
|
11
|
-
#
|
12
|
-
class WatirPageObject
|
13
|
-
attr_reader :browser
|
14
|
-
|
15
|
-
def initialize(browser)
|
16
|
-
@browser = browser
|
17
|
-
end
|
18
|
-
|
19
|
-
#
|
20
|
-
# platform method to navigate to a provided url
|
21
|
-
# See PageObject#navigate_to
|
22
|
-
#
|
23
|
-
def navigate_to(url)
|
24
|
-
@browser.goto url
|
25
|
-
end
|
26
|
-
|
27
|
-
#
|
28
|
-
# platform method to retrieve the text from the current page
|
29
|
-
# See PageObject#text
|
30
|
-
#
|
31
|
-
def text
|
32
|
-
@browser.text
|
33
|
-
end
|
34
|
-
|
35
|
-
#
|
36
|
-
# platform method to retrieve the html for the current page
|
37
|
-
# See PageObject#html
|
38
|
-
#
|
39
|
-
def html
|
40
|
-
@browser.html
|
41
|
-
end
|
42
|
-
|
43
|
-
#
|
44
|
-
# platform method to retrieve the title for the current page
|
45
|
-
# See PageObject#title
|
46
|
-
#
|
47
|
-
def title
|
48
|
-
@browser.title
|
49
|
-
end
|
50
|
-
|
51
|
-
#
|
52
|
-
# platform method to wait for a block to return true
|
53
|
-
# See PageObject#wait_until
|
54
|
-
def wait_until(timeout, message = nil, &block)
|
55
|
-
@browser.wait_until(timeout, message, &block)
|
56
|
-
end
|
57
|
-
|
58
|
-
#
|
59
|
-
# platform method to handle an alert popup
|
60
|
-
# See PageObject#alert
|
61
|
-
#
|
62
|
-
def alert(&block)
|
63
|
-
@browser.alert(&block)
|
64
|
-
end
|
65
|
-
|
66
|
-
#
|
67
|
-
# platform method to handle a confirm popup
|
68
|
-
# See PageObject#confirm
|
69
|
-
#
|
70
|
-
def confirm(response, &block)
|
71
|
-
@browser.confirm(response, &block)
|
72
|
-
end
|
73
|
-
|
74
|
-
#
|
75
|
-
# platform method to handle a prompt popup
|
76
|
-
# See PageObject#prompt
|
77
|
-
#
|
78
|
-
def prompt(answer, &block)
|
79
|
-
@browser.prompt(answer, &block)
|
80
|
-
end
|
81
|
-
|
82
|
-
#
|
83
|
-
# platform method to handle attaching to a running window
|
84
|
-
# See PageObject#attach_to_window
|
85
|
-
#
|
86
|
-
def attach_to_window(identifier, &block)
|
87
|
-
win_id = {identifier.keys.first => /#{Regexp.escape(identifier.values.first)}/}
|
88
|
-
@browser.window(win_id).use &block
|
89
|
-
end
|
90
|
-
|
91
|
-
#
|
92
|
-
# platform method to refresh the page
|
93
|
-
# See PageObject#refresh
|
94
|
-
#
|
95
|
-
def refresh
|
96
|
-
@browser.refresh
|
97
|
-
end
|
98
|
-
|
99
|
-
#
|
100
|
-
# platform method to go back to the previous page
|
101
|
-
# See PageObject#back
|
102
|
-
#
|
103
|
-
def back
|
104
|
-
@browser.back
|
105
|
-
end
|
106
|
-
|
107
|
-
#
|
108
|
-
# platform method to go forward to the next page
|
109
|
-
# See PageObject#forward
|
110
|
-
#
|
111
|
-
def forward
|
112
|
-
@browser.forward
|
113
|
-
end
|
114
|
-
|
115
|
-
#
|
116
|
-
# platform method to get the value stored in a text field
|
117
|
-
# See PageObject::Accessors#text_field
|
118
|
-
#
|
119
|
-
def text_field_value_for(identifier)
|
120
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::TextField)
|
121
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}text_field(identifier).value"
|
122
|
-
end
|
123
|
-
|
124
|
-
#
|
125
|
-
# platform method to set the value for a text field
|
126
|
-
# See PageObject::Accessors#text_field
|
127
|
-
#
|
128
|
-
def text_field_value_set(identifier, value)
|
129
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::TextField)
|
130
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}text_field(identifier).set(value)"
|
131
|
-
end
|
132
|
-
|
133
|
-
#
|
134
|
-
# platform method to retrieve a text field element
|
135
|
-
# See PageObject::Accessors#text_field
|
136
|
-
#
|
137
|
-
def text_field_for(identifier)
|
138
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::TextField)
|
139
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}text_field(identifier)"
|
140
|
-
Elements::TextField.new(element, :platform => :watir)
|
141
|
-
end
|
142
|
-
|
143
|
-
#
|
144
|
-
# platform method to get the value stored in a hidden field
|
145
|
-
# See PageObject::Accessors#hidden_field
|
146
|
-
#
|
147
|
-
def hidden_field_value_for(identifier)
|
148
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::HiddenField)
|
149
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}hidden(identifier).value"
|
150
|
-
end
|
151
|
-
|
152
|
-
#
|
153
|
-
# platform method to retrieve a hidden field element
|
154
|
-
# See PageObject::Accessors#hidden_field
|
155
|
-
#
|
156
|
-
def hidden_field_for(identifier)
|
157
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::HiddenField)
|
158
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}hidden(identifier)"
|
159
|
-
Elements::HiddenField.new(element, :platform => :watir)
|
160
|
-
end
|
161
|
-
|
162
|
-
#
|
163
|
-
# platform method to set text in a textarea
|
164
|
-
# See PageObject::Accessors#text_area
|
165
|
-
#
|
166
|
-
def text_area_value_set(identifier, value)
|
167
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::TextArea)
|
168
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}textarea(identifier).send_keys(value)"
|
169
|
-
end
|
170
|
-
|
171
|
-
#
|
172
|
-
# platform method to get the text from a textarea
|
173
|
-
# See PageObject::Accessors#text_area
|
174
|
-
#
|
175
|
-
def text_area_value_for(identifier)
|
176
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::TextArea)
|
177
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}textarea(identifier).value"
|
178
|
-
end
|
179
|
-
|
180
|
-
#
|
181
|
-
# platform method to get the text area element
|
182
|
-
# See PageObject::Accessors#text_area
|
183
|
-
#
|
184
|
-
def text_area_for(identifier)
|
185
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::TextArea)
|
186
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}textarea(identifier)"
|
187
|
-
Elements::TextArea.new(element, :platform => :watir)
|
188
|
-
end
|
189
|
-
|
190
|
-
#
|
191
|
-
# platform method to get the currently selected value from a select list
|
192
|
-
# See PageObject::Accessors#select_list
|
193
|
-
#
|
194
|
-
def select_list_value_for(identifier)
|
195
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::SelectList)
|
196
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}select_list(identifier).value"
|
197
|
-
end
|
198
|
-
|
199
|
-
#
|
200
|
-
# platform method to select a value from a select list
|
201
|
-
# See PageObject::Accessors#select_list
|
202
|
-
#
|
203
|
-
def select_list_value_set(identifier, value)
|
204
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::SelectList)
|
205
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}select_list(identifier).select(value)"
|
206
|
-
end
|
207
|
-
|
208
|
-
#
|
209
|
-
# platform method to return the select list element
|
210
|
-
# See PageObject::Accessors#select_list
|
211
|
-
#
|
212
|
-
def select_list_for(identifier)
|
213
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::SelectList)
|
214
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}select_list(identifier)"
|
215
|
-
Elements::SelectList.new(element, :platform => :watir)
|
216
|
-
end
|
217
|
-
|
218
|
-
#
|
219
|
-
# platform method to click a link
|
220
|
-
# See PageObject::Accessors#link
|
221
|
-
#
|
222
|
-
def click_link_for(identifier)
|
223
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::Link)
|
224
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}link(identifier).click if identifier"
|
225
|
-
end
|
226
|
-
|
227
|
-
#
|
228
|
-
# platform method to return a PageObject::Elements::Link object
|
229
|
-
# see PageObject::Accessors#link
|
230
|
-
#
|
231
|
-
def link_for(identifier)
|
232
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::Link)
|
233
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}link(identifier)"
|
234
|
-
Elements::Link.new(element, :platform => :watir)
|
235
|
-
end
|
236
|
-
|
237
|
-
#
|
238
|
-
# platform method to check a checkbox
|
239
|
-
# See PageObject::Accessors#checkbox
|
240
|
-
#
|
241
|
-
def check_checkbox(identifier)
|
242
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::CheckBox)
|
243
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}checkbox(identifier).set"
|
244
|
-
end
|
245
|
-
|
246
|
-
#
|
247
|
-
# platform method to uncheck a checkbox
|
248
|
-
# See PageObject::Accessors#checkbox
|
249
|
-
#
|
250
|
-
def uncheck_checkbox(identifier)
|
251
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::CheckBox)
|
252
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}checkbox(identifier).clear"
|
253
|
-
end
|
254
|
-
|
255
|
-
#
|
256
|
-
# platform method to determine if a checkbox is checked
|
257
|
-
# See PageObject::Accessors#checkbox
|
258
|
-
#
|
259
|
-
def checkbox_checked?(identifier)
|
260
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::CheckBox)
|
261
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}checkbox(identifier).set?"
|
262
|
-
end
|
263
|
-
|
264
|
-
#
|
265
|
-
# platform method to return a PageObject::Elements::CheckBox element
|
266
|
-
# See PageObject::Accessors#checkbox
|
267
|
-
#
|
268
|
-
def checkbox_for(identifier)
|
269
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::CheckBox)
|
270
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}checkbox(identifier)"
|
271
|
-
Elements::CheckBox.new(element, :platform => :watir)
|
272
|
-
end
|
273
|
-
|
274
|
-
#
|
275
|
-
# platform method to select a radio button
|
276
|
-
# See PageObject::Accessors#radio_button
|
277
|
-
#
|
278
|
-
def select_radio(identifier)
|
279
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::RadioButton)
|
280
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}radio(identifier).set"
|
281
|
-
end
|
282
|
-
|
283
|
-
#
|
284
|
-
# platform method to clear a radio button
|
285
|
-
# See PageObject::Accessors#radio_button
|
286
|
-
#
|
287
|
-
def clear_radio(identifier)
|
288
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::RadioButton)
|
289
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}radio(identifier).clear"
|
290
|
-
end
|
291
|
-
|
292
|
-
#
|
293
|
-
# platform method to determine if a radio button is selected
|
294
|
-
# See PageObject::Accessors#radio_button
|
295
|
-
#
|
296
|
-
def radio_selected?(identifier)
|
297
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::RadioButton)
|
298
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}radio(identifier).set?"
|
299
|
-
end
|
300
|
-
|
301
|
-
#
|
302
|
-
# platform method to return a PageObject::Eements::RadioButton element
|
303
|
-
# See PageObject::Accessors#radio_button
|
304
|
-
#
|
305
|
-
def radio_button_for(identifier)
|
306
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::RadioButton)
|
307
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}radio(identifier)"
|
308
|
-
PageObject::Elements::RadioButton.new(element, :platform => :watir)
|
309
|
-
end
|
310
|
-
|
311
|
-
#
|
312
|
-
# platform method to return the text for a div
|
313
|
-
# See PageObject::Accessors#div
|
314
|
-
#
|
315
|
-
def div_text_for(identifier)
|
316
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::Div, 'div')
|
317
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}div(identifier).text"
|
318
|
-
end
|
319
|
-
|
320
|
-
#
|
321
|
-
# platform method to return a PageObject::Elements::Div element
|
322
|
-
# See PageObject::Accessors#div
|
323
|
-
#
|
324
|
-
def div_for(identifier)
|
325
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::Div, 'div')
|
326
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}div(identifier)"
|
327
|
-
PageObject::Elements::Div.new(element, :platform => :watir)
|
328
|
-
end
|
329
|
-
|
330
|
-
#
|
331
|
-
# platform method to return the text for a span
|
332
|
-
# See PageObject::Accessors#span
|
333
|
-
#
|
334
|
-
def span_text_for(identifier)
|
335
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::Span, 'span')
|
336
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}span(identifier).text"
|
337
|
-
end
|
338
|
-
|
339
|
-
#
|
340
|
-
# platform method to return a PageObject::Elements::Span element
|
341
|
-
# See PageObject::Accessors#span
|
342
|
-
#
|
343
|
-
def span_for(identifier)
|
344
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::Span, 'span')
|
345
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}span(identifier)"
|
346
|
-
PageObject::Elements::Span.new(element, :platform => :watir)
|
347
|
-
end
|
348
|
-
|
349
|
-
#
|
350
|
-
# platform method to click a button
|
351
|
-
# See PageObject::Accessors#button
|
352
|
-
#
|
353
|
-
def click_button_for(identifier)
|
354
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::Button)
|
355
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}button(identifier).click"
|
356
|
-
end
|
357
|
-
|
358
|
-
#
|
359
|
-
# platform method to retrieve a button element
|
360
|
-
# See PageObject::Accessors#button
|
361
|
-
#
|
362
|
-
def button_for(identifier)
|
363
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::Button)
|
364
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}button(identifier)"
|
365
|
-
PageObject::Elements::Button.new(element, :platform => :watir)
|
366
|
-
end
|
367
|
-
|
368
|
-
#
|
369
|
-
# platform method to retrieve a table element
|
370
|
-
# See PageObject::Accessors#table
|
371
|
-
#
|
372
|
-
def table_for(identifier)
|
373
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::Table, 'table')
|
374
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}table(identifier)"
|
375
|
-
PageObject::Elements::Table.new(element, :platform => :watir)
|
376
|
-
end
|
377
|
-
|
378
|
-
#
|
379
|
-
# platform method to retrieve the text from a table cell
|
380
|
-
# See PageObject::Accessors#cell
|
381
|
-
#
|
382
|
-
def cell_text_for(identifier)
|
383
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::TableCell, 'td')
|
384
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}td(identifier).text"
|
385
|
-
end
|
386
|
-
|
387
|
-
#
|
388
|
-
# platform method to retrieve a table cell element
|
389
|
-
# See PageObject::Accessors#cell
|
390
|
-
#
|
391
|
-
def cell_for(identifier)
|
392
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::TableCell, 'td')
|
393
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}td(identifier)"
|
394
|
-
PageObject::Elements::TableCell.new(element, :platform => :watir)
|
395
|
-
end
|
396
|
-
|
397
|
-
#
|
398
|
-
# platform method to retrieve an image element
|
399
|
-
# See PageObject::Accessors#image
|
400
|
-
#
|
401
|
-
def image_for(identifier)
|
402
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::Image)
|
403
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}image(identifier)"
|
404
|
-
PageObject::Elements::Image.new(element, :platform => :watir)
|
405
|
-
end
|
406
|
-
|
407
|
-
#
|
408
|
-
# platform method to retrieve a form element
|
409
|
-
# See PageObject::Accessors#form
|
410
|
-
#
|
411
|
-
def form_for(identifier)
|
412
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::Form)
|
413
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}form(identifier)"
|
414
|
-
PageObject::Elements::Form.new(element, :platform => :watir)
|
415
|
-
end
|
416
|
-
|
417
|
-
#
|
418
|
-
# platform method to retrieve the text from a list item
|
419
|
-
# See PageObject::Accessors#list_item
|
420
|
-
#
|
421
|
-
def list_item_text_for(identifier)
|
422
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::ListItem, 'li')
|
423
|
-
@browser.instance_eval "#{nested_frames(frame_identifiers)}li(identifier).text"
|
424
|
-
end
|
425
|
-
|
426
|
-
#
|
427
|
-
# platform method to retrieve a list item element
|
428
|
-
# See PageObject::Accessors#list_item
|
429
|
-
#
|
430
|
-
def list_item_for(identifier)
|
431
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::ListItem, 'li')
|
432
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}li(identifier)"
|
433
|
-
PageObject::Elements::ListItem.new(element, :platform => :watir)
|
434
|
-
end
|
435
|
-
|
436
|
-
#
|
437
|
-
# platform method to retrieve an unordered list element
|
438
|
-
# See PageObject::Accessors#unordered_list
|
439
|
-
#
|
440
|
-
def unordered_list_for(identifier)
|
441
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::UnorderedList, 'ul')
|
442
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}ul(identifier)"
|
443
|
-
PageObject::Elements::UnorderedList.new(element, :platform => :watir)
|
444
|
-
end
|
445
|
-
|
446
|
-
#
|
447
|
-
# platform method to retrieve an ordered list element
|
448
|
-
# See PageObject::Accessors#ordered_list
|
449
|
-
#
|
450
|
-
def ordered_list_for(identifier)
|
451
|
-
identifier, frame_identifiers = parse_identifiers(identifier, Elements::OrderedList, 'ol')
|
452
|
-
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}ol(identifier)"
|
453
|
-
PageObject::Elements::OrderedList.new(element, :platform => :watir)
|
454
|
-
end
|
455
|
-
|
456
|
-
private
|
457
|
-
|
458
|
-
def parse_identifiers(identifier, element, tag_name=nil)
|
459
|
-
frame_identifiers = identifier.delete(:frame)
|
460
|
-
identifier = add_tagname_if_needed identifier, tag_name if tag_name
|
461
|
-
identifier = element.watir_identifier_for identifier
|
462
|
-
return identifier, frame_identifiers
|
463
|
-
end
|
464
|
-
|
465
|
-
def add_tagname_if_needed identifier, tag
|
466
|
-
return identifier if identifier.length < 2 and not identifier[:name]
|
467
|
-
identifier[:tag_name] = tag if identifier[:name]
|
468
|
-
identifier
|
469
|
-
end
|
470
|
-
|
471
|
-
def nested_frames(frame_identifiers)
|
472
|
-
return if frame_identifiers.nil?
|
473
|
-
frame_str = ''
|
474
|
-
frame_identifiers.each do |id|
|
475
|
-
value = id.values.first
|
476
|
-
frame_str += "frame(:#{id.keys.first} => #{value})." if value.to_s.is_integer
|
477
|
-
frame_str += "frame(:#{id.keys.first} => '#{value}')." unless value.to_s.is_integer
|
478
|
-
end
|
479
|
-
frame_str
|
480
|
-
end
|
481
|
-
end
|
482
|
-
end
|