symbiont 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. data/Gemfile.lock +1 -1
  2. data/HISTORY.md +6 -0
  3. data/app/app.rb +48 -0
  4. data/app/public/css/cupertino/images/ui-bg_diagonals-thick_90_eeeeee_40x40.png +0 -0
  5. data/app/public/css/cupertino/images/ui-bg_flat_15_cd0a0a_40x100.png +0 -0
  6. data/app/public/css/cupertino/images/ui-bg_glass_100_e4f1fb_1x400.png +0 -0
  7. data/app/public/css/cupertino/images/ui-bg_glass_50_3baae3_1x400.png +0 -0
  8. data/app/public/css/cupertino/images/ui-bg_glass_80_d7ebf9_1x400.png +0 -0
  9. data/app/public/css/cupertino/images/ui-bg_highlight-hard_100_f2f5f7_1x100.png +0 -0
  10. data/app/public/css/cupertino/images/ui-bg_highlight-hard_70_000000_1x100.png +0 -0
  11. data/app/public/css/cupertino/images/ui-bg_highlight-soft_100_deedf7_1x100.png +0 -0
  12. data/app/public/css/cupertino/images/ui-bg_highlight-soft_25_ffef8f_1x100.png +0 -0
  13. data/app/public/css/cupertino/images/ui-icons_2694e8_256x240.png +0 -0
  14. data/app/public/css/cupertino/images/ui-icons_2e83ff_256x240.png +0 -0
  15. data/app/public/css/cupertino/images/ui-icons_3d80b3_256x240.png +0 -0
  16. data/app/public/css/cupertino/images/ui-icons_72a7cf_256x240.png +0 -0
  17. data/app/public/css/cupertino/images/ui-icons_ffffff_256x240.png +0 -0
  18. data/app/public/css/cupertino/jquery-ui-1.8.16.custom.css +290 -0
  19. data/app/public/css/demo_table_jui.css +471 -0
  20. data/app/public/css/font/ColabLig-webfont.eot +0 -0
  21. data/app/public/css/font/ColabLig-webfont.svg +149 -0
  22. data/app/public/css/font/ColabLig-webfont.ttf +0 -0
  23. data/app/public/css/font/ColabLig-webfont.woff +0 -0
  24. data/app/public/css/font/ColabMed-webfont.eot +0 -0
  25. data/app/public/css/font/ColabMed-webfont.svg +149 -0
  26. data/app/public/css/font/ColabMed-webfont.ttf +0 -0
  27. data/app/public/css/font/ColabMed-webfont.woff +0 -0
  28. data/app/public/css/font/ColabReg-webfont.eot +0 -0
  29. data/app/public/css/font/ColabReg-webfont.svg +149 -0
  30. data/app/public/css/font/ColabReg-webfont.ttf +0 -0
  31. data/app/public/css/font/ColabReg-webfont.woff +0 -0
  32. data/app/public/css/font/ColabThi-webfont.eot +0 -0
  33. data/app/public/css/font/ColabThi-webfont.svg +149 -0
  34. data/app/public/css/font/ColabThi-webfont.ttf +0 -0
  35. data/app/public/css/font/ColabThi-webfont.woff +0 -0
  36. data/app/public/css/normalize.css +376 -0
  37. data/app/public/css/site.css +430 -0
  38. data/app/public/fancybox/blank.gif +0 -0
  39. data/app/public/fancybox/fancy_close.png +0 -0
  40. data/app/public/fancybox/fancy_loading.png +0 -0
  41. data/app/public/fancybox/fancy_nav_left.png +0 -0
  42. data/app/public/fancybox/fancy_nav_right.png +0 -0
  43. data/app/public/fancybox/fancy_shadow_e.png +0 -0
  44. data/app/public/fancybox/fancy_shadow_n.png +0 -0
  45. data/app/public/fancybox/fancy_shadow_ne.png +0 -0
  46. data/app/public/fancybox/fancy_shadow_nw.png +0 -0
  47. data/app/public/fancybox/fancy_shadow_s.png +0 -0
  48. data/app/public/fancybox/fancy_shadow_se.png +0 -0
  49. data/app/public/fancybox/fancy_shadow_sw.png +0 -0
  50. data/app/public/fancybox/fancy_shadow_w.png +0 -0
  51. data/app/public/fancybox/fancy_title_left.png +0 -0
  52. data/app/public/fancybox/fancy_title_main.png +0 -0
  53. data/app/public/fancybox/fancy_title_over.png +0 -0
  54. data/app/public/fancybox/fancy_title_right.png +0 -0
  55. data/app/public/fancybox/fancybox-x.png +0 -0
  56. data/app/public/fancybox/fancybox-y.png +0 -0
  57. data/app/public/fancybox/fancybox.png +0 -0
  58. data/app/public/fancybox/jquery.fancybox-1.3.4.css +359 -0
  59. data/app/public/fancybox/jquery.fancybox-1.3.4.js +1156 -0
  60. data/app/public/fancybox/jquery.fancybox-1.3.4.min.js +1 -0
  61. data/app/public/img/Sorting icons.psd +0 -0
  62. data/app/public/img/back_disabled.png +0 -0
  63. data/app/public/img/back_enabled.png +0 -0
  64. data/app/public/img/back_enabled_hover.png +0 -0
  65. data/app/public/img/close.png +0 -0
  66. data/app/public/img/favicon.ico +0 -0
  67. data/app/public/img/forward_disabled.png +0 -0
  68. data/app/public/img/forward_enabled.png +0 -0
  69. data/app/public/img/forward_enabled_hover.png +0 -0
  70. data/app/public/img/lucid-bg.png +0 -0
  71. data/app/public/img/lucid-ft.png +0 -0
  72. data/app/public/img/open.png +0 -0
  73. data/app/public/img/sort_asc.png +0 -0
  74. data/app/public/img/sort_asc_disabled.png +0 -0
  75. data/app/public/img/sort_both.png +0 -0
  76. data/app/public/img/sort_desc.png +0 -0
  77. data/app/public/img/sort_desc_disabled.png +0 -0
  78. data/app/public/js/comics.js +11 -0
  79. data/app/public/js/signup.js +141 -0
  80. data/app/public/js/site.js +40 -0
  81. data/app/public/js/stardate.js +35 -0
  82. data/app/public/js/vendor/html5shiv.js +5 -0
  83. data/app/public/js/vendor/jquery-1.8.3.min.js +2 -0
  84. data/app/public/js/vendor/jquery.dataTables.min.js +151 -0
  85. data/app/public/js/vendor/jquery.validate.min.js +4 -0
  86. data/app/views/comics.erb +322 -0
  87. data/app/views/index.erb +7 -0
  88. data/app/views/layout.erb +72 -0
  89. data/app/views/layout_small.erb +21 -0
  90. data/app/views/stardate.erb +5 -0
  91. data/app/views/stardate_calc.erb +30 -0
  92. data/app/views/webobject.erb +147 -0
  93. data/lib/symbiont/enclosers.rb +18 -2
  94. data/lib/symbiont/evaluators.rb +1 -4
  95. data/lib/symbiont/generators.rb +22 -56
  96. data/lib/symbiont/locators.rb +10 -10
  97. data/lib/symbiont/platform_watir/platform_object.rb +28 -52
  98. data/lib/symbiont/platform_watir.rb +2 -11
  99. data/lib/symbiont/platforms.rb +8 -20
  100. data/lib/symbiont/version.rb +1 -1
  101. data/lib/symbiont/web_objects/_common.rb +110 -32
  102. data/lib/symbiont/web_objects/button.rb +2 -15
  103. data/lib/symbiont/web_objects/checkbox.rb +11 -17
  104. data/lib/symbiont/web_objects/div.rb +1 -5
  105. data/lib/symbiont/web_objects/link.rb +3 -20
  106. data/lib/symbiont/web_objects/radio.rb +10 -16
  107. data/lib/symbiont/web_objects/select_list.rb +60 -15
  108. data/lib/symbiont/web_objects/span.rb +1 -5
  109. data/lib/symbiont/web_objects/table.rb +22 -12
  110. data/lib/symbiont/web_objects/table_cell.rb +2 -6
  111. data/lib/symbiont/web_objects/table_row.rb +24 -13
  112. data/lib/symbiont/web_objects/text_field.rb +10 -19
  113. data/lib/symbiont/web_objects.rb +2 -2
  114. data/lib/symbiont.rb +13 -3
  115. data/spec/spec_helper.rb +1 -0
  116. data/spec/symbiont/enclosers_spec.rb +3 -0
  117. data/spec/symbiont/evaluators_spec.rb +5 -0
  118. data/spec/symbiont/generators/button_generators_spec.rb +1 -1
  119. data/spec/symbiont/generators/cell_generators_spec.rb +1 -1
  120. data/spec/symbiont/generators/checkbox_generators_spec.rb +1 -1
  121. data/spec/symbiont/generators/div_generators_spec.rb +2 -2
  122. data/spec/symbiont/generators/link_generators_spec.rb +1 -1
  123. data/spec/symbiont/generators/paragraph_generators_spec.rb +52 -0
  124. data/spec/symbiont/generators/radio_generators_spec.rb +1 -2
  125. data/spec/symbiont/generators/select_list_generators_spec.rb +3 -3
  126. data/spec/symbiont/generators/span_generators_spec.rb +1 -1
  127. data/spec/symbiont/generators/table_generators_spec.rb +8 -1
  128. data/spec/symbiont/generators/text_field_generators_spec.rb +1 -1
  129. data/spec/symbiont/symbiont_spec.rb +10 -0
  130. data/spec/symbiont/web_object_spec.rb +71 -10
  131. data/spec/symbiont/web_objects/paragraph_spec.rb +11 -0
  132. data/spec/symbiont/web_objects/radio_spec.rb +17 -1
  133. data/spec/symbiont/web_objects/table_cell_spec.rb +6 -0
  134. data/spec/symbiont/web_objects/table_row_spec.rb +20 -10
  135. metadata +94 -20
  136. data/lib/symbiont/platform_selenium/platform_object.rb +0 -236
  137. data/lib/symbiont/platform_selenium/web_objects/button.rb +0 -13
  138. data/lib/symbiont/platform_selenium/web_objects/checkbox.rb +0 -21
  139. data/lib/symbiont/platform_selenium/web_objects/common.rb +0 -104
  140. data/lib/symbiont/platform_selenium/web_objects/link.rb +0 -13
  141. data/lib/symbiont/platform_selenium/web_objects/radio.rb +0 -21
  142. data/lib/symbiont/platform_selenium/web_objects/select_list.rb +0 -79
  143. data/lib/symbiont/platform_selenium/web_objects/table.rb +0 -40
  144. data/lib/symbiont/platform_selenium/web_objects/table_row.rb +0 -36
  145. data/lib/symbiont/platform_selenium/web_objects/text_field.rb +0 -14
  146. data/lib/symbiont/platform_selenium.rb +0 -18
  147. data/lib/symbiont/platform_watir/web_objects/checkbox.rb +0 -21
  148. data/lib/symbiont/platform_watir/web_objects/common.rb +0 -82
  149. data/lib/symbiont/platform_watir/web_objects/radio.rb +0 -21
  150. data/lib/symbiont/platform_watir/web_objects/select_list.rb +0 -67
  151. data/lib/symbiont/platform_watir/web_objects/table.rb +0 -31
  152. data/lib/symbiont/platform_watir/web_objects/table_row.rb +0 -31
  153. data/lib/symbiont/platform_watir/web_objects/text_field.rb +0 -13
@@ -16,9 +16,9 @@ module Symbiont
16
16
  def title_is(title)
17
17
  define_method('has_title?') do
18
18
  sleep 1
19
- valid_title = title =~ browser.title if title.kind_of?(Regexp)
20
- valid_title = title == browser.title if title.kind_of?(String)
21
- raise "\n\nExpected title: '#{title}'; Actual title: '#{browser.title}'" unless valid_title
19
+ valid_title = title =~ @browser.title if title.kind_of?(Regexp)
20
+ valid_title = title == @browser.title if title.kind_of?(String)
21
+ raise "\n\nExpected title: '#{title}'; Actual title: '#{@browser.title}'" unless valid_title
22
22
  valid_title
23
23
  end
24
24
  end
@@ -137,70 +137,35 @@ module Symbiont
137
137
 
138
138
 
139
139
 
140
- # Definition method for tables. Methods for the following actions will be created:
141
- # * reference a table (identifier_object, identifier_table)
142
- # * check for existence (identifier?, identifier_exists?)
143
- # * check for visibility (identifier_?, identifier_visible?)
144
- # @param [Symbol] identifier the friendly name of the web object
145
- # @param [optional, Hash] locator the key/values that identify the object
146
- # @return [Object] instance of Symbiont::WebObjects::Table
147
140
  def table(identifier, locator)
148
- define_method("#{identifier}_object") do
149
- @platform.get_table_for(locator.clone)
150
- end
151
-
152
- alias_method "#{identifier}_table".to_sym, "#{identifier}_object".to_sym
153
-
154
- define_method("#{identifier}_exists?") do
155
- @platform.check_table_for_existence(locator.clone)
156
- end
157
-
158
- alias_method "#{identifier}?".to_sym, "#{identifier}_exists?".to_sym
159
-
160
- define_method("#{identifier}_visible?") do
161
- @platform.check_table_for_visibility(locator.clone)
141
+ define_method(identifier) do
142
+ platform.table_text_for(locator.clone)
162
143
  end
163
-
164
- alias_method "#{identifier}_?".to_sym, "#{identifier}_visible?".to_sym
144
+
145
+ common_definition_methods(identifier, locator, 'table_element')
165
146
  end
166
147
 
167
- # Definition method for table cells. Methods for the following actions will be created:
168
- # * reference a table cell (identifier_object, identifier_cell)
169
- # * check for existence (identifier?, identifier_exists?)
170
- # * check for visibility (identifier_?, identifier_visible?)
171
- # * get text from cell (identifier)
172
- # @param [Symbol] identifier the friendly name of the web object
173
- # @param [optional, Hash] locator the key/values that identify the object
174
- # @return [Object] instance of Symbiont::WebObjects::TableCell
175
148
  def cell(identifier, locator)
176
- define_method("#{identifier}_object") do
177
- @platform.get_table_cell_for(locator.clone)
178
- end
179
-
180
- alias_method "#{identifier}_cell".to_sym, "#{identifier}_object".to_sym
181
-
182
- define_method("#{identifier}_exists?") do
183
- @platform.check_table_cell_for_existence(locator.clone)
184
- end
185
-
186
- alias_method "#{identifier}?".to_sym, "#{identifier}_exists?".to_sym
187
-
188
- define_method("#{identifier}_visible?") do
189
- @platform.check_table_cell_for_visibility(locator.clone)
190
- end
191
-
192
- alias_method "#{identifier}_?".to_sym, "#{identifier}_visible?".to_sym
193
-
194
- define_method("#{identifier}") do
195
- @platform.get_table_cell_text_for(locator.clone)
149
+ define_method(identifier) do
150
+ platform.get_table_cell_text_for(locator.clone)
196
151
  end
152
+
153
+ common_definition_methods(identifier, locator, 'cell_element')
197
154
  end
198
-
155
+
199
156
  def div(identifier, locator)
157
+ define_method(identifier) do
158
+ platform.div_text_for(locator.clone)
159
+ end
160
+
200
161
  common_definition_methods(identifier, locator, 'div_element')
201
162
  end
202
163
 
203
164
  def span(identifier, locator)
165
+ define_method(identifier) do
166
+ platform.span_text_for(locator.clone)
167
+ end
168
+
204
169
  common_definition_methods(identifier, locator, 'span_element')
205
170
  end
206
171
 
@@ -225,7 +190,8 @@ module Symbiont
225
190
  platform.send(method, locator.clone).text
226
191
  end
227
192
 
228
- element = method[0..method.index("_") - 1]
193
+ element = method[0..method.rindex("_") - 1] if method.count("_") == 2
194
+ element = method[0..method.index("_") - 1] if method.count("_") == 1
229
195
 
230
196
  alias_method "#{identifier}_#{element}".to_sym, "#{identifier}_object".to_sym
231
197
  alias_method "#{identifier}?".to_sym, "#{identifier}_exists?".to_sym
@@ -1,43 +1,43 @@
1
1
  module Symbiont
2
2
  module Locators
3
3
  def link_object(locator)
4
- @platform.get_link_for(locator)
4
+ platform.link_element(locator)
5
5
  end
6
6
 
7
7
  def button_object(locator)
8
- @platform.get_button_for(locator)
8
+ platform.button_element(locator)
9
9
  end
10
10
 
11
11
  def text_field_object(locator)
12
- @platform.get_text_field_for(locator)
12
+ platform.text_field_element(locator)
13
13
  end
14
14
 
15
15
  def select_list_object(locator)
16
- @platform.get_select_list_for(locator)
16
+ platform.select_list_element(locator)
17
17
  end
18
18
 
19
19
  def checkbox_object(locator)
20
- @platform.get_checkbox_for(locator)
20
+ platform.checkbox_element(locator)
21
21
  end
22
22
 
23
23
  def radio_object(locator)
24
- @platform.get_radio_for(locator)
24
+ platform.radio_element(locator)
25
25
  end
26
26
 
27
27
  def div_object(locator)
28
- @platform.get_div_for(locator)
28
+ platform.div_element(locator)
29
29
  end
30
30
 
31
31
  def span_object(locator)
32
- @platform.get_span_for(locator)
32
+ platform.span_element(locator)
33
33
  end
34
34
 
35
35
  def table_object(locator)
36
- @platform.get_table_for(locator)
36
+ platform.table_element(locator)
37
37
  end
38
38
 
39
39
  def cell_object(locator)
40
- @platform.get_table_cell_for(locator)
40
+ platform.cell_element(locator)
41
41
  end
42
42
  end # module: Locators
43
43
  end # module: Symbiont
@@ -48,7 +48,7 @@ module Symbiont
48
48
  web_object = @browser.execute_script("return document.activeElement")
49
49
  type = web_object.type.to_sym if web_object.tag_name.to_sym == :input
50
50
  object_class = ::Symbiont::WebObjects.get_class_for(web_object.tag_name, type)
51
- object_class.new(web_object, :platform => :watir_webdriver)
51
+ object_class.new(web_object)
52
52
  end
53
53
 
54
54
  ## Encloser Methods ##
@@ -100,11 +100,11 @@ module Symbiont
100
100
  ## Paragraphs ##
101
101
 
102
102
  def paragraph_element(locator)
103
- reference_web_object("p(locator)", WebObjects::Paragraph, locator)
103
+ reference_web_object("p(locator)", WebObjects::Paragraph, locator, 'p')
104
104
  end
105
105
 
106
106
  def paragraph_text_for(locator)
107
- access_web_object("p(locator).text", WebObjects::Paragraph, locator)
107
+ access_web_object("p(locator).text", WebObjects::Paragraph, locator, nil, 'p')
108
108
  end
109
109
 
110
110
  ## Links ##
@@ -191,61 +191,37 @@ module Symbiont
191
191
  access_web_object("radio(locator).set", WebObjects::Radio, locator)
192
192
  end
193
193
 
194
+ def table_element(locator)
195
+ reference_web_object("table(locator)", WebObjects::Table, locator, 'table')
196
+ end
194
197
 
195
-
196
-
197
- # Platform method to return a table object.
198
- # Table objects are of type: Symbiont::WebObjects::Table
199
- # @see Symbiont::Generators#table
200
- def get_table_for(locator)
201
- reference_web_object("table(locator)", WebObjects::Table, locator)
198
+ def table_text_for(locator)
199
+ access_web_object("table(locator).text", WebObjects::Table, locator, nil, 'table')
202
200
  end
203
-
204
- # Platform method to check if table object exists.
205
- # @see Symbiont::Generators#table
206
- #def check_table_for_existence(locator)
207
- # access_web_object("table(locator).exists?", WebObjects::Table, locator)
208
- #end
209
-
210
- # Platform method to check if table object is visible.
211
- # @see Symbiont::Generators#table
212
- #def check_table_for_visibility(locator)
213
- # access_web_object("table(locator).visible?", WebObjects::Table, locator)
214
- #end
215
-
216
- # Platform method to return a table cell object.
217
- # Table cell objects are of type: Symbiont::WebObjects::TableCell
218
- # @see Symbiont::Generators#cell
219
- def get_table_cell_for(locator)
220
- reference_web_object("td(locator)", WebObjects::TableCell, locator)
201
+
202
+
203
+ def cell_element(locator)
204
+ reference_web_object("td(locator)", WebObjects::TableCell, locator, 'td')
221
205
  end
222
206
 
223
- # Platform method to check if table cell object exists.
224
- # @see Symbiont::Generators#cell
225
- #def check_table_cell_for_existence(locator)
226
- # access_web_object("td(locator).exists?", WebObjects::TableCell, locator)
227
- #end
228
-
229
- # Platform method to check if table cell object is visible.
230
- # @see Symbiont::Generators#cell
231
- #def check_table_cell_for_visibility(locator)
232
- # access_web_object("td(locator).visible?", WebObjects::TableCell, locator)
233
- #end
234
-
235
- # Platform method to get text of table cell object.
236
- # @see Symbiont::Generators#cell
237
207
  def get_table_cell_text_for(locator)
238
- access_web_object("td(locator).text", WebObjects::TableCell, locator)
208
+ access_web_object("td(locator).text", WebObjects::TableCell, locator, nil, 'td')
239
209
  end
240
-
241
-
242
210
 
243
211
  def div_element(locator)
244
- reference_web_object("div(locator)", WebObjects::Div, locator)
212
+ reference_web_object("div(locator)", WebObjects::Div, locator, 'div')
213
+ end
214
+
215
+ def div_text_for(locator)
216
+ access_web_object("div(locator).text", WebObjects::Div, locator, nil, 'div')
245
217
  end
246
218
 
247
219
  def span_element(locator)
248
- reference_web_object("span(locator)", WebObjects::Span, locator)
220
+ reference_web_object("span(locator)", WebObjects::Span, locator, 'span')
221
+ end
222
+
223
+ def span_text_for(locator)
224
+ access_web_object("span(locator).text", WebObjects::Span, locator, nil, 'span')
249
225
  end
250
226
 
251
227
  private
@@ -257,12 +233,12 @@ module Symbiont
257
233
  # @param [Object] object_type the type of web object that will receive the action
258
234
  # @param [Hash] locator the specific web object selector, mainly for parsing
259
235
  # @return [Object] the web object identified by the action
260
- def reference_web_object(action, object_type, locator)
236
+ def reference_web_object(action, object_type, locator, object_tag=nil)
261
237
  enclosers = locator.delete(:frame)
262
- locator = object_type.provide_watir_locator_for(locator)
238
+ locator = object_type.provide_locator_for(locator)
263
239
  web_object = @browser.instance_eval "#{enclosed_by(enclosers)}#{action}"
264
240
  @browser.wd.switch_to.default_content unless enclosers.nil?
265
- object_type.new(web_object, :platform => :watir_webdriver)
241
+ object_type.new(web_object)
266
242
  end
267
243
 
268
244
  # This method is called by any platform methods that require accessing
@@ -274,9 +250,9 @@ module Symbiont
274
250
  # @param [String] value any specific information that must be sent to the
275
251
  # web object
276
252
  # @return [Any] the information or object returned by the action
277
- def access_web_object(action, object_type, locator, value=nil)
253
+ def access_web_object(action, object_type, locator, value=nil, object_tag=nil)
278
254
  enclosers = locator.delete(:frame)
279
- locator = object_type.provide_watir_locator_for(locator)
255
+ locator = object_type.provide_locator_for(locator)
280
256
  object = @browser.instance_eval "#{enclosed_by(enclosers)}#{action}"
281
257
  @browser.wd.switch_to.default_content unless enclosers.nil?
282
258
  object
@@ -2,17 +2,8 @@ module Symbiont
2
2
  module Platforms
3
3
  module WatirWebDriver
4
4
 
5
- def self.create_platform_object_for(browser)
6
- require_relative 'platform_watir/platform_object'
7
- return WatirWebDriver::PlatformObject.new(browser)
8
- end
9
-
10
- def self.works_with(browser)
11
- browser.is_a?(::Watir::Browser)
12
- end
5
+ require_relative 'platform_watir/platform_object'
13
6
 
14
7
  end
15
8
  end
16
- end
17
-
18
- Symbiont::Platforms.register(:watir_webdriver, Symbiont::Platforms::WatirWebDriver)
9
+ end
@@ -2,34 +2,22 @@ module Symbiont
2
2
  module Platforms
3
3
 
4
4
  require 'watir-webdriver'
5
- require 'selenium-webdriver'
6
-
7
- @@drivers = {}
8
-
9
- def self.list
10
- @@drivers
11
- end
12
-
13
- def self.register(driver, platform_object)
14
- @@drivers[driver] = platform_object
15
- end
16
5
 
17
6
  # This module determines what execution platform Symbiont will use.
18
7
  # The decision is based on the browser that has been established for
19
8
  # the execution profile.
20
9
  #
21
10
  # @param [Object] browser the browser to establish the platform for
22
- # @param [Hash] drivers the list of registered browser drivers
23
11
  # @returns [Object] a platform object to execute tests against
24
- def get_platform_for(browser, drivers)
25
- drivers.each_value { |driver|
26
- return driver.create_platform_object_for(browser) if driver.works_with(browser)
27
- }
28
- raise "Unable to create a platform object for #{browser}"
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
29
18
  end
30
19
 
31
- end # module: Platforms
32
- end # module: Symbiont
20
+ end
21
+ end
33
22
 
34
23
  require_relative 'platform_watir'
35
- require_relative 'platform_selenium'
@@ -1,3 +1,3 @@
1
1
  module Symbiont
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -9,9 +9,8 @@ module Symbiont
9
9
  class WebObject
10
10
  attr_reader :web_object
11
11
 
12
- def initialize(web_object, platform)
12
+ def initialize(web_object)
13
13
  @web_object = web_object
14
- include_platform_specifics_for(platform)
15
14
  end
16
15
 
17
16
  def enabled?
@@ -22,15 +21,51 @@ module Symbiont
22
21
  not enabled?
23
22
  end
24
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
+
25
52
  def text
26
53
  web_object.text
27
54
  end
55
+
56
+ def html
57
+ web_object.html
58
+ end
28
59
 
29
60
  def click
30
61
  web_object.click
31
62
  end
32
63
 
33
- def tag
64
+ def double_click
65
+ web_object.double_click
66
+ end
67
+
68
+ def tag_name
34
69
  web_object.tag_name
35
70
  end
36
71
 
@@ -46,50 +81,93 @@ module Symbiont
46
81
  web_object.inspect
47
82
  end
48
83
 
49
- def self.usable_selectors_for_watir
50
- [:id, :name, :xpath, :class, :index]
84
+ def hover
85
+ web_object.hover
51
86
  end
52
87
 
53
- def self.usable_selectors_for_selenium
54
- [:id, :name, :xpath, :class, :index, :css]
88
+ def fire_event(event)
89
+ web_object.fire_event(event)
55
90
  end
56
91
 
57
- def self.selector_mapping_for_watir
58
- {}
92
+ def send_keys(*args)
93
+ web_object.send_keys(*args)
59
94
  end
60
95
 
61
- def self.selector_mapping_for_selenium
62
- {}
96
+ def ==(other)
97
+ web_object == other.web_object
63
98
  end
64
-
65
- def self.provide_watir_locator_for(locator)
66
- locator = locator_for(locator, usable_selectors_for_watir, selector_mapping_for_watir)
67
- return {locator.keys.first => locator.values.first}
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
68
137
  end
69
138
 
70
- def self.provide_selenium_locator_for(locator)
71
- locator = locator_for(locator, usable_selectors_for_selenium, selector_mapping_for_selenium)
72
- return locator.keys.first, locator.values.first
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
73
145
  end
74
146
 
75
- def self.locator_for(locator, selectors, mappings)
76
- how, what = locator.keys.first, locator.values.first
77
- return how => what if selectors.include? how
78
- return mappings[how] => what if mappings[how]
79
- return nil => what
147
+ def self.usable_selectors
148
+ [:id, :name, :xpath, :class, :index]
80
149
  end
81
150
 
82
- def include_platform_specifics_for(platform)
83
- if platform[:platform] == :watir_webdriver
84
- require 'symbiont/platform_watir/web_objects/common'
85
- self.class.send :include, ::Symbiont::Platforms::WatirWebDriver::WebObject
86
- elsif platform[:platform] == :selenium_webdriver
87
- require 'symbiont/platform_selenium/web_objects/common'
88
- self.class.send :include, ::Symbiont::Platforms::SeleniumWebDriver::WebObject
89
- else
90
- raise ArgumentError, "The platform #{platform[:platform]} appears to be unsupported."
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
91
168
  end
92
169
  end
170
+
93
171
  end # class: WebObject
94
172
 
95
173
  end # module: WebObjects
@@ -3,27 +3,14 @@ module Symbiont
3
3
 
4
4
  class Button < WebObject
5
5
 
6
- def initialize(web_object, platform)
6
+ def initialize(web_object)
7
7
  @web_object = web_object
8
- include_platform_specifics_for(platform)
9
8
  end
10
9
 
11
- def self.usable_selectors_for_watir
10
+ def self.usable_selectors
12
11
  super + [:value, :text, :src, :alt, :css]
13
12
  end
14
13
 
15
- def self.usable_selectors_for_selenium
16
- super + [:value, :src, :alt]
17
- end
18
-
19
- def include_platform_specifics_for(platform)
20
- super
21
- if platform[:platform] == :selenium_webdriver
22
- require 'symbiont/platform_selenium/web_objects/button'
23
- self.class.send :include, Symbiont::Platforms::SeleniumWebDriver::Button
24
- end
25
- end
26
-
27
14
  end # class: Button
28
15
 
29
16
  ::Symbiont::WebObjects.class_for_type[:submit] = ::Symbiont::WebObjects::Button
@@ -3,30 +3,24 @@ module Symbiont
3
3
 
4
4
  class CheckBox < WebObject
5
5
 
6
- def initialize(web_object, platform)
6
+ def initialize(web_object)
7
7
  @web_object = web_object
8
- include_platform_specifics_for(platform)
9
8
  end
10
9
 
11
- def self.usable_selectors_for_watir
12
- super + [:value]
10
+ def check
11
+ web_object.set
13
12
  end
14
13
 
15
- def self.usable_selectors_for_selenium
16
- super + [:value]
14
+ def uncheck
15
+ web_object.clear
17
16
  end
18
17
 
19
- def include_platform_specifics_for(platform)
20
- super
21
- if platform[:platform] == :watir_webdriver
22
- require 'symbiont/platform_watir/web_objects/checkbox'
23
- self.class.send :include, Symbiont::Platforms::WatirWebDriver::CheckBox
24
- elsif platform[:platform] == :selenium_webdriver
25
- require 'symbiont/platform_selenium/web_objects/checkbox'
26
- self.class.send :include, Symbiont::Platforms::SeleniumWebDriver::CheckBox
27
- else
28
- raise ArgumentError, "The platform #{platform[:platform]} appears to be unsupported."
29
- end
18
+ def checked?
19
+ web_object.set?
20
+ end
21
+
22
+ def self.usable_selectors
23
+ super + [:value]
30
24
  end
31
25
 
32
26
  end # class: CheckBox
@@ -3,11 +3,7 @@ module Symbiont
3
3
 
4
4
  class Div < WebObject
5
5
 
6
- def self.usable_selectors_for_watir
7
- super + [:text, :title]
8
- end
9
-
10
- def self.usable_selectors_for_selenium
6
+ def self.usable_selectors
11
7
  super + [:text, :title]
12
8
  end
13
9
 
@@ -3,35 +3,18 @@ module Symbiont
3
3
 
4
4
  class Link < WebObject
5
5
 
6
- def initialize(web_object, platform)
6
+ def initialize(web_object)
7
7
  @web_object = web_object
8
- include_platform_specifics_for(platform)
9
8
  end
10
9
 
11
- def self.usable_selectors_for_watir
10
+ def self.usable_selectors
12
11
  super + [:href, :text, :title, :css]
13
12
  end
14
13
 
15
- def self.selector_mapping_for_watir
14
+ def self.selector_mapping
16
15
  super.merge({:link => :text, :link_text => :text})
17
16
  end
18
17
 
19
- def self.usable_selectors_for_selenium
20
- super + [:link, :link_text, :title]
21
- end
22
-
23
- def self.selector_mapping_for_selenium
24
- super.merge(:text => :link_text)
25
- end
26
-
27
- def include_platform_specifics_for(platform)
28
- super
29
- if platform[:platform] == :selenium_webdriver
30
- require 'symbiont/platform_selenium/web_objects/link'
31
- self.class.send :include, Symbiont::Platforms::SeleniumWebDriver::Link
32
- end
33
- end
34
-
35
18
  end # class: Link
36
19
 
37
20
  ::Symbiont::WebObjects.class_for_tag[:a] = ::Symbiont::WebObjects::Link