symbiont 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +22 -22
  4. data/.travis.yml +25 -14
  5. data/Gemfile +4 -2
  6. data/{LICENSE → LICENSE.txt} +22 -22
  7. data/README.md +57 -65
  8. data/Rakefile +28 -34
  9. data/lib/symbiont/accessor.rb +7 -0
  10. data/lib/symbiont/assertions.rb +33 -0
  11. data/lib/symbiont/elements.rb +69 -0
  12. data/lib/symbiont/errors.rb +7 -0
  13. data/lib/symbiont/factory.rb +75 -46
  14. data/lib/symbiont/helpers.rb +49 -0
  15. data/lib/symbiont/logging.rb +5 -0
  16. data/lib/symbiont/pages.rb +32 -0
  17. data/lib/symbiont/platform.rb +12 -0
  18. data/lib/symbiont/version.rb +3 -3
  19. data/lib/symbiont.rb +34 -92
  20. data/spec/fixtures/element_definitions.rb +32 -0
  21. data/spec/fixtures/mock_drivers.rb +8 -0
  22. data/spec/fixtures/page_definitions.rb +36 -0
  23. data/spec/spec_helper.rb +31 -80
  24. data/spec/symbiont/assertion_spec.rb +88 -0
  25. data/spec/symbiont/driver_spec.rb +41 -0
  26. data/spec/symbiont/element_spec.rb +8 -0
  27. data/spec/symbiont/factory_spec.rb +70 -130
  28. data/spec/symbiont/page_spec.rb +50 -0
  29. data/symbiont.gemspec +52 -27
  30. data/test/symbiont-script.rb +97 -0
  31. metadata +89 -230
  32. data/Gemfile.lock +0 -44
  33. data/HISTORY.md +0 -99
  34. data/app/app.rb +0 -48
  35. data/app/public/css/cupertino/images/ui-bg_diagonals-thick_90_eeeeee_40x40.png +0 -0
  36. data/app/public/css/cupertino/images/ui-bg_flat_15_cd0a0a_40x100.png +0 -0
  37. data/app/public/css/cupertino/images/ui-bg_glass_100_e4f1fb_1x400.png +0 -0
  38. data/app/public/css/cupertino/images/ui-bg_glass_50_3baae3_1x400.png +0 -0
  39. data/app/public/css/cupertino/images/ui-bg_glass_80_d7ebf9_1x400.png +0 -0
  40. data/app/public/css/cupertino/images/ui-bg_highlight-hard_100_f2f5f7_1x100.png +0 -0
  41. data/app/public/css/cupertino/images/ui-bg_highlight-hard_70_000000_1x100.png +0 -0
  42. data/app/public/css/cupertino/images/ui-bg_highlight-soft_100_deedf7_1x100.png +0 -0
  43. data/app/public/css/cupertino/images/ui-bg_highlight-soft_25_ffef8f_1x100.png +0 -0
  44. data/app/public/css/cupertino/images/ui-icons_2694e8_256x240.png +0 -0
  45. data/app/public/css/cupertino/images/ui-icons_2e83ff_256x240.png +0 -0
  46. data/app/public/css/cupertino/images/ui-icons_3d80b3_256x240.png +0 -0
  47. data/app/public/css/cupertino/images/ui-icons_72a7cf_256x240.png +0 -0
  48. data/app/public/css/cupertino/images/ui-icons_ffffff_256x240.png +0 -0
  49. data/app/public/css/cupertino/jquery-ui-1.8.16.custom.css +0 -290
  50. data/app/public/css/demo_table_jui.css +0 -471
  51. data/app/public/css/font/ColabLig-webfont.eot +0 -0
  52. data/app/public/css/font/ColabLig-webfont.svg +0 -149
  53. data/app/public/css/font/ColabLig-webfont.ttf +0 -0
  54. data/app/public/css/font/ColabLig-webfont.woff +0 -0
  55. data/app/public/css/font/ColabMed-webfont.eot +0 -0
  56. data/app/public/css/font/ColabMed-webfont.svg +0 -149
  57. data/app/public/css/font/ColabMed-webfont.ttf +0 -0
  58. data/app/public/css/font/ColabMed-webfont.woff +0 -0
  59. data/app/public/css/font/ColabReg-webfont.eot +0 -0
  60. data/app/public/css/font/ColabReg-webfont.svg +0 -149
  61. data/app/public/css/font/ColabReg-webfont.ttf +0 -0
  62. data/app/public/css/font/ColabReg-webfont.woff +0 -0
  63. data/app/public/css/font/ColabThi-webfont.eot +0 -0
  64. data/app/public/css/font/ColabThi-webfont.svg +0 -149
  65. data/app/public/css/font/ColabThi-webfont.ttf +0 -0
  66. data/app/public/css/font/ColabThi-webfont.woff +0 -0
  67. data/app/public/css/normalize.css +0 -376
  68. data/app/public/css/site.css +0 -446
  69. data/app/public/fancybox/blank.gif +0 -0
  70. data/app/public/fancybox/fancy_close.png +0 -0
  71. data/app/public/fancybox/fancy_loading.png +0 -0
  72. data/app/public/fancybox/fancy_nav_left.png +0 -0
  73. data/app/public/fancybox/fancy_nav_right.png +0 -0
  74. data/app/public/fancybox/fancy_shadow_e.png +0 -0
  75. data/app/public/fancybox/fancy_shadow_n.png +0 -0
  76. data/app/public/fancybox/fancy_shadow_ne.png +0 -0
  77. data/app/public/fancybox/fancy_shadow_nw.png +0 -0
  78. data/app/public/fancybox/fancy_shadow_s.png +0 -0
  79. data/app/public/fancybox/fancy_shadow_se.png +0 -0
  80. data/app/public/fancybox/fancy_shadow_sw.png +0 -0
  81. data/app/public/fancybox/fancy_shadow_w.png +0 -0
  82. data/app/public/fancybox/fancy_title_left.png +0 -0
  83. data/app/public/fancybox/fancy_title_main.png +0 -0
  84. data/app/public/fancybox/fancy_title_over.png +0 -0
  85. data/app/public/fancybox/fancy_title_right.png +0 -0
  86. data/app/public/fancybox/fancybox-x.png +0 -0
  87. data/app/public/fancybox/fancybox-y.png +0 -0
  88. data/app/public/fancybox/fancybox.png +0 -0
  89. data/app/public/fancybox/jquery.fancybox-1.3.4.css +0 -359
  90. data/app/public/fancybox/jquery.fancybox-1.3.4.js +0 -1156
  91. data/app/public/fancybox/jquery.fancybox-1.3.4.min.js +0 -1
  92. data/app/public/img/Sorting icons.psd +0 -0
  93. data/app/public/img/back_disabled.png +0 -0
  94. data/app/public/img/back_enabled.png +0 -0
  95. data/app/public/img/back_enabled_hover.png +0 -0
  96. data/app/public/img/close.png +0 -0
  97. data/app/public/img/favicon.ico +0 -0
  98. data/app/public/img/forward_disabled.png +0 -0
  99. data/app/public/img/forward_enabled.png +0 -0
  100. data/app/public/img/forward_enabled_hover.png +0 -0
  101. data/app/public/img/lucid-bg.png +0 -0
  102. data/app/public/img/lucid-ft.png +0 -0
  103. data/app/public/img/open.png +0 -0
  104. data/app/public/img/sort_asc.png +0 -0
  105. data/app/public/img/sort_asc_disabled.png +0 -0
  106. data/app/public/img/sort_both.png +0 -0
  107. data/app/public/img/sort_desc.png +0 -0
  108. data/app/public/img/sort_desc_disabled.png +0 -0
  109. data/app/public/js/comics.js +0 -11
  110. data/app/public/js/signup.js +0 -141
  111. data/app/public/js/site.js +0 -42
  112. data/app/public/js/stardate.js +0 -35
  113. data/app/public/js/vendor/html5shiv.js +0 -5
  114. data/app/public/js/vendor/jquery-1.8.3.min.js +0 -2
  115. data/app/public/js/vendor/jquery.dataTables.min.js +0 -151
  116. data/app/public/js/vendor/jquery.validate.min.js +0 -4
  117. data/app/views/comics.erb +0 -344
  118. data/app/views/index.erb +0 -7
  119. data/app/views/layout.erb +0 -72
  120. data/app/views/layout_small.erb +0 -21
  121. data/app/views/stardate.erb +0 -5
  122. data/app/views/stardate_calc.erb +0 -30
  123. data/app/views/webobject.erb +0 -147
  124. data/lib/symbiont/data_setter.rb +0 -53
  125. data/lib/symbiont/enclosers.rb +0 -118
  126. data/lib/symbiont/evaluators.rb +0 -92
  127. data/lib/symbiont/generators.rb +0 -331
  128. data/lib/symbiont/locators.rb +0 -43
  129. data/lib/symbiont/logger.rb +0 -5
  130. data/lib/symbiont/platform_watir/platform_object.rb +0 -466
  131. data/lib/symbiont/platform_watir.rb +0 -9
  132. data/lib/symbiont/platforms.rb +0 -23
  133. data/lib/symbiont/web_objects/_common.rb +0 -174
  134. data/lib/symbiont/web_objects/button.rb +0 -22
  135. data/lib/symbiont/web_objects/checkbox.rb +0 -31
  136. data/lib/symbiont/web_objects/div.rb +0 -15
  137. data/lib/symbiont/web_objects/heading.rb +0 -12
  138. data/lib/symbiont/web_objects/hidden_field.rb +0 -19
  139. data/lib/symbiont/web_objects/label.rb +0 -15
  140. data/lib/symbiont/web_objects/link.rb +0 -23
  141. data/lib/symbiont/web_objects/list_item.rb +0 -13
  142. data/lib/symbiont/web_objects/option.rb +0 -10
  143. data/lib/symbiont/web_objects/ordered_list.rb +0 -49
  144. data/lib/symbiont/web_objects/paragraph.rb +0 -11
  145. data/lib/symbiont/web_objects/radio.rb +0 -31
  146. data/lib/symbiont/web_objects/select_list.rb +0 -82
  147. data/lib/symbiont/web_objects/span.rb +0 -15
  148. data/lib/symbiont/web_objects/table.rb +0 -71
  149. data/lib/symbiont/web_objects/table_cell.rb +0 -24
  150. data/lib/symbiont/web_objects/table_row.rb +0 -59
  151. data/lib/symbiont/web_objects/text_area.rb +0 -26
  152. data/lib/symbiont/web_objects/text_field.rb +0 -31
  153. data/lib/symbiont/web_objects/unordered_list.rb +0 -49
  154. data/lib/symbiont/web_objects.rb +0 -22
  155. data/lucid.yml +0 -6
  156. data/spec/symbiont/data_setter_spec.rb +0 -65
  157. data/spec/symbiont/enclosers_spec.rb +0 -76
  158. data/spec/symbiont/evaluators_spec.rb +0 -95
  159. data/spec/symbiont/generators/button_generators_spec.rb +0 -72
  160. data/spec/symbiont/generators/checkbox_generators_spec.rb +0 -79
  161. data/spec/symbiont/generators/div_generators_spec.rb +0 -56
  162. data/spec/symbiont/generators/hidden_field_generators_spec.rb +0 -65
  163. data/spec/symbiont/generators/link_generators_spec.rb +0 -62
  164. data/spec/symbiont/generators/paragraph_generators_spec.rb +0 -57
  165. data/spec/symbiont/generators/radio_generators_spec.rb +0 -76
  166. data/spec/symbiont/generators/select_list_generators_spec.rb +0 -93
  167. data/spec/symbiont/generators/span_generators_spec.rb +0 -56
  168. data/spec/symbiont/generators/table_cell_generators_spec.rb +0 -56
  169. data/spec/symbiont/generators/table_generators_spec.rb +0 -56
  170. data/spec/symbiont/generators/text_area_generators_spec.rb +0 -72
  171. data/spec/symbiont/generators/text_field_generators_spec.rb +0 -72
  172. data/spec/symbiont/generators_spec.rb +0 -59
  173. data/spec/symbiont/locators_spec.rb +0 -68
  174. data/spec/symbiont/platform_object_spec.rb +0 -18
  175. data/spec/symbiont/symbiont_spec.rb +0 -29
  176. data/spec/symbiont/web_object_spec.rb +0 -194
  177. data/spec/symbiont/web_objects/button_spec.rb +0 -38
  178. data/spec/symbiont/web_objects/checkbox_spec.rb +0 -27
  179. data/spec/symbiont/web_objects/div_spec.rb +0 -18
  180. data/spec/symbiont/web_objects/heading_spec.rb +0 -22
  181. data/spec/symbiont/web_objects/hidden_field_spec.rb +0 -18
  182. data/spec/symbiont/web_objects/label_spec.rb +0 -18
  183. data/spec/symbiont/web_objects/link_spec.rb +0 -33
  184. data/spec/symbiont/web_objects/list_item_spec.rb +0 -18
  185. data/spec/symbiont/web_objects/option_spec.rb +0 -9
  186. data/spec/symbiont/web_objects/ordered_list_spec.rb +0 -53
  187. data/spec/symbiont/web_objects/paragraph_spec.rb +0 -18
  188. data/spec/symbiont/web_objects/radio_spec.rb +0 -27
  189. data/spec/symbiont/web_objects/select_list_spec.rb +0 -69
  190. data/spec/symbiont/web_objects/span_spec.rb +0 -18
  191. data/spec/symbiont/web_objects/table_cell_spec.rb +0 -19
  192. data/spec/symbiont/web_objects/table_row_spec.rb +0 -58
  193. data/spec/symbiont/web_objects/table_spec.rb +0 -61
  194. data/spec/symbiont/web_objects/text_area_spec.rb +0 -18
  195. data/spec/symbiont/web_objects/text_field_spec.rb +0 -39
  196. data/spec/symbiont/web_objects/unordered_list_spec.rb +0 -51
  197. data/specs/common/support/browser.rb +0 -25
  198. data/specs/common/support/env.rb +0 -6
  199. data/specs/common/support/events.rb +0 -15
  200. data/specs/enclosers.feature +0 -9
  201. data/specs/evaluators.feature +0 -26
  202. data/specs/pages/characters.rb +0 -22
  203. data/specs/pages/home.rb +0 -9
  204. data/specs/pages/stardate.rb +0 -23
  205. data/specs/pages/web_objects.rb +0 -77
  206. data/specs/select_list.feature +0 -53
  207. data/specs/steps/enclosers_steps.rb +0 -17
  208. data/specs/steps/evaluators_steps.rb +0 -44
  209. data/specs/steps/navigation_steps.rb +0 -14
  210. data/specs/steps/select_list_steps.rb +0 -94
  211. data/specs/steps/table_cell_steps.rb +0 -31
  212. data/specs/steps/table_steps.rb +0 -87
  213. data/specs/table.feature +0 -49
  214. data/specs/table_cell.feature +0 -27
@@ -1,466 +0,0 @@
1
- module Symbiont
2
- module Platforms
3
- module WatirWebDriver
4
-
5
- class PlatformObject
6
-
7
- def initialize(browser)
8
- @browser = browser
9
- end
10
-
11
- ## Browser-Level Actions ##
12
-
13
- def visit(url)
14
- @browser.goto(url)
15
- end
16
-
17
- def url
18
- @browser.url
19
- end
20
-
21
- def screenshot(file)
22
- @browser.wd.save_screenshot(file)
23
- end
24
-
25
- def run_script(script)
26
- @browser.execute_script(script)
27
- end
28
-
29
- def back
30
- @browser.back
31
- end
32
-
33
- def forward
34
- @browser.forward
35
- end
36
-
37
- def refresh
38
- @browser.refresh
39
- end
40
-
41
- def remove_cookies
42
- @browser.cookies.clear
43
- end
44
-
45
- ## Page-Level Actions ##
46
-
47
- def text
48
- @browser.text
49
- end
50
-
51
- def markup
52
- @browser.html
53
- end
54
-
55
- def title
56
- @browser.title
57
- end
58
-
59
- def focus
60
- web_object = @browser.execute_script("return document.activeElement")
61
- type = web_object.type.to_sym if web_object.tag_name.to_sym == :input
62
- object_class = ::Symbiont::WebObjects.get_class_for(web_object.tag_name, type)
63
- object_class.new(web_object)
64
- end
65
-
66
- ## Encloser Methods ##
67
-
68
- # Platform method to wait for an action to complete in a given time.
69
- # @see Symbiont::Enclosers#wait_for
70
- def wait_for(timeout, message="wait condition not found", &block)
71
- @browser.wait_until(timeout, message, &block)
72
- end
73
-
74
- # Platform method to reference web objects in the context of a
75
- # window.
76
- # @see Symbiont::Enclosers#within_window
77
- def within_window(locator, &block)
78
- identifier = {locator.keys.first => /#{Regexp.escape(locator.values.first)}/}
79
- @browser.window(identifier).use(&block)
80
- end
81
-
82
- def within_frame(locator, encloser=nil, &block)
83
- encloser = [] if encloser.nil?
84
- encloser << locator
85
- block.call(encloser)
86
- end
87
-
88
- # Platform method to handle an alert message box.
89
- # @see Symbiont::Enclosers#will_alert
90
- def will_alert(encloser=nil, &block)
91
- switch_to_frame(encloser)
92
-
93
- yield
94
- value = nil
95
- if @browser.alert.exists?
96
- value = @browser.alert.text
97
- @browser.alert.ok
98
- end
99
-
100
- ###
101
- ##@browser.wd.execute_script("window.alert = function(msg) { window.__lastWatirAlert=msg; }")
102
- ##yield
103
- ##value = @browser.wd.execute_script("return window.__lastWatirAlert")
104
-
105
- switch_to_default_content(encloser)
106
- value
107
- end
108
-
109
- # Platform method to handle a confirmation message box
110
- # @see Symbiont::Enclosers#will_confirm
111
- def will_confirm(response, encloser=nil, &block)
112
- switch_to_frame(encloser)
113
-
114
- yield
115
- value = nil
116
- if @browser.alert.exists?
117
- value = @browser.alert.text
118
- response ? @browser.alert.ok : @browser.alert.close
119
- end
120
-
121
- ##@browser.wd.execute_script("window.confirm = function(msg) { window.__lastWatirConfirm=msg; return #{!!response} }")
122
- ##yield
123
- ##value = @browser.wd.execute_script("return window.__lastWatirConfirm")
124
-
125
- switch_to_default_content(encloser)
126
- value
127
- end
128
-
129
- # Platform method to handle a prompt message box.
130
- # @see Symbiont::Enclosers#will_prompt
131
- def will_prompt(response, encloser=nil, &block)
132
- switch_to_frame(encloser)
133
- @browser.wd.execute_script("window.prompt = function(text, value) { window.__lastWatirPrompt = { message: text, default_value: value }; return #{!!response}; }")
134
- yield
135
- result = @browser.wd.execute_script("return window.__lastWatirPrompt")
136
- switch_to_default_content(encloser)
137
- result && result.dup.each_key { |k| result[k.to_sym] = result.delete(k) }
138
- result
139
- end
140
-
141
- ## Generator Methods ##
142
-
143
- ## Paragraphs ##
144
-
145
- def paragraph_element(locator)
146
- reference_web_object("p(locator)", WebObjects::Paragraph, locator, 'p')
147
- end
148
-
149
- def paragraph_text_for(locator)
150
- access_web_object("p(locator).text", WebObjects::Paragraph, locator, nil, 'p')
151
- end
152
-
153
- ## Labels ##
154
-
155
- def label_element(locator)
156
- reference_web_object("label(locator)", WebObjects::Label, locator, 'label')
157
- end
158
-
159
- def label_text_for(locator)
160
- access_web_object("label(locator).text", WebObjects::Label, locator, nil, 'label')
161
- end
162
-
163
- ## Links ##
164
-
165
- def link_element(locator)
166
- reference_web_object("link(locator)", WebObjects::Link, locator)
167
- end
168
-
169
- def click_link_for(locator)
170
- access_web_object("link(locator).click", WebObjects::Link, locator)
171
- end
172
-
173
- ## Buttons ##
174
-
175
- def button_element(locator)
176
- reference_web_object("button(locator)", WebObjects::Button, locator)
177
- end
178
-
179
- def click_button_for(locator)
180
- access_web_object("button(locator).click", WebObjects::Button, locator)
181
- end
182
-
183
- ## Text Fields ##
184
-
185
- def text_field_element(locator)
186
- reference_web_object("text_field(locator)", WebObjects::TextField, locator)
187
- end
188
-
189
- def get_text_field_value_for(locator)
190
- access_web_object("text_field(locator).value", WebObjects::TextField, locator)
191
- end
192
-
193
- def set_text_field_value_for(locator, value)
194
- access_web_object("text_field(locator).set(value)", WebObjects::TextField, locator, value)
195
- end
196
-
197
- ## Text Areas ##
198
-
199
- def text_area_element(locator)
200
- reference_web_object("text_area(locator)", WebObjects::TextArea, locator)
201
- end
202
-
203
- def get_text_area_value_for(locator)
204
- access_web_object("text_area(locator).value", WebObjects::TextArea, locator)
205
- end
206
-
207
- def set_text_area_value_for(locator, value)
208
- access_web_object("text_area(locator).set(value)", WebObjects::TextArea, locator, value)
209
- end
210
-
211
- ## Hidden Fields ##
212
-
213
- def hidden_field_element(locator)
214
- reference_web_object("hidden(locator)", WebObjects::HiddenField, locator)
215
- end
216
-
217
- def get_hidden_field_value_for(locator)
218
- access_web_object("hidden(locator).value", WebObjects::HiddenField, locator)
219
- end
220
-
221
- ## Checkboxes ##
222
-
223
- def checkbox_element(locator)
224
- reference_web_object("checkbox(locator)", WebObjects::CheckBox, locator)
225
- end
226
-
227
- def check_checkbox_for_checked(locator)
228
- access_web_object("checkbox(locator).set?", WebObjects::CheckBox, locator)
229
- end
230
-
231
- def check_checkbox_for(locator)
232
- access_web_object("checkbox(locator).set", WebObjects::CheckBox, locator)
233
- end
234
-
235
- def uncheck_checkbox_for(locator)
236
- access_web_object("checkbox(locator).clear", WebObjects::CheckBox, locator)
237
- end
238
-
239
- ## Select Lists ##
240
-
241
- def select_list_element(locator)
242
- reference_web_object("select_list(locator)", WebObjects::SelectList, locator)
243
- end
244
-
245
- def get_select_list_item_for(locator)
246
- access_web_object("select_list(locator).selected_options[0].text", WebObjects::SelectList, locator)
247
- # Should I consider: select_list(identifier).options.find {|o| o.selected?}.text
248
- end
249
-
250
- def get_select_list_value_for(locator)
251
- access_web_object("select_list(locator).value", WebObjects::SelectList, locator)
252
- end
253
-
254
- def set_select_list_value_for(locator, value)
255
- access_web_object("select_list(locator).select(value)", WebObjects::SelectList, locator, value)
256
- end
257
-
258
- ## Radios ##
259
-
260
- def radio_element(locator)
261
- reference_web_object("radio(locator)", WebObjects::Radio, locator)
262
- end
263
-
264
- def check_radio_for_selected(locator)
265
- access_web_object("radio(locator).set?", WebObjects::Radio, locator)
266
- end
267
-
268
- def select_radio_for(locator)
269
- access_web_object("radio(locator).set", WebObjects::Radio, locator)
270
- end
271
-
272
- ## Table Elements ##
273
-
274
- def table_element(locator)
275
- reference_web_object("table(locator)", WebObjects::Table, locator, 'table')
276
- end
277
-
278
- def table_text_for(locator)
279
- access_web_object("table(locator).text", WebObjects::Table, locator, nil, 'table')
280
- end
281
-
282
- def cell_element(locator)
283
- reference_web_object("td(locator)", WebObjects::TableCell, locator, 'td')
284
- end
285
-
286
- def get_table_cell_text_for(locator)
287
- access_web_object("td(locator).text", WebObjects::TableCell, locator, nil, 'td')
288
- end
289
-
290
- ## Sectional Elements ##
291
-
292
- def div_element(locator)
293
- reference_web_object("div(locator)", WebObjects::Div, locator, 'div')
294
- end
295
-
296
- def div_text_for(locator)
297
- access_web_object("div(locator).text", WebObjects::Div, locator, nil, 'div')
298
- end
299
-
300
- def span_element(locator)
301
- reference_web_object("span(locator)", WebObjects::Span, locator, 'span')
302
- end
303
-
304
- def span_text_for(locator)
305
- access_web_object("span(locator).text", WebObjects::Span, locator, nil, 'span')
306
- end
307
-
308
- ## Header Elements ##
309
-
310
- def h1_element(locator)
311
- reference_web_object("h1(locator)", WebObjects::Heading, locator, 'h1')
312
- end
313
-
314
- def h1_text_for(locator)
315
- access_web_object("h1(locator).text", WebObjects::Heading, locator, nil, 'h1')
316
- end
317
-
318
- def h2_element(locator)
319
- reference_web_object("h2(locator)", WebObjects::Heading, locator, 'h2')
320
- end
321
-
322
- def h2_text_for(locator)
323
- access_web_object("h2(locator).text", WebObjects::Heading, locator, nil, 'h2')
324
- end
325
-
326
- ## List Elements ##
327
-
328
- def ordered_list_element(locator)
329
- reference_web_object("ol(locator)", WebObjects::OrderedList, locator, 'ol')
330
- end
331
-
332
- def ordered_list_text_for(locator)
333
- access_web_object("ol(locator).text", WebObjects::OrderedList, locator, nil, 'ol')
334
- end
335
-
336
- def ordered_lists_elements(locator)
337
- reference_web_object("ols(locator)", WebObjects::OrderedList, locator, 'ol')
338
- end
339
-
340
- def unordered_list_element(locator)
341
- reference_web_object("ul(locator)", WebObjects::UnorderedList, locator, 'ul')
342
- end
343
-
344
- def unordered_list_text_for(locator)
345
- access_web_object("ul(locator).text", WebObjects::UnorderedList, locator, nil, 'ul')
346
- end
347
-
348
- def unordered_lists_elements(locator)
349
- reference_web_object("uls(locator)", WebObjects::UnorderedList, locator, 'ul')
350
- end
351
-
352
- def list_item_element(locator)
353
- reference_web_object("li(locator)", WebObjects::ListItem, locator, 'li')
354
- end
355
-
356
- def list_item_text_for(locator)
357
- access_web_object("li(locator).text", WebObjects::ListItem, locator, nil, 'li')
358
- end
359
-
360
- def list_items_elements(locator)
361
- reference_web_object("lis(locator)", WebObjects::ListItem, locator, 'li')
362
- end
363
-
364
- private
365
-
366
- # This method is called by any platform methods that require getting
367
- # an object reference.
368
- #
369
- # @param [String] action the driver logic to be sent to the browser
370
- # @param [Object] object_type the type of web object that will receive the action
371
- # @param [Hash] locator the specific web object selector, mainly for parsing
372
- # @return [Object] the web object identified by the action
373
- def reference_web_object(action, object_type, locator, object_tag=nil)
374
- #puts "[ref_obj] Locator (1): #{locator}"
375
- locator, enclosers = qualify_locators(locator, object_type, object_tag)
376
- #puts "[ref_obj] Locator (2): #{locator}"
377
- web_object = @browser.instance_eval "#{enclosed_by(enclosers)}#{action}"
378
- switch_to_default_content(enclosers)
379
- object_type.new(web_object)
380
- end
381
-
382
- # This method is called by any platform methods that require accessing
383
- # a web object with the intent of manipulating it or getting information
384
- # from it.
385
- #
386
- # @param [String] action the driver logic to be sent to the browser
387
- # @param [Hash] locator the specific web object selector, mainly for parsing
388
- # @param [String] value any specific information that must be sent to the web object
389
- # @param [String] object_tag the tag that represents the web object in a browser
390
- #
391
- # @return [Any] the information or object returned by the action
392
- def access_web_object(action, object_type, locator, value=nil, object_tag=nil)
393
- #puts "[acc_obj] Locator (1): #{locator}"
394
- locator, enclosers = qualify_locators(locator, object_type, object_tag)
395
- #puts "[acc_obj] Locator (2): #{locator}"
396
- web_object = @browser.instance_eval "#{enclosed_by(enclosers)}#{action}"
397
- switch_to_default_content(enclosers)
398
- web_object
399
- end
400
-
401
- # This method is used to qualify any locators with necessary information that
402
- # is required to find the web objects during execution.
403
- #
404
- # @param [String] locator the locator being used
405
- # @param [Object] object_type the object type that the locator applies to
406
- # @param [String] object_tag the tag that represents the web object in a browser
407
- def qualify_locators(locator, object_type, object_tag=nil)
408
- enclosers = locator.delete(:frame)
409
-
410
- #puts "[qualify] Locator (1): #{locator}"
411
- locator = use_tagname_for_name(locator, object_tag) if object_tag
412
- #puts "[qualify] Locator (2): #{locator}"
413
- locator = object_type.provide_locator_for(locator)
414
- #puts "[qualify] Locator (3): #{locator}"
415
-
416
- return locator, enclosers
417
- end
418
-
419
- # This method uses an object tag for the locator for a web object
420
- # if the locator being used was :name.
421
- #
422
- # @param [String] locator the locator being used
423
- # @param [String] object_tag the tag that represents the web object in a browser
424
- def use_tagname_for_name(locator, object_tag)
425
- #puts "[use_tagname] Locator (1): #{locator}"
426
- return locator if locator.length < 2 and not locator[:name]
427
- locator[:tag_name] = object_tag if locator[:name]
428
- #puts "[use_tagname] Locator (2): #{locator}"
429
- locator
430
- end
431
-
432
- # This method is used to wrap a web object locator within the locator for an
433
- # enclosing web object. Currently the only enclosing objects this makes sense
434
- # for are iframes and frames.
435
- #
436
- # @param [Hash] enclosers locator information for enclosing web objects
437
- # @return [Hash] driver-specific frame selector
438
- def enclosed_by(enclosers)
439
- return if enclosers.nil?
440
-
441
- key = enclosers[0].keys.first
442
- value = enclosers[0].values.first
443
-
444
- encloser_locator = "frame(:#{key} => '#{value}')."
445
- end
446
-
447
- def switch_to_default_content(locator)
448
- @browser.wd.switch_to.default_content unless locator.nil?
449
- end
450
-
451
- def switch_to_frame(locator)
452
- unless locator.nil?
453
- locator.each do |frame|
454
- value = frame.values.first
455
- @browser.wd.switch_to.frame(value)
456
- end
457
- end
458
- end
459
- end # class: PlatformObject
460
-
461
- end # module: WatirWebDriver
462
- end # module: Platforms
463
- end # module: Symbiont
464
-
465
- require 'symbiont/web_objects'
466
- Dir["#{File.dirname(__FILE__)}/../web_objects/**/*.rb"].sort.each { |file| require file }
@@ -1,9 +0,0 @@
1
- module Symbiont
2
- module Platforms
3
- module WatirWebDriver
4
-
5
- require_relative 'platform_watir/platform_object'
6
-
7
- end
8
- end
9
- end
@@ -1,23 +0,0 @@
1
- module Symbiont
2
- module Platforms
3
-
4
- require 'watir-webdriver'
5
-
6
- # This module determines what execution platform Symbiont will use.
7
- # The decision is based on the browser that has been established for
8
- # the execution profile.
9
- #
10
- # @param [Object] browser the browser to establish the platform for
11
- # @returns [Object] a platform object to execute tests against
12
- def get_platform_for(browser)
13
- if browser.is_a?(Watir::Browser)
14
- return @platform = Symbiont::Platforms::WatirWebDriver::PlatformObject.new(@browser)
15
- else
16
- raise "Unable to create a platform object for #{browser}"
17
- end
18
- end
19
-
20
- end
21
- end
22
-
23
- require_relative 'platform_watir'
@@ -1,174 +0,0 @@
1
- module Symbiont
2
- module WebObjects
3
-
4
- # This class is designed to provide methods for functionality that is
5
- # common to all web objects and that may need to be called directly
6
- # on a web object (as opposed to a web object wrapped up by the
7
- # platform).
8
-
9
- class WebObject
10
- attr_reader :web_object
11
-
12
- def initialize(web_object)
13
- @web_object = web_object
14
- end
15
-
16
- def enabled?
17
- web_object.enabled?
18
- end
19
-
20
- def disabled?
21
- not enabled?
22
- end
23
-
24
- def visible?
25
- web_object.present?
26
- end
27
-
28
- def exists?
29
- web_object.exists?
30
- end
31
-
32
- def id
33
- web_object.id
34
- end
35
-
36
- def value
37
- web_object.value
38
- end
39
-
40
- def flash
41
- web_object.flash
42
- end
43
-
44
- def attribute(name)
45
- web_object.attribute_value(name)
46
- end
47
-
48
- def focus
49
- web_object.focus
50
- end
51
-
52
- def text
53
- web_object.text
54
- end
55
-
56
- def html
57
- web_object.html
58
- end
59
-
60
- def click
61
- web_object.click
62
- end
63
-
64
- def double_click
65
- web_object.double_click
66
- end
67
-
68
- def tag_name
69
- web_object.tag_name
70
- end
71
-
72
- def clear
73
- web_object.clear
74
- end
75
-
76
- def style(property)
77
- web_object.style(property)
78
- end
79
-
80
- def inspect
81
- web_object.inspect
82
- end
83
-
84
- def hover
85
- web_object.hover
86
- end
87
-
88
- def fire_event(event)
89
- web_object.fire_event(event)
90
- end
91
-
92
- def send_keys(*args)
93
- web_object.send_keys(*args)
94
- end
95
-
96
- def ==(other)
97
- web_object == other.web_object
98
- end
99
-
100
- def parent
101
- parent = web_object.parent
102
- type = web_object.type if parent.tag_name.to_sym == :input
103
- object_class = ::Symbiont::WebObjects.get_class_for(parent.tag_name, type)
104
- object_class.new(parent)
105
- end
106
-
107
- def wait_until(timeout=::Symbiont.element_level_wait, message=nil, &block)
108
- Object::Watir::Wait.until(timeout, message, &block)
109
- end
110
-
111
- def when_actionable(timeout=::Symbiont.element_level_wait)
112
- web_object.wait_until_present(timeout)
113
- self
114
- end
115
-
116
- alias_method :when_present, :when_actionable
117
-
118
- def when_not_actionable(timeout=::Symbiont.element_level_wait)
119
- web_object.wait_while_present(timeout)
120
- self
121
- end
122
-
123
- alias_method :when_not_present, :when_not_actionable
124
-
125
- def when_visible(timeout=::Symbiont.element_level_wait)
126
- Object::Watir::Wait.until(timeout, "Object not visible within #{timeout} seconds.") do
127
- visible?
128
- end
129
- self
130
- end
131
-
132
- def when_not_visible(timeout=::Symbiont.element_level_wait)
133
- Object::Watir::Wait.while(timeout, "Object still visible after #{timeout} seconds.") do
134
- visible?
135
- end
136
- self
137
- end
138
-
139
- alias_method :must_be_visible, :when_visible
140
- alias_method :must_not_be_visible, :when_not_visible
141
-
142
- def scroll_into_view(wait=2)
143
- sleep wait
144
- web_object.wd.location_once_scrolled_into_view
145
- end
146
-
147
- def self.usable_selectors
148
- [:id, :name, :xpath, :class, :index]
149
- end
150
-
151
- def self.selector_mapping
152
- {}
153
- end
154
-
155
- #def self.locator_for(locator)
156
- # how, what = locator.keys.first, locator.values.first
157
- # return how => what if usable_selectors.include? how
158
- # return selector_mapping[how] => what if selector_mapping[how]
159
- # return nil => what
160
- #end
161
-
162
- def self.provide_locator_for(locator)
163
- locator.each do |key, value|
164
- how, what = locator.keys.first, locator.values.first
165
- return how => what if usable_selectors.include? how
166
- return selector_mapping[how] => what if selector_mapping[how]
167
- return nil => what
168
- end
169
- end
170
-
171
- end # class: WebObject
172
-
173
- end # module: WebObjects
174
- end # module: Symbiont
@@ -1,22 +0,0 @@
1
- module Symbiont
2
- module WebObjects
3
-
4
- class Button < WebObject
5
-
6
- def initialize(web_object)
7
- @web_object = web_object
8
- end
9
-
10
- def self.usable_selectors
11
- super + [:value, :text, :src, :alt]
12
- end
13
-
14
- end # class: Button
15
-
16
- ::Symbiont::WebObjects.class_for_type[:submit] = ::Symbiont::WebObjects::Button
17
- ::Symbiont::WebObjects.class_for_type[:button] = ::Symbiont::WebObjects::Button
18
- ::Symbiont::WebObjects.class_for_type[:image] = ::Symbiont::WebObjects::Button
19
- ::Symbiont::WebObjects.class_for_type[:reset] = ::Symbiont::WebObjects::Button
20
-
21
- end # module: WebObjects
22
- end # module: Symbiont