druid-ts 0.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -0
  3. data/.rspec +1 -0
  4. data/.rvmrc +1 -0
  5. data/.travis.yml +1 -2
  6. data/ChangeLog +218 -0
  7. data/Gemfile +2 -1
  8. data/README.md +64 -7
  9. data/Rakefile +1 -1
  10. data/druid.gemspec +25 -0
  11. data/features/async.feature +18 -0
  12. data/features/button.feature +42 -1
  13. data/features/checkbox.feature +7 -1
  14. data/features/div.feature +6 -0
  15. data/features/element.feature +100 -0
  16. data/features/file_field.feature +35 -0
  17. data/features/form.feature +12 -6
  18. data/features/frames.feature +57 -0
  19. data/features/heading.feature +164 -0
  20. data/features/hidden_field.feature +6 -0
  21. data/features/html/async.html +18 -0
  22. data/features/html/frame_1.html +18 -0
  23. data/features/html/frame_2.html +16 -0
  24. data/features/html/frame_3.html +14 -0
  25. data/features/html/frames.html +12 -0
  26. data/features/html/iframes.html +12 -0
  27. data/features/html/modal.html +17 -0
  28. data/features/html/modal_1.html +38 -0
  29. data/features/html/modal_2.html +27 -0
  30. data/features/html/nested_elements.html +52 -0
  31. data/features/html/nested_frame_1.html +1 -0
  32. data/features/html/nested_frame_2.html +11 -0
  33. data/features/html/nested_frame_3.html +14 -0
  34. data/features/html/nested_frames.html +10 -0
  35. data/features/html/static_elements.html +29 -23
  36. data/features/image.feature +8 -0
  37. data/features/link.feature +5 -0
  38. data/features/list_item.feature +5 -0
  39. data/features/modal_dialog.feature +9 -0
  40. data/features/nested_elements.feature +105 -0
  41. data/features/ordered_list.feature +6 -0
  42. data/features/page_level_actions.feature +48 -0
  43. data/features/paragraph.feature +33 -0
  44. data/features/radio_button.feature +6 -0
  45. data/features/select_list.feature +6 -1
  46. data/features/span.feature +6 -1
  47. data/features/step_definations/async_steps.rb +63 -0
  48. data/features/step_definations/button_steps.rb +25 -1
  49. data/features/step_definations/checkbox_steps.rb +5 -1
  50. data/features/step_definations/div_steps.rb +6 -1
  51. data/features/step_definations/element_steps.rb +55 -1
  52. data/features/step_definations/file_field_steps.rb +27 -0
  53. data/features/step_definations/form_steps.rb +8 -0
  54. data/features/step_definations/frame_steps.rb +112 -0
  55. data/features/step_definations/heading_steps.rb +39 -0
  56. data/features/step_definations/hidden_field_steps.rb +7 -3
  57. data/features/step_definations/image_steps.rb +7 -3
  58. data/features/step_definations/link_steps.rb +8 -3
  59. data/features/step_definations/list_item_steps.rb +9 -1
  60. data/features/step_definations/modal_dialog_steps.rb +38 -0
  61. data/features/step_definations/nested_elements_steps.rb +196 -0
  62. data/features/step_definations/ordered_list_steps.rb +11 -3
  63. data/features/step_definations/page_level_actions_steps.rb +72 -0
  64. data/features/step_definations/paragraph_steps.rb +15 -0
  65. data/features/step_definations/radio_button_steps.rb +5 -1
  66. data/features/step_definations/select_list_steps.rb +10 -2
  67. data/features/step_definations/span_steps.rb +5 -1
  68. data/features/step_definations/table_cell_steps.rb +5 -1
  69. data/features/step_definations/table_steps.rb +17 -3
  70. data/features/step_definations/text_area_steps.rb +18 -2
  71. data/features/step_definations/text_field_steps.rb +9 -1
  72. data/features/step_definations/unordered_list_steps.rb +11 -3
  73. data/features/support/env.rb +0 -15
  74. data/features/support/hooks.rb +7 -0
  75. data/features/support/page.rb +98 -1
  76. data/features/support/persistent_browser.rb +15 -0
  77. data/features/support/url_helper.rb +24 -1
  78. data/features/table.feature +7 -0
  79. data/features/table_cell.feature +6 -0
  80. data/features/text_area.feature +11 -0
  81. data/features/text_field.feature +6 -1
  82. data/features/unordered_list.feature +6 -0
  83. data/lib/druid.rb +251 -3
  84. data/lib/druid/accessors.rb +446 -158
  85. data/lib/druid/assist.rb +394 -0
  86. data/lib/druid/core_ext/string.rb +5 -0
  87. data/lib/druid/element_locators.rb +405 -0
  88. data/lib/druid/elements.rb +28 -0
  89. data/lib/druid/elements/button.rb +6 -1
  90. data/lib/druid/elements/check_box.rb +26 -0
  91. data/lib/druid/elements/div.rb +3 -1
  92. data/lib/druid/elements/element.rb +170 -5
  93. data/lib/druid/elements/file_field.rb +18 -0
  94. data/lib/druid/elements/form.rb +11 -0
  95. data/lib/druid/elements/heading.rb +14 -0
  96. data/lib/druid/elements/hidden_field.rb +12 -2
  97. data/lib/druid/elements/image.rb +13 -0
  98. data/lib/druid/elements/link.rb +2 -0
  99. data/lib/druid/elements/list_item.rb +3 -1
  100. data/lib/druid/elements/option.rb +9 -0
  101. data/lib/druid/elements/ordered_list.rb +4 -5
  102. data/lib/druid/elements/paragraph.rb +9 -0
  103. data/lib/druid/elements/radio_button.rb +25 -0
  104. data/lib/druid/elements/select_list.rb +10 -1
  105. data/lib/druid/elements/span.rb +3 -1
  106. data/lib/druid/elements/table.rb +20 -1
  107. data/lib/druid/elements/table_cell.rb +7 -0
  108. data/lib/druid/elements/table_row.rb +5 -1
  109. data/lib/druid/elements/text_area.rb +15 -1
  110. data/lib/druid/elements/text_field.rb +11 -1
  111. data/lib/druid/elements/unordered_list.rb +5 -5
  112. data/lib/druid/nested_elements.rb +103 -0
  113. data/lib/druid/page_factory.rb +4 -4
  114. data/lib/druid/page_populator.rb +71 -0
  115. data/spec/druid/accessors_spec.rb +789 -0
  116. data/spec/druid/druid_spec.rb +130 -7
  117. data/spec/druid/element_locators_spec.rb +160 -0
  118. data/spec/druid/elements/button_spec.rb +31 -0
  119. data/spec/druid/elements/check_box_spec.rb +38 -0
  120. data/spec/druid/elements/div_spec.rb +19 -0
  121. data/spec/druid/elements/element_spec.rb +150 -0
  122. data/spec/druid/elements/file_field_spec.rb +27 -0
  123. data/spec/druid/elements/form_spec.rb +27 -0
  124. data/spec/druid/elements/heading_spec.rb +39 -0
  125. data/spec/druid/elements/hidden_field_spec.rb +24 -0
  126. data/spec/druid/elements/image_spec.rb +32 -0
  127. data/spec/druid/elements/link_spec.rb +26 -0
  128. data/spec/druid/elements/list_item_spec.rb +19 -0
  129. data/spec/druid/elements/option_spec.rb +10 -0
  130. data/spec/druid/elements/ordered_list_spec.rb +42 -0
  131. data/spec/druid/elements/page_factory_spec.rb +40 -0
  132. data/spec/druid/elements/paragraph_spec.rb +21 -0
  133. data/spec/druid/elements/radio_button_spec.rb +38 -0
  134. data/spec/druid/elements/select_list_spec.rb +37 -0
  135. data/spec/druid/elements/span_spec.rb +19 -0
  136. data/spec/druid/elements/table_cell_spec.rb +23 -0
  137. data/spec/druid/elements/table_row_spec.rb +41 -0
  138. data/spec/druid/elements/table_spec.rb +52 -0
  139. data/spec/druid/elements/text_area_spec.rb +31 -0
  140. data/spec/druid/elements/text_field_spec.rb +31 -0
  141. data/spec/druid/elements/unordered_list_spec.rb +42 -0
  142. data/spec/druid/nested_element_spec.rb +128 -0
  143. data/spec/druid/page_populator_spec.rb +92 -0
  144. data/spec/spec_helper.rb +2 -1
  145. metadata +147 -27
@@ -0,0 +1,394 @@
1
+ module Druid
2
+ module Assist
3
+ def click_link_for identifier
4
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Link)
5
+ driver.instance_eval "#{nested_frames(frame_identifiers)}link(identifier).click"
6
+ switch_to_default_content(frame_identifiers)
7
+ end
8
+
9
+ def link_for identifier
10
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Link)
11
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}link(identifier)"
12
+ switch_to_default_content(frame_identifiers)
13
+ Elements::Link.new element
14
+ end
15
+
16
+ def text_field_for identifier
17
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::TextField)
18
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}text_field(identifier)"
19
+ switch_to_default_content(frame_identifiers)
20
+ Elements::TextField.new element
21
+ end
22
+
23
+ def text_field_value_for identifier
24
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::TextField)
25
+ value = driver.instance_eval "#{nested_frames(frame_identifiers)}text_field(identifier).value"
26
+ switch_to_default_content(frame_identifiers)
27
+ value
28
+ end
29
+
30
+ def text_field_value_set identifier, value
31
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::TextField)
32
+ driver.instance_eval "#{nested_frames(frame_identifiers)}text_field(identifier).set(value)"
33
+ switch_to_default_content(frame_identifiers)
34
+ end
35
+
36
+ def check_checkbox identifier
37
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::CheckBox)
38
+ driver.instance_eval "#{nested_frames(frame_identifiers)}checkbox(identifier).set"
39
+ switch_to_default_content(frame_identifiers)
40
+ end
41
+
42
+ def uncheck_checkbox identifier
43
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::CheckBox)
44
+ driver.instance_eval "#{nested_frames(frame_identifiers)}checkbox(identifier).clear"
45
+ switch_to_default_content(frame_identifiers)
46
+ end
47
+
48
+ def checkbox_checked? identifier
49
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::CheckBox)
50
+ result = driver.instance_eval "#{nested_frames(frame_identifiers)}checkbox(identifier).set?"
51
+ switch_to_default_content(frame_identifiers)
52
+ result
53
+ end
54
+
55
+ def checkbox_for identifier
56
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::CheckBox)
57
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}checkbox(identifier)"
58
+ switch_to_default_content(frame_identifiers)
59
+ Elements::CheckBox.new element
60
+ end
61
+
62
+ def select_list_value_set identifier, value
63
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::SelectList)
64
+ driver.instance_eval "#{nested_frames(frame_identifiers)}select_list(identifier).select value"
65
+ switch_to_default_content(frame_identifiers)
66
+ end
67
+
68
+ def select_list_value_for identifier
69
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::SelectList)
70
+ value = driver.instance_eval "#{nested_frames(frame_identifiers)}select_list(identifier).value"
71
+ switch_to_default_content(frame_identifiers)
72
+ value
73
+ end
74
+
75
+ def select_list_for identifier
76
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::SelectList)
77
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}select_list(identifier)"
78
+ switch_to_default_content(frame_identifiers)
79
+ Elements::SelectList.new element
80
+ end
81
+
82
+ def select_radio identifier
83
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::RadioButton)
84
+ driver.instance_eval "#{nested_frames(frame_identifiers)}radio(identifier).set"
85
+ switch_to_default_content(frame_identifiers)
86
+ end
87
+
88
+ def clear_radio identifier
89
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::RadioButton)
90
+ driver.instance_eval "#{nested_frames(frame_identifiers)}radio(identifier).clear"
91
+ switch_to_default_content(frame_identifiers)
92
+ end
93
+
94
+ def radio_selected? identifier
95
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::RadioButton)
96
+ result = driver.instance_eval "#{nested_frames(frame_identifiers)}radio(identifier).set?"
97
+ switch_to_default_content(frame_identifiers)
98
+ result
99
+ end
100
+
101
+ def radio_button_for identifier
102
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::RadioButton)
103
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}radio(identifier)"
104
+ switch_to_default_content(frame_identifiers)
105
+ Elements::RadioButton.new element
106
+ end
107
+
108
+ def click_button_for identifier
109
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Button)
110
+ driver.instance_eval "#{nested_frames(frame_identifiers)}button(identifier).click"
111
+ switch_to_default_content(frame_identifiers)
112
+ end
113
+
114
+ def button_for identifier
115
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Button)
116
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}button(identifier)"
117
+ switch_to_default_content(frame_identifiers)
118
+ Elements::Button.new element
119
+ end
120
+
121
+ def div_text_for identifier
122
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Div, 'div')
123
+ text = driver.instance_eval "#{nested_frames(frame_identifiers)}div(identifier).text"
124
+ switch_to_default_content(frame_identifiers)
125
+ text
126
+ end
127
+
128
+ def div_for identifier
129
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Div, 'div')
130
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}div(identifier)"
131
+ switch_to_default_content(frame_identifiers)
132
+ Elements::Div.new element
133
+ end
134
+
135
+ def table_for identifier
136
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Table, 'table')
137
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}table(identifier)"
138
+ switch_to_default_content(frame_identifiers)
139
+ Elements::Table.new element
140
+ end
141
+
142
+ def cell_text_for identifier
143
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::TableCell, 'td')
144
+ text = driver.instance_eval "#{nested_frames(frame_identifiers)}td(identifier).text"
145
+ switch_to_default_content(frame_identifiers)
146
+ text
147
+ end
148
+
149
+ def cell_for identifier
150
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::TableCell, 'td')
151
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}td(identifier)"
152
+ switch_to_default_content(frame_identifiers)
153
+ Elements::TableCell.new element
154
+ end
155
+
156
+ def span_text_for identifier
157
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Span, 'span')
158
+ text = driver.instance_eval "#{nested_frames(frame_identifiers)}span(identifier).text"
159
+ switch_to_default_content(frame_identifiers)
160
+ text
161
+ end
162
+
163
+ def span_for identifier
164
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Span, 'span')
165
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}span(identifier)"
166
+ switch_to_default_content(frame_identifiers)
167
+ Elements::Span.new element
168
+ end
169
+
170
+ def image_for identifier
171
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Image)
172
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}image(identifier)"
173
+ switch_to_default_content(frame_identifiers)
174
+ Elements::Image.new element
175
+ end
176
+
177
+ def form_for identifier
178
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Form)
179
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}form(identifier)"
180
+ switch_to_default_content(frame_identifiers)
181
+ Elements::Form.new element
182
+ end
183
+
184
+ def hidden_field_value_for identifier
185
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::HiddenField)
186
+ value = driver.instance_eval "#{nested_frames(frame_identifiers)}hidden(identifier).value"
187
+ switch_to_default_content(frame_identifiers)
188
+ value
189
+ end
190
+
191
+ def hidden_field_for identifier
192
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::HiddenField)
193
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}hidden(identifier)"
194
+ switch_to_default_content(frame_identifiers)
195
+ Elements::HiddenField.new element
196
+ end
197
+
198
+ def list_item_text_for identifier
199
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::ListItem, 'li')
200
+ text = driver.instance_eval "#{nested_frames(frame_identifiers)}li(identifier).text"
201
+ switch_to_default_content(frame_identifiers)
202
+ text
203
+ end
204
+
205
+ def list_item_for identifier
206
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::ListItem, 'li')
207
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}li(identifier)"
208
+ switch_to_default_content(frame_identifiers)
209
+ Elements::ListItem.new element
210
+ end
211
+
212
+ def ordered_list_for identifier
213
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::OrderedList, 'ol')
214
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}ol(identifier)"
215
+ switch_to_default_content(frame_identifiers)
216
+ Elements::OrderedList.new element
217
+ end
218
+
219
+ def text_area_value_set identifier, value
220
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::TextArea)
221
+ driver.instance_eval "#{nested_frames(frame_identifiers)}textarea(identifier).send_keys value"
222
+ switch_to_default_content(frame_identifiers)
223
+ end
224
+
225
+ def text_area_value_for identifier
226
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::TextArea)
227
+ value = driver.instance_eval "#{nested_frames(frame_identifiers)}textarea(identifier).value"
228
+ switch_to_default_content(frame_identifiers)
229
+ value
230
+ end
231
+
232
+ def text_area_for identifier
233
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::TextArea)
234
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}textarea(identifier)"
235
+ switch_to_default_content(frame_identifiers)
236
+ Elements::TextArea.new element
237
+ end
238
+
239
+ def unordered_list_for identifier
240
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::UnOrderedList, 'ul')
241
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}ul(identifier)"
242
+ switch_to_default_content(frame_identifiers)
243
+ Elements::UnOrderedList.new element
244
+ end
245
+
246
+ def h1_text_for identifier
247
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h1')
248
+ text = driver.instance_eval "#{nested_frames(frame_identifiers)}h1(identifier).text"
249
+ switch_to_default_content(frame_identifiers)
250
+ text
251
+ end
252
+
253
+ def h1_for identifier
254
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h1')
255
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}h1(identifier)"
256
+ switch_to_default_content(frame_identifiers)
257
+ Elements::Heading.new element
258
+ end
259
+
260
+ def h2_text_for identifier
261
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h2')
262
+ text = driver.instance_eval "#{nested_frames(frame_identifiers)}h2(identifier).text"
263
+ switch_to_default_content(frame_identifiers)
264
+ text
265
+ end
266
+
267
+ def h2_for identifier
268
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h2')
269
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}h2(identifier)"
270
+ switch_to_default_content(frame_identifiers)
271
+ Elements::Heading.new element
272
+ end
273
+
274
+ def h3_text_for identifier
275
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h3')
276
+ text = driver.instance_eval "#{nested_frames(frame_identifiers)}h3(identifier).text"
277
+ switch_to_default_content(frame_identifiers)
278
+ text
279
+ end
280
+
281
+ def h3_for identifier
282
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h3')
283
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}h3(identifier)"
284
+ switch_to_default_content(frame_identifiers)
285
+ Elements::Heading.new element
286
+ end
287
+
288
+ def h4_text_for identifier
289
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h4')
290
+ text = driver.instance_eval "#{nested_frames(frame_identifiers)}h4(identifier).text"
291
+ switch_to_default_content(frame_identifiers)
292
+ text
293
+ end
294
+
295
+ def h4_for identifier
296
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h4')
297
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}h4(identifier)"
298
+ switch_to_default_content(frame_identifiers)
299
+ Elements::Heading.new element
300
+ end
301
+
302
+ def h5_text_for identifier
303
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h5')
304
+ text = driver.instance_eval "#{nested_frames(frame_identifiers)}h5(identifier).text"
305
+ switch_to_default_content(frame_identifiers)
306
+ text
307
+ end
308
+
309
+ def h5_for identifier
310
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h5')
311
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}h5(identifier)"
312
+ switch_to_default_content(frame_identifiers)
313
+ Elements::Heading.new element
314
+ end
315
+
316
+ def h6_text_for identifier
317
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h6')
318
+ text = driver.instance_eval "#{nested_frames(frame_identifiers)}h6(identifier).text"
319
+ switch_to_default_content(frame_identifiers)
320
+ text
321
+ end
322
+
323
+ def h6_for identifier
324
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Heading, 'h6')
325
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}h6(identifier)"
326
+ switch_to_default_content(frame_identifiers)
327
+ Elements::Heading.new element
328
+ end
329
+
330
+ def paragraph_text_for identifier
331
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Paragraph, 'p')
332
+ text = driver.instance_eval "#{nested_frames(frame_identifiers)}p(identifier).text"
333
+ switch_to_default_content(frame_identifiers)
334
+ text
335
+ end
336
+
337
+ def paragraph_for identifier
338
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::Paragraph, 'p')
339
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}p(identifier)"
340
+ switch_to_default_content(frame_identifiers)
341
+ Elements::Paragraph.new element
342
+ end
343
+
344
+ def file_field_value_set identifier, value
345
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::FileField)
346
+ driver.instance_eval "#{nested_frames(frame_identifiers)}file_field(identifier).set(value)"
347
+ switch_to_default_content(frame_identifiers)
348
+ end
349
+
350
+ def file_field_for identifier
351
+ identifier, frame_identifiers = parse_identifiers(identifier, Elements::FileField)
352
+ element = driver.instance_eval "#{nested_frames(frame_identifiers)}file_field(identifier)"
353
+ switch_to_default_content(frame_identifiers)
354
+ Elements::FileField.new element
355
+ end
356
+ private
357
+
358
+ def add_tagname_if_needed identifier, tag
359
+ return identifier if identifier.length < 2 and not identifier[:name]
360
+ identifier[:tag_name] = tag if identifier[:name]
361
+ identifier
362
+ end
363
+
364
+ def parse_identifiers(identifier, element, tag_name=nil)
365
+ frame_identifiers = identifier.delete(:frame)
366
+ identifier = add_tagname_if_needed identifier, tag_name if tag_name
367
+ identifier = element.identifier_for identifier
368
+ return identifier, frame_identifiers
369
+ end
370
+
371
+ def nested_frames(frame_identifiers)
372
+ return if frame_identifiers.nil?
373
+ frame_str = ''
374
+ frame_identifiers.each do |frame|
375
+ type = frame.keys.first
376
+ identifier = frame.values.first.map do |key, value|
377
+ if value.is_a?(Regexp)
378
+ ":#{key} => #{value.inspect}"
379
+ elsif value.to_s.is_integer
380
+ ":#{key} => #{value}"
381
+ else
382
+ ":#{key} => '#{value}'"
383
+ end
384
+ end.join(', ')
385
+ frame_str +="#{type.to_s}(#{identifier})."
386
+ end
387
+ frame_str
388
+ end
389
+
390
+ def switch_to_default_content(frame_identifiers)
391
+ driver.wd.switch_to.default_content unless frame_identifiers.nil?
392
+ end
393
+ end
394
+ end
@@ -0,0 +1,5 @@
1
+ class String
2
+ def is_integer
3
+ true if Integer(self) rescue false
4
+ end
5
+ end
@@ -0,0 +1,405 @@
1
+ module Druid
2
+ module ElementLocators
3
+
4
+ #
5
+ # Finds a button
6
+ #
7
+ # @param [Hash] identifier how we find a button. You can use a multiple paramaters
8
+ # by combining of any of the following except xpath. The valid keys are:
9
+ # * :class
10
+ # * :id
11
+ # * :index
12
+ # * :name
13
+ # * :text
14
+ # * :value
15
+ # * :xpath
16
+ # * :src
17
+ # * :alt
18
+ #
19
+ def button_element identifier
20
+ button_for identifier
21
+ end
22
+
23
+ #
24
+ # Finds a text field
25
+ #
26
+ # @param [Hash] identifier how we find a text field. You can use a multiple parameters
27
+ # by combining of any of the following except xpath. The valid keys are:
28
+ # * :class
29
+ # * :css
30
+ # * :id
31
+ # * :index
32
+ # * :name
33
+ # * :tag_name
34
+ # * :text
35
+ # * :xpath
36
+ # * :title
37
+ #
38
+ def text_field_element identifier
39
+ text_field_for identifier
40
+ end
41
+
42
+ #
43
+ # Finds a hidden field
44
+ #
45
+ # @param [Hash] identifier how we find a hidden field. You can use a multiple parameters
46
+ # by combining of any of the following except xpath. The valid keys are:
47
+ # * :class
48
+ # * :css
49
+ # * :id
50
+ # * :index
51
+ # * :name
52
+ # * :tag_name
53
+ # * :text
54
+ # * :xpath
55
+ # * :value
56
+ #
57
+ def hidden_field_element identifier
58
+ hidden_field_for identifier
59
+ end
60
+
61
+ #
62
+ # Finds a text area
63
+ #
64
+ # @param [Hash] identifier how we find a text area. You can use a multiple parameters
65
+ # by combining of any of the following except xpath. The valid keys are:
66
+ # * :class
67
+ # * :css
68
+ # * :id
69
+ # * :index
70
+ # * :name
71
+ # * :tag_name
72
+ # * :xpath
73
+ #
74
+ def text_area_element identifier
75
+ text_area_for identifier
76
+ end
77
+
78
+ #
79
+ # Finds a select list
80
+ #
81
+ # @param [Hash] identifier how we find a select list. You can use a multiple parameters
82
+ # by combining of any of the following except xpath. The valid keys are:
83
+ # * :class
84
+ # * :id
85
+ # * :index
86
+ # * :name
87
+ # * :xpath
88
+ # * :value
89
+ # * :text
90
+ #
91
+ def select_list_element identifier
92
+ select_list_for identifier
93
+ end
94
+
95
+ #
96
+ # Finds a link
97
+ #
98
+ # @param [Hash] identifier how we find a link. You can use a multiple parameters
99
+ # by combining of any of the following except xpath. The valid keys are:
100
+ # * :class
101
+ # * :href
102
+ # * :id
103
+ # * :index
104
+ # * :link
105
+ # * :link_text
106
+ # * :name
107
+ # * :xpath
108
+ # * :text
109
+ #
110
+ def link_element identifier
111
+ link_for identifier
112
+ end
113
+
114
+ #
115
+ # Finds a check box
116
+ #
117
+ # @param [Hash] identifier how we find a check box. You can use a multiple parameters
118
+ # by combining of any of the following except xpath. The valid keys are:
119
+ # * :class
120
+ # * :id
121
+ # * :index
122
+ # * :name
123
+ # * :xpath
124
+ # * :value
125
+ #
126
+ def checkbox_element identifier
127
+ checkbox_for identifier
128
+ end
129
+
130
+ #
131
+ # Finds a radio button
132
+ #
133
+ # @param [Hash] identifier how we find a radio button. You can use a multiple parameters
134
+ # by combining of any of the following except xpath. The valid keys are:
135
+ # * :class
136
+ # * :id
137
+ # * :index
138
+ # * :name
139
+ # * :xpath
140
+ #
141
+ def radio_button_element identifier
142
+ radio_button_for identifier
143
+ end
144
+
145
+ #
146
+ # Finds a div
147
+ #
148
+ # @param [Hash] identifier how we find a div. You can use a multiple parameters
149
+ # by combining of any of the following except xpath. The valid keys are:
150
+ # * :class
151
+ # * :id
152
+ # * :index
153
+ # * :name
154
+ # * :xpath
155
+ # * :text
156
+ #
157
+ def div_element identifier
158
+ div_for identifier
159
+ end
160
+
161
+ #
162
+ # Finds a span
163
+ #
164
+ # @param [Hash] identifier how we find a span. You can use a multiple parameters
165
+ # by combining of any of the following except xpath. The valid keys are:
166
+ # * :class
167
+ # * :id
168
+ # * :index
169
+ # * :name
170
+ # * :xpath
171
+ #
172
+ def span_element identifier
173
+ span_for identifier
174
+ end
175
+
176
+ #
177
+ # Finds a table
178
+ #
179
+ # @param [Hash] identifier how we find a table. You can use a multiple parameters
180
+ # by combining of any of the following except xpath. The valid keys are:
181
+ # * :class
182
+ # * :id
183
+ # * :index
184
+ # * :name
185
+ # * :xpath
186
+ #
187
+ def table_element identifier
188
+ table_for identifier
189
+ end
190
+
191
+ #
192
+ # Finds a table cell
193
+ #
194
+ # @param [Hash] identifier how we find a table cell. You can use a multiple parameters
195
+ # by combining of any of the following except xpath. The valid keys are:
196
+ # * :class
197
+ # * :id
198
+ # * :index
199
+ # * :name
200
+ # * :xpath
201
+ # * :text
202
+ #
203
+ def cell_element identifier
204
+ cell_for identifier
205
+ end
206
+
207
+ #
208
+ # Finds an image
209
+ #
210
+ # @param [Hash] identifier how we find an image. You can use a multiple parameters
211
+ # by combining of any of the following except xpath. The valid keys are:
212
+ # * :class
213
+ # * :id
214
+ # * :index
215
+ # * :name
216
+ # * :xpath
217
+ # * :alt
218
+ # * :src
219
+ #
220
+ def image_element identifier
221
+ image_for identifier
222
+ end
223
+
224
+ #
225
+ # Finds a form
226
+ #
227
+ # @param [Hash] identifier how we find a form. You can use a multiple parameters
228
+ # by combining of any of the following except xpath. The valid keys are:
229
+ # * :class
230
+ # * :id
231
+ # * :index
232
+ # * :xpath
233
+ # * :action
234
+ #
235
+ def form_element identifier
236
+ form_for identifier
237
+ end
238
+
239
+ #
240
+ # Finds a list item
241
+ #
242
+ # @param [Hash] identifier how we find a list item. You can use a multiple parameters
243
+ # by combining of any of the following except xpath. The valid keys are:
244
+ # * :class
245
+ # * :id
246
+ # * :index
247
+ # * :xpath
248
+ # * :name
249
+ #
250
+ def list_item_element identifier
251
+ list_item_for identifier
252
+ end
253
+
254
+ #
255
+ # Finds an ordered list
256
+ #
257
+ # @param [Hash] identifier how we find an ordered list. You can use a multiple parameters
258
+ # by combining of any of the following except xpath. The valid keys are:
259
+ # * :class
260
+ # * :id
261
+ # * :index
262
+ # * :xpath
263
+ # * :name
264
+ #
265
+ def ordered_list_element identifier
266
+ ordered_list_for identifier
267
+ end
268
+
269
+ #
270
+ # Finds an unordered list
271
+ #
272
+ # @param [Hash] identifier how we find an unordered list. You can use a multiple parameters
273
+ # by combining of any of the following except xpath. The valid keys are:
274
+ # * :class
275
+ # * :id
276
+ # * :index
277
+ # * :xpath
278
+ # * :name
279
+ #
280
+ def unordered_list_element identifier
281
+ unordered_list_for identifier
282
+ end
283
+
284
+ #
285
+ # Finds a h1
286
+ #
287
+ # @param [Hash] identifier how we find a h1. You can use a multiple parameters
288
+ # by combining of any of the following except xpath. The valid keys are:
289
+ # * :class
290
+ # * :id
291
+ # * :index
292
+ # * :xpath
293
+ # * :name
294
+ #
295
+ def h1_element identifier
296
+ h1_for identifier
297
+ end
298
+
299
+ #
300
+ # Finds a h2
301
+ #
302
+ # @param [Hash] identifier how we find a h2. You can use a multiple parameters
303
+ # by combining of any of the following except xpath. The valid keys are:
304
+ # * :class
305
+ # * :id
306
+ # * :index
307
+ # * :xpath
308
+ # * :name
309
+ #
310
+ def h2_element identifier
311
+ h2_for identifier
312
+ end
313
+
314
+ #
315
+ # Finds a h3
316
+ #
317
+ # @param [Hash] identifier how we find a h3. You can use a multiple parameters
318
+ # by combining of any of the following except xpath. The valid keys are:
319
+ # * :class
320
+ # * :id
321
+ # * :index
322
+ # * :xpath
323
+ # * :name
324
+ #
325
+ def h3_element identifier
326
+ h3_for identifier
327
+ end
328
+
329
+ #
330
+ # Finds a h4
331
+ #
332
+ # @param [Hash] identifier how we find a h4. You can use a multiple parameters
333
+ # by combining of any of the following except xpath. The valid keys are:
334
+ # * :class
335
+ # * :id
336
+ # * :index
337
+ # * :xpath
338
+ # * :name
339
+ #
340
+ def h4_element identifier
341
+ h4_for identifier
342
+ end
343
+
344
+ #
345
+ # Finds a h5
346
+ #
347
+ # @param [Hash] identifier how we find a h5. You can use a multiple parameters
348
+ # by combining of any of the following except xpath. The valid keys are:
349
+ # * :class
350
+ # * :id
351
+ # * :index
352
+ # * :xpath
353
+ # * :name
354
+ #
355
+ def h5_element identifier
356
+ h5_for identifier
357
+ end
358
+
359
+ #
360
+ # Finds a h6
361
+ #
362
+ # @param [Hash] identifier how we find a h6. You can use a multiple parameters
363
+ # by combining of any of the following except xpath. The valid keys are:
364
+ # * :class
365
+ # * :id
366
+ # * :index
367
+ # * :xpath
368
+ # * :name
369
+ #
370
+ def h6_element identifier
371
+ h6_for identifier
372
+ end
373
+
374
+ #
375
+ # Finds a paragraph
376
+ #
377
+ # @param [Hash] identifier how we find a paragraph. You can use a multiple parameters
378
+ # by combining of any of the following except xpath. The valid keys are:
379
+ # * :class
380
+ # * :id
381
+ # * :index
382
+ # * :xpath
383
+ # * :name
384
+ #
385
+ def paragraph_element identifier
386
+ paragraph_for identifier
387
+ end
388
+
389
+ #
390
+ # Finds a file field
391
+ #
392
+ # @param [Hash] identifier how we find a file field. You can use a multiple parameters
393
+ # by combining of any of the following except xpath. The valid keys are:
394
+ # * :class
395
+ # * :id
396
+ # * :index
397
+ # * :xpath
398
+ # * :name
399
+ # * :title
400
+ #
401
+ def file_field_element identifier
402
+ file_field_for identifier
403
+ end
404
+ end
405
+ end