symbiont 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/HISTORY.md +6 -0
- data/app/app.rb +48 -0
- data/app/public/css/cupertino/images/ui-bg_diagonals-thick_90_eeeeee_40x40.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_flat_15_cd0a0a_40x100.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_glass_100_e4f1fb_1x400.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_glass_50_3baae3_1x400.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_glass_80_d7ebf9_1x400.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_highlight-hard_100_f2f5f7_1x100.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_highlight-hard_70_000000_1x100.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_highlight-soft_100_deedf7_1x100.png +0 -0
- data/app/public/css/cupertino/images/ui-bg_highlight-soft_25_ffef8f_1x100.png +0 -0
- data/app/public/css/cupertino/images/ui-icons_2694e8_256x240.png +0 -0
- data/app/public/css/cupertino/images/ui-icons_2e83ff_256x240.png +0 -0
- data/app/public/css/cupertino/images/ui-icons_3d80b3_256x240.png +0 -0
- data/app/public/css/cupertino/images/ui-icons_72a7cf_256x240.png +0 -0
- data/app/public/css/cupertino/images/ui-icons_ffffff_256x240.png +0 -0
- data/app/public/css/cupertino/jquery-ui-1.8.16.custom.css +290 -0
- data/app/public/css/demo_table_jui.css +471 -0
- data/app/public/css/font/ColabLig-webfont.eot +0 -0
- data/app/public/css/font/ColabLig-webfont.svg +149 -0
- data/app/public/css/font/ColabLig-webfont.ttf +0 -0
- data/app/public/css/font/ColabLig-webfont.woff +0 -0
- data/app/public/css/font/ColabMed-webfont.eot +0 -0
- data/app/public/css/font/ColabMed-webfont.svg +149 -0
- data/app/public/css/font/ColabMed-webfont.ttf +0 -0
- data/app/public/css/font/ColabMed-webfont.woff +0 -0
- data/app/public/css/font/ColabReg-webfont.eot +0 -0
- data/app/public/css/font/ColabReg-webfont.svg +149 -0
- data/app/public/css/font/ColabReg-webfont.ttf +0 -0
- data/app/public/css/font/ColabReg-webfont.woff +0 -0
- data/app/public/css/font/ColabThi-webfont.eot +0 -0
- data/app/public/css/font/ColabThi-webfont.svg +149 -0
- data/app/public/css/font/ColabThi-webfont.ttf +0 -0
- data/app/public/css/font/ColabThi-webfont.woff +0 -0
- data/app/public/css/normalize.css +376 -0
- data/app/public/css/site.css +430 -0
- data/app/public/fancybox/blank.gif +0 -0
- data/app/public/fancybox/fancy_close.png +0 -0
- data/app/public/fancybox/fancy_loading.png +0 -0
- data/app/public/fancybox/fancy_nav_left.png +0 -0
- data/app/public/fancybox/fancy_nav_right.png +0 -0
- data/app/public/fancybox/fancy_shadow_e.png +0 -0
- data/app/public/fancybox/fancy_shadow_n.png +0 -0
- data/app/public/fancybox/fancy_shadow_ne.png +0 -0
- data/app/public/fancybox/fancy_shadow_nw.png +0 -0
- data/app/public/fancybox/fancy_shadow_s.png +0 -0
- data/app/public/fancybox/fancy_shadow_se.png +0 -0
- data/app/public/fancybox/fancy_shadow_sw.png +0 -0
- data/app/public/fancybox/fancy_shadow_w.png +0 -0
- data/app/public/fancybox/fancy_title_left.png +0 -0
- data/app/public/fancybox/fancy_title_main.png +0 -0
- data/app/public/fancybox/fancy_title_over.png +0 -0
- data/app/public/fancybox/fancy_title_right.png +0 -0
- data/app/public/fancybox/fancybox-x.png +0 -0
- data/app/public/fancybox/fancybox-y.png +0 -0
- data/app/public/fancybox/fancybox.png +0 -0
- data/app/public/fancybox/jquery.fancybox-1.3.4.css +359 -0
- data/app/public/fancybox/jquery.fancybox-1.3.4.js +1156 -0
- data/app/public/fancybox/jquery.fancybox-1.3.4.min.js +1 -0
- data/app/public/img/Sorting icons.psd +0 -0
- data/app/public/img/back_disabled.png +0 -0
- data/app/public/img/back_enabled.png +0 -0
- data/app/public/img/back_enabled_hover.png +0 -0
- data/app/public/img/close.png +0 -0
- data/app/public/img/favicon.ico +0 -0
- data/app/public/img/forward_disabled.png +0 -0
- data/app/public/img/forward_enabled.png +0 -0
- data/app/public/img/forward_enabled_hover.png +0 -0
- data/app/public/img/lucid-bg.png +0 -0
- data/app/public/img/lucid-ft.png +0 -0
- data/app/public/img/open.png +0 -0
- data/app/public/img/sort_asc.png +0 -0
- data/app/public/img/sort_asc_disabled.png +0 -0
- data/app/public/img/sort_both.png +0 -0
- data/app/public/img/sort_desc.png +0 -0
- data/app/public/img/sort_desc_disabled.png +0 -0
- data/app/public/js/comics.js +11 -0
- data/app/public/js/signup.js +141 -0
- data/app/public/js/site.js +40 -0
- data/app/public/js/stardate.js +35 -0
- data/app/public/js/vendor/html5shiv.js +5 -0
- data/app/public/js/vendor/jquery-1.8.3.min.js +2 -0
- data/app/public/js/vendor/jquery.dataTables.min.js +151 -0
- data/app/public/js/vendor/jquery.validate.min.js +4 -0
- data/app/views/comics.erb +322 -0
- data/app/views/index.erb +7 -0
- data/app/views/layout.erb +72 -0
- data/app/views/layout_small.erb +21 -0
- data/app/views/stardate.erb +5 -0
- data/app/views/stardate_calc.erb +30 -0
- data/app/views/webobject.erb +147 -0
- data/lib/symbiont/enclosers.rb +18 -2
- data/lib/symbiont/evaluators.rb +1 -4
- data/lib/symbiont/generators.rb +22 -56
- data/lib/symbiont/locators.rb +10 -10
- data/lib/symbiont/platform_watir/platform_object.rb +28 -52
- data/lib/symbiont/platform_watir.rb +2 -11
- data/lib/symbiont/platforms.rb +8 -20
- data/lib/symbiont/version.rb +1 -1
- data/lib/symbiont/web_objects/_common.rb +110 -32
- data/lib/symbiont/web_objects/button.rb +2 -15
- data/lib/symbiont/web_objects/checkbox.rb +11 -17
- data/lib/symbiont/web_objects/div.rb +1 -5
- data/lib/symbiont/web_objects/link.rb +3 -20
- data/lib/symbiont/web_objects/radio.rb +10 -16
- data/lib/symbiont/web_objects/select_list.rb +60 -15
- data/lib/symbiont/web_objects/span.rb +1 -5
- data/lib/symbiont/web_objects/table.rb +22 -12
- data/lib/symbiont/web_objects/table_cell.rb +2 -6
- data/lib/symbiont/web_objects/table_row.rb +24 -13
- data/lib/symbiont/web_objects/text_field.rb +10 -19
- data/lib/symbiont/web_objects.rb +2 -2
- data/lib/symbiont.rb +13 -3
- data/spec/spec_helper.rb +1 -0
- data/spec/symbiont/enclosers_spec.rb +3 -0
- data/spec/symbiont/evaluators_spec.rb +5 -0
- data/spec/symbiont/generators/button_generators_spec.rb +1 -1
- data/spec/symbiont/generators/cell_generators_spec.rb +1 -1
- data/spec/symbiont/generators/checkbox_generators_spec.rb +1 -1
- data/spec/symbiont/generators/div_generators_spec.rb +2 -2
- data/spec/symbiont/generators/link_generators_spec.rb +1 -1
- data/spec/symbiont/generators/paragraph_generators_spec.rb +52 -0
- data/spec/symbiont/generators/radio_generators_spec.rb +1 -2
- data/spec/symbiont/generators/select_list_generators_spec.rb +3 -3
- data/spec/symbiont/generators/span_generators_spec.rb +1 -1
- data/spec/symbiont/generators/table_generators_spec.rb +8 -1
- data/spec/symbiont/generators/text_field_generators_spec.rb +1 -1
- data/spec/symbiont/symbiont_spec.rb +10 -0
- data/spec/symbiont/web_object_spec.rb +71 -10
- data/spec/symbiont/web_objects/paragraph_spec.rb +11 -0
- data/spec/symbiont/web_objects/radio_spec.rb +17 -1
- data/spec/symbiont/web_objects/table_cell_spec.rb +6 -0
- data/spec/symbiont/web_objects/table_row_spec.rb +20 -10
- metadata +94 -20
- data/lib/symbiont/platform_selenium/platform_object.rb +0 -236
- data/lib/symbiont/platform_selenium/web_objects/button.rb +0 -13
- data/lib/symbiont/platform_selenium/web_objects/checkbox.rb +0 -21
- data/lib/symbiont/platform_selenium/web_objects/common.rb +0 -104
- data/lib/symbiont/platform_selenium/web_objects/link.rb +0 -13
- data/lib/symbiont/platform_selenium/web_objects/radio.rb +0 -21
- data/lib/symbiont/platform_selenium/web_objects/select_list.rb +0 -79
- data/lib/symbiont/platform_selenium/web_objects/table.rb +0 -40
- data/lib/symbiont/platform_selenium/web_objects/table_row.rb +0 -36
- data/lib/symbiont/platform_selenium/web_objects/text_field.rb +0 -14
- data/lib/symbiont/platform_selenium.rb +0 -18
- data/lib/symbiont/platform_watir/web_objects/checkbox.rb +0 -21
- data/lib/symbiont/platform_watir/web_objects/common.rb +0 -82
- data/lib/symbiont/platform_watir/web_objects/radio.rb +0 -21
- data/lib/symbiont/platform_watir/web_objects/select_list.rb +0 -67
- data/lib/symbiont/platform_watir/web_objects/table.rb +0 -31
- data/lib/symbiont/platform_watir/web_objects/table_row.rb +0 -31
- data/lib/symbiont/platform_watir/web_objects/text_field.rb +0 -13
data/lib/symbiont/generators.rb
CHANGED
@@ -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(
|
149
|
-
|
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
|
-
|
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(
|
177
|
-
|
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.
|
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
|
data/lib/symbiont/locators.rb
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
module Symbiont
|
2
2
|
module Locators
|
3
3
|
def link_object(locator)
|
4
|
-
|
4
|
+
platform.link_element(locator)
|
5
5
|
end
|
6
6
|
|
7
7
|
def button_object(locator)
|
8
|
-
|
8
|
+
platform.button_element(locator)
|
9
9
|
end
|
10
10
|
|
11
11
|
def text_field_object(locator)
|
12
|
-
|
12
|
+
platform.text_field_element(locator)
|
13
13
|
end
|
14
14
|
|
15
15
|
def select_list_object(locator)
|
16
|
-
|
16
|
+
platform.select_list_element(locator)
|
17
17
|
end
|
18
18
|
|
19
19
|
def checkbox_object(locator)
|
20
|
-
|
20
|
+
platform.checkbox_element(locator)
|
21
21
|
end
|
22
22
|
|
23
23
|
def radio_object(locator)
|
24
|
-
|
24
|
+
platform.radio_element(locator)
|
25
25
|
end
|
26
26
|
|
27
27
|
def div_object(locator)
|
28
|
-
|
28
|
+
platform.div_element(locator)
|
29
29
|
end
|
30
30
|
|
31
31
|
def span_object(locator)
|
32
|
-
|
32
|
+
platform.span_element(locator)
|
33
33
|
end
|
34
34
|
|
35
35
|
def table_object(locator)
|
36
|
-
|
36
|
+
platform.table_element(locator)
|
37
37
|
end
|
38
38
|
|
39
39
|
def cell_object(locator)
|
40
|
-
|
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
|
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
|
-
|
205
|
-
|
206
|
-
|
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.
|
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
|
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.
|
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
|
-
|
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
|
data/lib/symbiont/platforms.rb
CHANGED
@@ -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
|
25
|
-
|
26
|
-
return
|
27
|
-
|
28
|
-
|
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
|
32
|
-
end
|
20
|
+
end
|
21
|
+
end
|
33
22
|
|
34
23
|
require_relative 'platform_watir'
|
35
|
-
require_relative 'platform_selenium'
|
data/lib/symbiont/version.rb
CHANGED
@@ -9,9 +9,8 @@ module Symbiont
|
|
9
9
|
class WebObject
|
10
10
|
attr_reader :web_object
|
11
11
|
|
12
|
-
def initialize(web_object
|
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
|
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
|
50
|
-
|
84
|
+
def hover
|
85
|
+
web_object.hover
|
51
86
|
end
|
52
87
|
|
53
|
-
def
|
54
|
-
|
88
|
+
def fire_event(event)
|
89
|
+
web_object.fire_event(event)
|
55
90
|
end
|
56
91
|
|
57
|
-
def
|
58
|
-
|
92
|
+
def send_keys(*args)
|
93
|
+
web_object.send_keys(*args)
|
59
94
|
end
|
60
95
|
|
61
|
-
def
|
62
|
-
|
96
|
+
def ==(other)
|
97
|
+
web_object == other.web_object
|
63
98
|
end
|
64
|
-
|
65
|
-
def
|
66
|
-
|
67
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
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.
|
76
|
-
|
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
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
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.
|
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
|
6
|
+
def initialize(web_object)
|
7
7
|
@web_object = web_object
|
8
|
-
include_platform_specifics_for(platform)
|
9
8
|
end
|
10
9
|
|
11
|
-
def
|
12
|
-
|
10
|
+
def check
|
11
|
+
web_object.set
|
13
12
|
end
|
14
13
|
|
15
|
-
def
|
16
|
-
|
14
|
+
def uncheck
|
15
|
+
web_object.clear
|
17
16
|
end
|
18
17
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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,35 +3,18 @@ module Symbiont
|
|
3
3
|
|
4
4
|
class Link < WebObject
|
5
5
|
|
6
|
-
def initialize(web_object
|
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.
|
10
|
+
def self.usable_selectors
|
12
11
|
super + [:href, :text, :title, :css]
|
13
12
|
end
|
14
13
|
|
15
|
-
def self.
|
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
|