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