symbiont 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +22 -22
- data/.travis.yml +25 -14
- data/Gemfile +4 -2
- data/{LICENSE → LICENSE.txt} +22 -22
- data/README.md +57 -65
- data/Rakefile +28 -34
- data/lib/symbiont/accessor.rb +7 -0
- data/lib/symbiont/assertions.rb +33 -0
- data/lib/symbiont/elements.rb +69 -0
- data/lib/symbiont/errors.rb +7 -0
- data/lib/symbiont/factory.rb +75 -46
- data/lib/symbiont/helpers.rb +49 -0
- data/lib/symbiont/logging.rb +5 -0
- data/lib/symbiont/pages.rb +32 -0
- data/lib/symbiont/platform.rb +12 -0
- data/lib/symbiont/version.rb +3 -3
- data/lib/symbiont.rb +34 -92
- data/spec/fixtures/element_definitions.rb +32 -0
- data/spec/fixtures/mock_drivers.rb +8 -0
- data/spec/fixtures/page_definitions.rb +36 -0
- data/spec/spec_helper.rb +31 -80
- data/spec/symbiont/assertion_spec.rb +88 -0
- data/spec/symbiont/driver_spec.rb +41 -0
- data/spec/symbiont/element_spec.rb +8 -0
- data/spec/symbiont/factory_spec.rb +70 -130
- data/spec/symbiont/page_spec.rb +50 -0
- data/symbiont.gemspec +52 -27
- data/test/symbiont-script.rb +97 -0
- metadata +89 -230
- data/Gemfile.lock +0 -44
- data/HISTORY.md +0 -99
- data/app/app.rb +0 -48
- 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 +0 -290
- data/app/public/css/demo_table_jui.css +0 -471
- data/app/public/css/font/ColabLig-webfont.eot +0 -0
- data/app/public/css/font/ColabLig-webfont.svg +0 -149
- 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 +0 -149
- 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 +0 -149
- 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 +0 -149
- 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 +0 -376
- data/app/public/css/site.css +0 -446
- 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 +0 -359
- data/app/public/fancybox/jquery.fancybox-1.3.4.js +0 -1156
- data/app/public/fancybox/jquery.fancybox-1.3.4.min.js +0 -1
- 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 +0 -11
- data/app/public/js/signup.js +0 -141
- data/app/public/js/site.js +0 -42
- data/app/public/js/stardate.js +0 -35
- data/app/public/js/vendor/html5shiv.js +0 -5
- data/app/public/js/vendor/jquery-1.8.3.min.js +0 -2
- data/app/public/js/vendor/jquery.dataTables.min.js +0 -151
- data/app/public/js/vendor/jquery.validate.min.js +0 -4
- data/app/views/comics.erb +0 -344
- data/app/views/index.erb +0 -7
- data/app/views/layout.erb +0 -72
- data/app/views/layout_small.erb +0 -21
- data/app/views/stardate.erb +0 -5
- data/app/views/stardate_calc.erb +0 -30
- data/app/views/webobject.erb +0 -147
- data/lib/symbiont/data_setter.rb +0 -53
- data/lib/symbiont/enclosers.rb +0 -118
- data/lib/symbiont/evaluators.rb +0 -92
- data/lib/symbiont/generators.rb +0 -331
- data/lib/symbiont/locators.rb +0 -43
- data/lib/symbiont/logger.rb +0 -5
- data/lib/symbiont/platform_watir/platform_object.rb +0 -466
- data/lib/symbiont/platform_watir.rb +0 -9
- data/lib/symbiont/platforms.rb +0 -23
- data/lib/symbiont/web_objects/_common.rb +0 -174
- data/lib/symbiont/web_objects/button.rb +0 -22
- data/lib/symbiont/web_objects/checkbox.rb +0 -31
- data/lib/symbiont/web_objects/div.rb +0 -15
- data/lib/symbiont/web_objects/heading.rb +0 -12
- data/lib/symbiont/web_objects/hidden_field.rb +0 -19
- data/lib/symbiont/web_objects/label.rb +0 -15
- data/lib/symbiont/web_objects/link.rb +0 -23
- data/lib/symbiont/web_objects/list_item.rb +0 -13
- data/lib/symbiont/web_objects/option.rb +0 -10
- data/lib/symbiont/web_objects/ordered_list.rb +0 -49
- data/lib/symbiont/web_objects/paragraph.rb +0 -11
- data/lib/symbiont/web_objects/radio.rb +0 -31
- data/lib/symbiont/web_objects/select_list.rb +0 -82
- data/lib/symbiont/web_objects/span.rb +0 -15
- data/lib/symbiont/web_objects/table.rb +0 -71
- data/lib/symbiont/web_objects/table_cell.rb +0 -24
- data/lib/symbiont/web_objects/table_row.rb +0 -59
- data/lib/symbiont/web_objects/text_area.rb +0 -26
- data/lib/symbiont/web_objects/text_field.rb +0 -31
- data/lib/symbiont/web_objects/unordered_list.rb +0 -49
- data/lib/symbiont/web_objects.rb +0 -22
- data/lucid.yml +0 -6
- data/spec/symbiont/data_setter_spec.rb +0 -65
- data/spec/symbiont/enclosers_spec.rb +0 -76
- data/spec/symbiont/evaluators_spec.rb +0 -95
- data/spec/symbiont/generators/button_generators_spec.rb +0 -72
- data/spec/symbiont/generators/checkbox_generators_spec.rb +0 -79
- data/spec/symbiont/generators/div_generators_spec.rb +0 -56
- data/spec/symbiont/generators/hidden_field_generators_spec.rb +0 -65
- data/spec/symbiont/generators/link_generators_spec.rb +0 -62
- data/spec/symbiont/generators/paragraph_generators_spec.rb +0 -57
- data/spec/symbiont/generators/radio_generators_spec.rb +0 -76
- data/spec/symbiont/generators/select_list_generators_spec.rb +0 -93
- data/spec/symbiont/generators/span_generators_spec.rb +0 -56
- data/spec/symbiont/generators/table_cell_generators_spec.rb +0 -56
- data/spec/symbiont/generators/table_generators_spec.rb +0 -56
- data/spec/symbiont/generators/text_area_generators_spec.rb +0 -72
- data/spec/symbiont/generators/text_field_generators_spec.rb +0 -72
- data/spec/symbiont/generators_spec.rb +0 -59
- data/spec/symbiont/locators_spec.rb +0 -68
- data/spec/symbiont/platform_object_spec.rb +0 -18
- data/spec/symbiont/symbiont_spec.rb +0 -29
- data/spec/symbiont/web_object_spec.rb +0 -194
- data/spec/symbiont/web_objects/button_spec.rb +0 -38
- data/spec/symbiont/web_objects/checkbox_spec.rb +0 -27
- data/spec/symbiont/web_objects/div_spec.rb +0 -18
- data/spec/symbiont/web_objects/heading_spec.rb +0 -22
- data/spec/symbiont/web_objects/hidden_field_spec.rb +0 -18
- data/spec/symbiont/web_objects/label_spec.rb +0 -18
- data/spec/symbiont/web_objects/link_spec.rb +0 -33
- data/spec/symbiont/web_objects/list_item_spec.rb +0 -18
- data/spec/symbiont/web_objects/option_spec.rb +0 -9
- data/spec/symbiont/web_objects/ordered_list_spec.rb +0 -53
- data/spec/symbiont/web_objects/paragraph_spec.rb +0 -18
- data/spec/symbiont/web_objects/radio_spec.rb +0 -27
- data/spec/symbiont/web_objects/select_list_spec.rb +0 -69
- data/spec/symbiont/web_objects/span_spec.rb +0 -18
- data/spec/symbiont/web_objects/table_cell_spec.rb +0 -19
- data/spec/symbiont/web_objects/table_row_spec.rb +0 -58
- data/spec/symbiont/web_objects/table_spec.rb +0 -61
- data/spec/symbiont/web_objects/text_area_spec.rb +0 -18
- data/spec/symbiont/web_objects/text_field_spec.rb +0 -39
- data/spec/symbiont/web_objects/unordered_list_spec.rb +0 -51
- data/specs/common/support/browser.rb +0 -25
- data/specs/common/support/env.rb +0 -6
- data/specs/common/support/events.rb +0 -15
- data/specs/enclosers.feature +0 -9
- data/specs/evaluators.feature +0 -26
- data/specs/pages/characters.rb +0 -22
- data/specs/pages/home.rb +0 -9
- data/specs/pages/stardate.rb +0 -23
- data/specs/pages/web_objects.rb +0 -77
- data/specs/select_list.feature +0 -53
- data/specs/steps/enclosers_steps.rb +0 -17
- data/specs/steps/evaluators_steps.rb +0 -44
- data/specs/steps/navigation_steps.rb +0 -14
- data/specs/steps/select_list_steps.rb +0 -94
- data/specs/steps/table_cell_steps.rb +0 -31
- data/specs/steps/table_steps.rb +0 -87
- data/specs/table.feature +0 -49
- data/specs/table_cell.feature +0 -27
data/lib/symbiont/data_setter.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
module Symbiont
|
2
|
-
module DataSetter
|
3
|
-
|
4
|
-
def using(data)
|
5
|
-
data.each do |key, value|
|
6
|
-
use_text_data_with(key, value) if text_settable_for(key) and object_enabled_for(key)
|
7
|
-
use_check_data_with(key, value) if value_checkable_for(key) and object_enabled_for(key)
|
8
|
-
use_select_data_with(key, value) if value_selectable_for(key) and object_enabled_for(key)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
alias :using_data :using
|
13
|
-
alias :using_values :using
|
14
|
-
alias :use_data :using
|
15
|
-
alias :use_values :using
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def use_text_data_with(key, value)
|
20
|
-
self.send "#{key}=", value
|
21
|
-
end
|
22
|
-
|
23
|
-
def use_check_data_with(key, value)
|
24
|
-
if value
|
25
|
-
self.send "check_#{key}"
|
26
|
-
else
|
27
|
-
self.send "uncheck_#{key}"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def use_select_data_with(key, value)
|
32
|
-
self.send "select_#{key}" if value
|
33
|
-
end
|
34
|
-
|
35
|
-
def text_settable_for(key)
|
36
|
-
respond_to?("#{key}=".to_sym)
|
37
|
-
end
|
38
|
-
|
39
|
-
def value_checkable_for(key)
|
40
|
-
respond_to?("check_#{key}".to_sym)
|
41
|
-
end
|
42
|
-
|
43
|
-
def value_selectable_for(key)
|
44
|
-
respond_to?("select_#{key}".to_sym)
|
45
|
-
end
|
46
|
-
|
47
|
-
def object_enabled_for(key)
|
48
|
-
return true if (self.send "#{key}_object").tag_name == "textarea"
|
49
|
-
self.send("#{key}_object").enabled?
|
50
|
-
end
|
51
|
-
|
52
|
-
end # module: DataSetter
|
53
|
-
end # module: Symbiont
|
data/lib/symbiont/enclosers.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
module Symbiont
|
2
|
-
module Enclosers
|
3
|
-
# Provides a context for an action that must succeed within a given time period.
|
4
|
-
# The logic here is simply that the result of the action will be true (meaning
|
5
|
-
# the action was carried out) or false, which means the action did not succeed
|
6
|
-
# in the time allotted.
|
7
|
-
#
|
8
|
-
# @param [Integer] timeout the amount of time in seconds to wait
|
9
|
-
# @param [String] message the text to return if the action did not occur in time
|
10
|
-
# @param [Proc] block the code that calls the desired action
|
11
|
-
#
|
12
|
-
# @example
|
13
|
-
# @page.wait_for(5, 'page with expected title not found') do
|
14
|
-
# @page.title.should == "Test App"
|
15
|
-
# end
|
16
|
-
def wait_for(timeout=Symbiont.page_level_wait, message=nil, &block)
|
17
|
-
platform.wait_for(timeout, message, &block)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Used to identify a web object or action on a web object as existing
|
21
|
-
# within an enclosing window object. The window can be referenced using
|
22
|
-
# either the title attribute of the window or a direct URL. The URL does
|
23
|
-
# not have to be the entire URL; it can just be a page name.
|
24
|
-
#
|
25
|
-
# @param [Hash] locator the :title or :url of the window
|
26
|
-
# @param [Proc; optional] block any code that should be executed as an
|
27
|
-
# action on or within the window
|
28
|
-
#
|
29
|
-
# @example
|
30
|
-
# page.within_window(title: "Report Page")
|
31
|
-
# page.within_window(url: report.html)
|
32
|
-
def within_window(locator, &block)
|
33
|
-
platform.within_window(locator, &block)
|
34
|
-
end
|
35
|
-
|
36
|
-
# Used to identify a web object as existing within an enclosing object
|
37
|
-
# like a frame or an iframe. It is possible to nest by passing in parent
|
38
|
-
# enclosers as the second parameter.
|
39
|
-
#
|
40
|
-
# @param [String] locator how an encloser will be referenced; the
|
41
|
-
# only valid locators here are :id, :index, and :name
|
42
|
-
# @param encloser a parent encloser that is passed from a previous call
|
43
|
-
# @param [optional] block that contains calls to web objects within the
|
44
|
-
# encloser
|
45
|
-
#
|
46
|
-
# @example
|
47
|
-
# within_frame(id: "loginSection") do |encloser|
|
48
|
-
# text_field :username, id: "userName", frame: encloser
|
49
|
-
# button :login, id: "btnSubmit", frame: encloser
|
50
|
-
# end
|
51
|
-
def within_frame(locator, encloser=nil, &block)
|
52
|
-
platform.within_frame(locator, encloser, &block)
|
53
|
-
end
|
54
|
-
|
55
|
-
# Used to identify a web object as existing within an enclosing object
|
56
|
-
# like a modal dialog box. What this does is override the normal call to
|
57
|
-
# showModalDialog and opens a window instead. In order to use this new
|
58
|
-
# window, you have to attach to it.
|
59
|
-
def within_modal(&block)
|
60
|
-
convert_modal_to_window = %Q{
|
61
|
-
window.showModalDialog = function(sURL, vArguments, sFeatures) {
|
62
|
-
window.dialogArguments = vArguments;
|
63
|
-
modalWin = window.open(sURL, 'modal', sFeatures);
|
64
|
-
return modalWin;
|
65
|
-
}
|
66
|
-
}
|
67
|
-
@browser.execute_script(convert_modal_to_window)
|
68
|
-
yield if block_given?
|
69
|
-
end
|
70
|
-
|
71
|
-
# Provides a context for an action that will generate a JavaScript alert
|
72
|
-
# message box. The alert invocation will be overridden by the platform.
|
73
|
-
#
|
74
|
-
# @param [Proc] block the code that generates the alert
|
75
|
-
# @return [String] the message contained in the alert message box
|
76
|
-
#
|
77
|
-
# @example
|
78
|
-
# response = @page.will_alert do
|
79
|
-
# @page.submitForm
|
80
|
-
# end
|
81
|
-
def will_alert(encloser=nil, &block)
|
82
|
-
platform.will_alert(encloser, &block)
|
83
|
-
end
|
84
|
-
|
85
|
-
# Provides a context for an action that will generate a JavaScript
|
86
|
-
# confirmation message box. The confirmation invocation will be
|
87
|
-
# overridden by the platform.
|
88
|
-
#
|
89
|
-
# @param [bool] response true to accept the confirmation, false to cancel it
|
90
|
-
# @param [Proc] block the code that generates the confirmation
|
91
|
-
# @return [String] the message contained in the confirmation message box
|
92
|
-
#
|
93
|
-
# @example
|
94
|
-
# response = @page.will_confirm(true) do
|
95
|
-
# @page.areYouSure
|
96
|
-
# end
|
97
|
-
def will_confirm(response, encloser=nil, &block)
|
98
|
-
platform.will_confirm(response, encloser, &block)
|
99
|
-
end
|
100
|
-
|
101
|
-
# Provides a context for an action that will generate a JavaScript prompt
|
102
|
-
# message box. The prompt invocation will be overridden by the platform.
|
103
|
-
#
|
104
|
-
# @param [String] response the value to be used in the prompt
|
105
|
-
# @param [Proc] block the code that generates the prompt
|
106
|
-
# @return [Hash] :message for the prompt message, :default_value for
|
107
|
-
# the value that the prompt had before the response was applied
|
108
|
-
#
|
109
|
-
# @example
|
110
|
-
# response = @page.will_prompt("use this") do
|
111
|
-
# @page.useValue
|
112
|
-
# end
|
113
|
-
def will_prompt(response, encloser=nil, &block)
|
114
|
-
platform.will_prompt(response, encloser, &block)
|
115
|
-
end
|
116
|
-
|
117
|
-
end # module: Enclosers
|
118
|
-
end # module: Symbiont
|
data/lib/symbiont/evaluators.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
module Symbiont
|
2
|
-
module Evaluators
|
3
|
-
|
4
|
-
## Browser-Level Actions ##
|
5
|
-
|
6
|
-
def visit(url)
|
7
|
-
platform.visit(url)
|
8
|
-
end
|
9
|
-
|
10
|
-
alias_method :navigate_to, :visit
|
11
|
-
|
12
|
-
def url
|
13
|
-
platform.url
|
14
|
-
end
|
15
|
-
|
16
|
-
alias_method :current_url, :url
|
17
|
-
|
18
|
-
# Save a snapshot of the current screen to a provided file location.
|
19
|
-
# The file will be saved as a PNG file in the path specified or in the
|
20
|
-
# location where the tests are being run from.
|
21
|
-
def screenshot(file)
|
22
|
-
platform.screenshot file
|
23
|
-
end
|
24
|
-
|
25
|
-
alias_method :save_screenshot, :screenshot
|
26
|
-
|
27
|
-
# Executes JavaScript against the browser instance.
|
28
|
-
def run_script(script)
|
29
|
-
platform.run_script(script)
|
30
|
-
end
|
31
|
-
|
32
|
-
alias_method :execute_script, :run_script
|
33
|
-
|
34
|
-
def back
|
35
|
-
platform.back
|
36
|
-
end
|
37
|
-
|
38
|
-
def forward
|
39
|
-
platform.forward
|
40
|
-
end
|
41
|
-
|
42
|
-
def refresh
|
43
|
-
platform.refresh
|
44
|
-
end
|
45
|
-
|
46
|
-
def remove_cookies
|
47
|
-
platform.remove_cookies
|
48
|
-
end
|
49
|
-
|
50
|
-
alias_method :clear_cookies, :remove_cookies
|
51
|
-
|
52
|
-
## Page-Level Actions ##
|
53
|
-
|
54
|
-
def text
|
55
|
-
platform.text
|
56
|
-
end
|
57
|
-
|
58
|
-
def markup
|
59
|
-
platform.markup
|
60
|
-
end
|
61
|
-
|
62
|
-
alias_method :html, :markup
|
63
|
-
|
64
|
-
def title
|
65
|
-
platform.title
|
66
|
-
end
|
67
|
-
|
68
|
-
# Returns the element on a page that has the focus.
|
69
|
-
def focus
|
70
|
-
platform.focus
|
71
|
-
end
|
72
|
-
|
73
|
-
alias_method :what_has_focus?, :focus
|
74
|
-
|
75
|
-
def wait_for_app(value=1)
|
76
|
-
sleep value
|
77
|
-
end
|
78
|
-
|
79
|
-
# Provides an evaluator that attempts to wait for any pending AJAX
|
80
|
-
# requests from the jQuery library.
|
81
|
-
def wait_for_pending_requests(time_limit=30, message_if_timeout=nil)
|
82
|
-
end_time = ::Time.now + time_limit
|
83
|
-
until ::Time.now > end_time
|
84
|
-
return if @browser.execute_script('return jQuery.active') == 0
|
85
|
-
sleep 0.5
|
86
|
-
end
|
87
|
-
message = "Pending jQuery requests never indicated completion." unless message_if_timeout
|
88
|
-
raise message
|
89
|
-
end
|
90
|
-
|
91
|
-
end # module: Evaluators
|
92
|
-
end # module: Symbiont
|
data/lib/symbiont/generators.rb
DELETED
@@ -1,331 +0,0 @@
|
|
1
|
-
module Symbiont
|
2
|
-
module Generators
|
3
|
-
|
4
|
-
def url_is(url)
|
5
|
-
define_method("view") do
|
6
|
-
platform.visit(url)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def begin_at(url)
|
11
|
-
define_method("start") do
|
12
|
-
platform.visit(url)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def title_is(title)
|
17
|
-
define_method('has_title?') do
|
18
|
-
wait_for_app
|
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
|
-
valid_title
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def look_for(widget, timeout=::Symbiont.element_level_wait)
|
27
|
-
define_method('has_object?') do
|
28
|
-
if self.respond_to? "#{widget}_object"
|
29
|
-
self.send("#{widget}_object").when_actionable(timeout)
|
30
|
-
else
|
31
|
-
raise "\n\nThe '#{widget}' object was not declared and could not be checked."
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def frame(locator, encloser=nil, &block)
|
37
|
-
encloser = [] if encloser.nil?
|
38
|
-
encloser << locator
|
39
|
-
block.call(encloser)
|
40
|
-
end
|
41
|
-
|
42
|
-
def paragraph(identifier, locator={index: 0}, &block)
|
43
|
-
define_method(identifier) do
|
44
|
-
return platform.paragraph_text_for(locator.clone) unless block_given?
|
45
|
-
self.send("#{identifier}_object").text
|
46
|
-
end
|
47
|
-
|
48
|
-
common_definition_methods(identifier, locator, 'paragraph_element', &block)
|
49
|
-
end
|
50
|
-
|
51
|
-
alias_method :p, :paragraph
|
52
|
-
|
53
|
-
def link(identifier, locator={index: 0}, &block)
|
54
|
-
define_method(identifier) do
|
55
|
-
return platform.click_link_for(locator.clone) unless block_given?
|
56
|
-
self.send("#{identifier}_object").click
|
57
|
-
end
|
58
|
-
|
59
|
-
common_definition_methods(identifier, locator, 'link_element', &block)
|
60
|
-
end
|
61
|
-
|
62
|
-
alias_method :a, :link
|
63
|
-
|
64
|
-
def button(identifier, locator={index: 0}, &block)
|
65
|
-
define_method(identifier) do
|
66
|
-
return platform.click_button_for(locator.clone) unless block_given?
|
67
|
-
self.send("#{name}_object").click
|
68
|
-
end
|
69
|
-
|
70
|
-
common_definition_methods(identifier, locator, 'button_element', &block)
|
71
|
-
end
|
72
|
-
|
73
|
-
def text_field(identifier, locator={index: 0}, &block)
|
74
|
-
define_method(identifier) do
|
75
|
-
return platform.get_text_field_value_for(locator.clone) unless block_given?
|
76
|
-
self.send("#{identifier}_object").value
|
77
|
-
end
|
78
|
-
|
79
|
-
define_method("#{identifier}=") do |value|
|
80
|
-
return platform.set_text_field_value_for(locator.clone, value) unless block_given?
|
81
|
-
self.send("#{identifier}_object").value = value
|
82
|
-
end
|
83
|
-
|
84
|
-
common_definition_methods(identifier, locator, 'text_field_element', &block)
|
85
|
-
end
|
86
|
-
|
87
|
-
alias_method :textfield, :text_field
|
88
|
-
alias_method :text, :text_field
|
89
|
-
|
90
|
-
def text_area(identifier, locator={index: 0}, &block)
|
91
|
-
define_method(identifier) do
|
92
|
-
return platform.get_text_area_value_for(locator.clone) unless block_given?
|
93
|
-
self.send("#{identifier}_object").value
|
94
|
-
end
|
95
|
-
|
96
|
-
define_method("#{identifier}=") do |value|
|
97
|
-
return platform.set_text_area_value_for(locator.clone, value) unless block_given?
|
98
|
-
self.send("#{identifier}_object").value = value
|
99
|
-
end
|
100
|
-
|
101
|
-
common_definition_methods(identifier, locator, 'text_area_element', &block)
|
102
|
-
end
|
103
|
-
|
104
|
-
alias_method :textarea, :text_area
|
105
|
-
|
106
|
-
def hidden_field(identifier, locator={index: 0}, &block)
|
107
|
-
define_method(identifier) do
|
108
|
-
return platform.get_hidden_field_value_for(locator.clone) unless block_given?
|
109
|
-
self.send("#{identifier}_object").value
|
110
|
-
end
|
111
|
-
|
112
|
-
common_definition_methods(identifier, locator, 'hidden_field_element', &block)
|
113
|
-
end
|
114
|
-
|
115
|
-
alias_method :hidden, :hidden_field
|
116
|
-
|
117
|
-
def select_list(identifier, locator={index: 0}, &block)
|
118
|
-
define_method(identifier) do
|
119
|
-
return platform.get_select_list_item_for(locator.clone) unless block_given?
|
120
|
-
self.send("#{identifier}_object").value
|
121
|
-
end
|
122
|
-
|
123
|
-
define_method("#{identifier}_option?") do
|
124
|
-
platform.get_select_list_value_for(locator.clone)
|
125
|
-
end
|
126
|
-
|
127
|
-
define_method("#{identifier}_options?") do
|
128
|
-
object = self.send("#{identifier}_object")
|
129
|
-
(object && object.options) ? object.options.collect(&:text) : []
|
130
|
-
end
|
131
|
-
|
132
|
-
define_method("#{identifier}=") do |value|
|
133
|
-
return platform.set_select_list_value_for(locator.clone, value) unless block_given?
|
134
|
-
self.send("#{identifier}_object").select(value)
|
135
|
-
end
|
136
|
-
|
137
|
-
common_definition_methods(identifier, locator, 'select_list_element', &block)
|
138
|
-
end
|
139
|
-
|
140
|
-
alias_method :select, :select_list
|
141
|
-
|
142
|
-
def checkbox(identifier, locator={index: 0}, &block)
|
143
|
-
define_method("check_#{identifier}") do
|
144
|
-
return platform.check_checkbox_for(locator.clone) unless block_given?
|
145
|
-
self.send("#{identifier}_object").check
|
146
|
-
end
|
147
|
-
|
148
|
-
define_method("uncheck_#{identifier}") do
|
149
|
-
return platform.uncheck_checkbox_for(locator.clone) unless block_given?
|
150
|
-
self.send("#{identifier}_object").uncheck
|
151
|
-
end
|
152
|
-
|
153
|
-
define_method("#{identifier}_checked?") do
|
154
|
-
return platform.check_checkbox_for_checked(locator.clone) unless block_given?
|
155
|
-
self.send("#{identifier}_object").checked?
|
156
|
-
end
|
157
|
-
|
158
|
-
common_definition_methods(identifier, locator, 'checkbox_element', &block)
|
159
|
-
end
|
160
|
-
|
161
|
-
def radio(identifier, locator={index: 0}, &block)
|
162
|
-
#alias_method "#{identifier}_radio".to_sym, "#{identifier}_object".to_sym
|
163
|
-
#alias_method "#{identifier}_radio_button".to_sym, "#{identifier}_object".to_sym
|
164
|
-
|
165
|
-
define_method("#{identifier}_selected?") do
|
166
|
-
return platform.check_radio_for_selected(locator.clone) unless block_given?
|
167
|
-
self.send("#{identifier}_object").selected?
|
168
|
-
end
|
169
|
-
|
170
|
-
alias_method "#{identifier}_set?".to_sym, "#{identifier}_selected?".to_sym
|
171
|
-
|
172
|
-
define_method("select_#{identifier}") do
|
173
|
-
return platform.select_radio_for(locator.clone) unless block_given?
|
174
|
-
self.send("#{identifier}_object").select
|
175
|
-
end
|
176
|
-
|
177
|
-
alias_method "set_#{identifier}".to_sym, "select_#{identifier}".to_sym
|
178
|
-
|
179
|
-
common_definition_methods(identifier, locator, 'radio_element', &block)
|
180
|
-
end
|
181
|
-
|
182
|
-
alias_method :radio_button, :radio
|
183
|
-
|
184
|
-
def table(identifier, locator={index: 0}, &block)
|
185
|
-
define_method(identifier) do
|
186
|
-
return platform.table_text_for(locator.clone) unless block_given?
|
187
|
-
self.send("#{identifier}_object").text
|
188
|
-
end
|
189
|
-
|
190
|
-
common_definition_methods(identifier, locator, 'table_element', &block)
|
191
|
-
end
|
192
|
-
|
193
|
-
def cell(identifier, locator={index: 0}, &block)
|
194
|
-
define_method(identifier) do
|
195
|
-
return platform.get_table_cell_text_for(locator.clone) unless block_given?
|
196
|
-
self.send("#{identifier}_object").text
|
197
|
-
end
|
198
|
-
|
199
|
-
common_definition_methods(identifier, locator, 'cell_element', &block)
|
200
|
-
end
|
201
|
-
|
202
|
-
alias_method :td, :cell
|
203
|
-
|
204
|
-
def div(identifier, locator={index: 0}, &block)
|
205
|
-
define_method(identifier) do
|
206
|
-
return platform.div_text_for(locator.clone) unless block_given?
|
207
|
-
self.send("#{identifier}_object").text
|
208
|
-
end
|
209
|
-
|
210
|
-
common_definition_methods(identifier, locator, 'div_element', &block)
|
211
|
-
end
|
212
|
-
|
213
|
-
def span(identifier, locator={index: 0}, &block)
|
214
|
-
define_method(identifier) do
|
215
|
-
return platform.span_text_for(locator.clone) unless block_given?
|
216
|
-
self.send("#{identifier}_object").text
|
217
|
-
end
|
218
|
-
|
219
|
-
common_definition_methods(identifier, locator, 'span_element', &block)
|
220
|
-
end
|
221
|
-
|
222
|
-
def h1(identifier, locator={index: 0}, &block)
|
223
|
-
define_method(identifier) do
|
224
|
-
return platform.h1_text_for(locator.clone) unless block_given?
|
225
|
-
self.send("#{identifier}_object").text
|
226
|
-
end
|
227
|
-
|
228
|
-
common_definition_methods(identifier, locator, 'h1_element', &block)
|
229
|
-
end
|
230
|
-
|
231
|
-
def h2(identifier, locator={index: 0}, &block)
|
232
|
-
define_method(identifier) do
|
233
|
-
return platform.h2_text_for(locator.clone) unless block_given?
|
234
|
-
self.send("#{identifier}_object").text
|
235
|
-
end
|
236
|
-
|
237
|
-
common_definition_methods(identifier, locator, 'h2_element', &block)
|
238
|
-
end
|
239
|
-
|
240
|
-
def label(identifier, locator={index: 0}, &block)
|
241
|
-
define_method(identifier) do
|
242
|
-
return platform.label_text_for(locator.clone) unless block_given?
|
243
|
-
self.send("#{identifier}_object").text
|
244
|
-
end
|
245
|
-
|
246
|
-
common_definition_methods(identifier, locator, 'label_element', &block)
|
247
|
-
end
|
248
|
-
|
249
|
-
def ordered_list(identifier, locator={:index => 0}, &block)
|
250
|
-
define_method(identifier) do
|
251
|
-
return platform.ordered_list_text_for(locator.clone) unless block_given?
|
252
|
-
self.send("#{identifier}_object").text
|
253
|
-
end
|
254
|
-
|
255
|
-
common_definition_methods(identifier, locator, 'ordered_list_element', &block)
|
256
|
-
end
|
257
|
-
|
258
|
-
alias_method :ol, :ordered_list
|
259
|
-
|
260
|
-
def unordered_list(identifier, locator={:index => 0}, &block)
|
261
|
-
define_method(identifier) do
|
262
|
-
return platform.unordered_list_text_for(locator.clone) unless block_given?
|
263
|
-
self.send("#{identifier}_object").text
|
264
|
-
end
|
265
|
-
|
266
|
-
common_definition_methods(identifier, locator, 'unordered_list_element', &block)
|
267
|
-
end
|
268
|
-
|
269
|
-
alias_method :ul, :unordered_list
|
270
|
-
|
271
|
-
def list_item(identifier, locator={:index => 0}, &block)
|
272
|
-
define_method(identifier) do
|
273
|
-
return platform.list_item_text_for(locator.clone) unless block_given?
|
274
|
-
self.send("#{identifier}_object").text
|
275
|
-
end
|
276
|
-
|
277
|
-
common_definition_methods(identifier, locator, 'list_item_element', &block)
|
278
|
-
end
|
279
|
-
|
280
|
-
alias_method :li, :list_item
|
281
|
-
|
282
|
-
## Multiple Element Handling ##
|
283
|
-
|
284
|
-
[:unordered_lists, :ordered_lists, :list_items].each do |method|
|
285
|
-
define_method(method) do |identifier, *locator, &block|
|
286
|
-
define_method("#{identifier}_elements") do
|
287
|
-
return process_block(&block) unless block.nil?
|
288
|
-
platform_method = "#{method.to_s}_elements"
|
289
|
-
puts "*********** #{platform_method}"
|
290
|
-
platform.send(platform_method, locator.first.clone)
|
291
|
-
end
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
def common_definition_methods(identifier, locator, method, &block)
|
296
|
-
define_method("#{identifier}_object") do
|
297
|
-
return process_block(&block) if block_given?
|
298
|
-
platform.send(method, locator.clone)
|
299
|
-
end
|
300
|
-
|
301
|
-
define_method("#{identifier}_exists?") do
|
302
|
-
return process_block(&block).exists? if block_given?
|
303
|
-
platform.send(method, locator.clone).exists?
|
304
|
-
end
|
305
|
-
|
306
|
-
define_method("#{identifier}_visible?") do
|
307
|
-
return process_block(&block).visible? if block_given?
|
308
|
-
platform.send(method, locator.clone).visible?
|
309
|
-
end
|
310
|
-
|
311
|
-
define_method("#{identifier}_enabled?") do
|
312
|
-
return process_block(&block).enabled? if block_given?
|
313
|
-
platform.send(method, locator.clone).enabled?
|
314
|
-
end
|
315
|
-
|
316
|
-
define_method("#{identifier}_text") do
|
317
|
-
return process_block(&block).text if block_given?
|
318
|
-
platform.send(method, locator.clone).text
|
319
|
-
end
|
320
|
-
|
321
|
-
element = method[0..method.rindex("_") - 1] if method.count("_") == 2
|
322
|
-
element = method[0..method.index("_") - 1] if method.count("_") == 1
|
323
|
-
|
324
|
-
alias_method "#{identifier}_#{element}".to_sym, "#{identifier}_object".to_sym
|
325
|
-
alias_method "#{identifier}?".to_sym, "#{identifier}_exists?".to_sym
|
326
|
-
alias_method "#{identifier}_?".to_sym, "#{identifier}_visible?".to_sym
|
327
|
-
alias_method "#{identifier}!".to_sym, "#{identifier}_enabled?".to_sym
|
328
|
-
end
|
329
|
-
|
330
|
-
end # module: Generators
|
331
|
-
end # module: Symbiont
|
data/lib/symbiont/locators.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
module Symbiont
|
2
|
-
module Locators
|
3
|
-
def link_object(locator)
|
4
|
-
platform.link_element(locator)
|
5
|
-
end
|
6
|
-
|
7
|
-
def button_object(locator)
|
8
|
-
platform.button_element(locator)
|
9
|
-
end
|
10
|
-
|
11
|
-
def text_field_object(locator)
|
12
|
-
platform.text_field_element(locator)
|
13
|
-
end
|
14
|
-
|
15
|
-
def select_list_object(locator)
|
16
|
-
platform.select_list_element(locator)
|
17
|
-
end
|
18
|
-
|
19
|
-
def checkbox_object(locator)
|
20
|
-
platform.checkbox_element(locator)
|
21
|
-
end
|
22
|
-
|
23
|
-
def radio_object(locator)
|
24
|
-
platform.radio_element(locator)
|
25
|
-
end
|
26
|
-
|
27
|
-
def div_object(locator)
|
28
|
-
platform.div_element(locator)
|
29
|
-
end
|
30
|
-
|
31
|
-
def span_object(locator)
|
32
|
-
platform.span_element(locator)
|
33
|
-
end
|
34
|
-
|
35
|
-
def table_object(locator)
|
36
|
-
platform.table_element(locator)
|
37
|
-
end
|
38
|
-
|
39
|
-
def cell_object(locator)
|
40
|
-
platform.cell_element(locator)
|
41
|
-
end
|
42
|
-
end # module: Locators
|
43
|
-
end # module: Symbiont
|