awetestlib 0.1.28 → 0.1.29pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +22 -22
- data/.gitignore +69 -69
- data/.yardopts +7 -7
- data/README.md +108 -108
- data/awetestlib.gemspec +57 -57
- data/awetestlib.windows.gemspec +41 -41
- data/awetestlib_notes.txt +4 -4
- data/awetestlib_osx.gemspec +47 -48
- data/bin/awetestlib +99 -99
- data/bin/awetestlib-android-setup.rb +26 -26
- data/bin/awetestlib-cucumber-setup.rb +28 -28
- data/bin/awetestlib-driver-setup.rb +21 -21
- data/bin/awetestlib-helpers.rb +41 -41
- data/bin/awetestlib-mobile-app-setup.rb +31 -31
- data/bin/awetestlib-netbeans-setup.rb +58 -58
- data/bin/awetestlib-regression-setup.rb +15 -15
- data/bin/awetestlib-rubymine-setup.rb +39 -39
- data/drivers/chromedriver.exe +0 -0
- data/ext/Rakefile +1 -1
- data/ext/mkrf_conf.rb +27 -27
- data/lib/awetestlib/html_report.rb +142 -142
- data/lib/awetestlib/logging.rb +366 -366
- data/lib/awetestlib/regression/browser.rb +1380 -1375
- data/lib/awetestlib/regression/drag_and_drop.rb +421 -420
- data/lib/awetestlib/regression/find.rb +345 -345
- data/lib/awetestlib/regression/legacy.rb +1187 -1187
- data/lib/awetestlib/regression/page_data.rb +191 -191
- data/lib/awetestlib/regression/runner.rb +307 -307
- data/lib/awetestlib/regression/tables.rb +627 -619
- data/lib/awetestlib/regression/user_input.rb +576 -576
- data/lib/awetestlib/regression/utilities.rb +1046 -988
- data/lib/awetestlib/regression/validations.rb +1093 -1074
- data/lib/awetestlib/regression/waits.rb +470 -470
- data/lib/awetestlib/runner.rb +18 -18
- data/lib/awetestlib.rb +41 -41
- data/lib/patches/README +2 -2
- data/lib/patches/firewatir.rb +106 -106
- data/lib/patches/watir.rb +175 -175
- data/lib/version.rb +2 -2
- data/license.txt +13 -13
- data/netbeans_setup.md +29 -29
- data/rdoc_test.bat +1 -1
- data/rubymine_setup.md +23 -23
- data/setup_samples/sample_android/features/dk.mejer.hansen.control.FlyingColorsPlayerAidActivity.apk +0 -0
- data/setup_samples/sample_android/features/sample_android.feature +5 -5
- data/setup_samples/sample_android/features/step_definitions/calabash_steps.rb +1 -1
- data/setup_samples/sample_android/features/support/app_installation_hooks.rb +36 -36
- data/setup_samples/sample_android/features/support/app_life_cycle_hooks.rb +14 -14
- data/setup_samples/sample_android/features/test_servers/8ba795a0288381ae346b67867b586881_0.3.2.apk +0 -0
- data/setup_samples/sample_cucumber/features/step_definitions/predefined_steps.rb +76 -76
- data/setup_samples/sample_cucumber/features/yahoo_mail.feature +11 -11
- data/setup_samples/sample_mobile_app/features/my_first.feature +14 -14
- data/setup_samples/sample_mobile_app/features/step_definitions/predefined_webview_steps.rb +80 -80
- data/setup_samples/sample_mobile_app/features/support/env.rb +2 -2
- data/setup_samples/sample_netbeans/demo.rb +86 -86
- data/setup_samples/sample_netbeans/nbproject/configs/Demo.properties +2 -2
- data/setup_samples/sample_netbeans/nbproject/private/config.properties +1 -1
- data/setup_samples/sample_netbeans/nbproject/private/configs/Demo.properties +2 -2
- data/setup_samples/sample_netbeans/nbproject/private/private.properties +2 -2
- data/setup_samples/sample_netbeans/nbproject/project.properties +5 -5
- data/setup_samples/sample_netbeans/nbproject/project.xml +13 -13
- data/setup_samples/sample_rubymine/.idea/encodings.xml +5 -5
- data/setup_samples/sample_rubymine/.idea/misc.xml +5 -5
- data/setup_samples/sample_rubymine/.idea/modules.xml +9 -9
- data/setup_samples/sample_rubymine/.idea/sample_rubymine.iml +9 -9
- data/setup_samples/sample_rubymine/.idea/scopes/scope_settings.xml +4 -4
- data/setup_samples/sample_rubymine/.idea/vcs.xml +7 -7
- data/setup_samples/sample_rubymine/.idea/workspace.xml +213 -213
- data/setup_samples/sample_rubymine/demo.rb +86 -86
- data/test/create_zoho.rb +66 -66
- data/test/create_zoho_account1.rb +68 -68
- data/test/create_zoho_account2.rb +72 -72
- data/test/demo.rb +87 -87
- data/test/google_search1.rb +16 -16
- data/test/google_search2.rb +19 -19
- data/test/login_1.rb +37 -37
- data/test/login_1a.rb +37 -37
- data/test/login_2.rb +32 -32
- data/test/zoho_exercise.rb +21 -21
- data/test/zoho_util.rb +487 -487
- data/tmp/placeholder.html +71 -71
- metadata +18 -49
@@ -1,191 +1,191 @@
|
|
1
|
-
module Awetestlib
|
2
|
-
module Regression
|
3
|
-
# Methods for capture and manipulation of data contained in
|
4
|
-
# text, values, and/or states of spans, text fields, radios, checkboxes, and select_lists.
|
5
|
-
module PageData
|
6
|
-
|
7
|
-
# @!group Core
|
8
|
-
|
9
|
-
=begin rdoc
|
10
|
-
:category: Page Data
|
11
|
-
:tags: data, DOM, page
|
12
|
-
|
13
|
-
_Parameters_::
|
14
|
-
|
15
|
-
*browser* is any container element, usually the browser window or a div within it. Best to use is the smallest that contains the desired data.
|
16
|
-
|
17
|
-
*types* is an array that defaults to all of: :text, :textarea, :select_list, :span, :hidden, :checkbox, and :radio.
|
18
|
-
Set types to an array of a subset of these if fewer elements are desired.
|
19
|
-
|
20
|
-
No positive validations are reported but failure is rescued and reported.
|
21
|
-
=end
|
22
|
-
def capture_page_data(browser, types = [:text, :textarea, :select_list, :span, :hidden, :checkbox, :radio])
|
23
|
-
start = Time.now
|
24
|
-
debug_to_log("Begin #{__method__}")
|
25
|
-
data = Hash.new
|
26
|
-
data[:id] = Hash.new
|
27
|
-
data[:name] = Hash.new
|
28
|
-
data[:index] = Hash.new
|
29
|
-
types.each do |type|
|
30
|
-
#debug_to_log("#{__method__}: #{type}. . .")
|
31
|
-
data[:id][type], data[:name][type], data[:index][type] = parse_elements(browser, type)
|
32
|
-
end
|
33
|
-
data
|
34
|
-
rescue
|
35
|
-
failed_to_log("#{__method__}: '#{$!}'")
|
36
|
-
ensure
|
37
|
-
stop = Time.now
|
38
|
-
passed_to_log("#{__method__.to_s.titleize} finished. (#{"%.5f" % (stop - start)} secs)")
|
39
|
-
#debug_to_log("End #{__method__}")
|
40
|
-
end
|
41
|
-
|
42
|
-
def compare_page_data(before, after, how, desc = '')
|
43
|
-
[:text, :textarea, :select_list, :span, :hidden, :checkbox, :radio].each do |type|
|
44
|
-
before[how][type].each_key do |what|
|
45
|
-
msg = "#{desc} #{type} #{how}=#{what}: Expected '#{before[how][type][what]}'."
|
46
|
-
if after[how][type][what] == before[how][type][what]
|
47
|
-
passed_to_log(msg)
|
48
|
-
else
|
49
|
-
failed_to_log("#{msg} Found '#{after[how][type][what]}'")
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
rescue
|
54
|
-
failed_to_log("Unable to compare before and after page data. '#{$!}'")
|
55
|
-
end
|
56
|
-
|
57
|
-
=begin rdoc
|
58
|
-
:category: Page Data
|
59
|
-
:tags:data, DOM
|
60
|
-
|
61
|
-
*data* is the hash returned by capture_page_data().
|
62
|
-
|
63
|
-
*how* is one of :id, :name, :index
|
64
|
-
|
65
|
-
*what* is the target value for how. It can be a string or a regular expression
|
66
|
-
|
67
|
-
*type* is one of :text,:textarea,:select_list,:span,:hidden,:checkbox,:radio
|
68
|
-
|
69
|
-
*get_text* determines whether selected option's text or value is returned. Default is true, i.e., return the selected text.
|
70
|
-
This only applies when the *type* is :select_list.
|
71
|
-
|
72
|
-
=end
|
73
|
-
def fetch_page_data(data, how, what, type, get_text = true)
|
74
|
-
rslt = data[how][type][what]
|
75
|
-
if type == :select_list
|
76
|
-
value, text = rslt.split('::')
|
77
|
-
if get_text
|
78
|
-
rslt = text
|
79
|
-
else
|
80
|
-
rslt = value
|
81
|
-
end
|
82
|
-
end
|
83
|
-
rslt
|
84
|
-
end
|
85
|
-
|
86
|
-
=begin rdoc
|
87
|
-
:category: Page Data
|
88
|
-
:tags:data, DOM
|
89
|
-
|
90
|
-
*browser* is any container element. best to use is the smallest that contains the desired data.
|
91
|
-
|
92
|
-
*type* is one of these symbols: :text,:textarea,:select_list,:span,:hidden,:checkbox,:radio
|
93
|
-
|
94
|
-
Returns three hashes: id[type][id] = value, name[type][id] = value, index[type][id] = value
|
95
|
-
|
96
|
-
A given element appears once in the set of hashes depending on how is is found: id first
|
97
|
-
then name, then index.
|
98
|
-
|
99
|
-
Select list value is in the form 'value::text'. parse with x.split('::')
|
100
|
-
|
101
|
-
No positive validations are reported but failure is rescued and reported.
|
102
|
-
=end
|
103
|
-
def parse_elements(browser, type)
|
104
|
-
id = Hash.new
|
105
|
-
name = Hash.new
|
106
|
-
index = Hash.new
|
107
|
-
idx = 0
|
108
|
-
#debug_to_log("#{__method__}: #{type}")
|
109
|
-
case type
|
110
|
-
when :span
|
111
|
-
collection = browser.spans
|
112
|
-
when :select_list
|
113
|
-
collection = browser.select_lists
|
114
|
-
when :radio
|
115
|
-
collection = browser.radios
|
116
|
-
when :checkbox
|
117
|
-
collection = browser.checkboxes
|
118
|
-
else
|
119
|
-
collection = browser.elements(:type, type.to_s)
|
120
|
-
end
|
121
|
-
#debug_to_log("#{__method__}: collection: #{collection.inspect}")
|
122
|
-
collection.each do |e|
|
123
|
-
case type
|
124
|
-
when :span
|
125
|
-
vlu = e.text
|
126
|
-
when :select_list
|
127
|
-
vlu = "#{e.value}::#{e.selected_options[0]}"
|
128
|
-
when :radio
|
129
|
-
vlu = e.set?
|
130
|
-
when :checkbox
|
131
|
-
vlu = e.set?
|
132
|
-
else
|
133
|
-
vlu = e.value
|
134
|
-
end
|
135
|
-
idx += 1
|
136
|
-
if e.id.length > 0 and not e.id =~ /^__[A-Z]/
|
137
|
-
id[e.id] = vlu
|
138
|
-
elsif e.name.length > 0 and not e.name =~ /^__[A-Z]/
|
139
|
-
name[e.name] = vlu
|
140
|
-
else
|
141
|
-
index[idx] = vlu if not type == :hidden
|
142
|
-
end
|
143
|
-
end
|
144
|
-
[id, name, index]
|
145
|
-
|
146
|
-
rescue
|
147
|
-
failed_to_log("#{__method__}: '#{$!}'")
|
148
|
-
end
|
149
|
-
|
150
|
-
def get_textfield_value(browser, how, what, desc = '')
|
151
|
-
msg = build_message("Return value in textfield #{how}='#{what}'", desc)
|
152
|
-
tf = browser.text_field(how, what)
|
153
|
-
if tf
|
154
|
-
debug_to_log("#{tf.inspect}")
|
155
|
-
vlu = tf.value
|
156
|
-
passed_to_log("#{msg} Value='#{vlu}'")
|
157
|
-
vlu
|
158
|
-
else
|
159
|
-
failed_to_log("#{msg}")
|
160
|
-
end
|
161
|
-
rescue
|
162
|
-
failed_to_log("Unable to #{msg}: '#{$!}'")
|
163
|
-
end
|
164
|
-
|
165
|
-
def get_element_text(browser, element, how, what, desc = '')
|
166
|
-
msg = build_message("Return text in #{element} #{how}='#{what}'", desc)
|
167
|
-
text = browser.element(how, what).text
|
168
|
-
passed_to_log("#{msg} text='#{text}'")
|
169
|
-
text
|
170
|
-
rescue
|
171
|
-
failed_to_log("Unable to #{msg}: '#{$!}'")
|
172
|
-
end
|
173
|
-
|
174
|
-
# @!endgroup Core
|
175
|
-
|
176
|
-
# @!group Legacy (Backward compatible usage)
|
177
|
-
|
178
|
-
def get_textfield_value_by_name(browser, strg, desc = '')
|
179
|
-
get_textfield_value(browser, :name, strg, desc)
|
180
|
-
end
|
181
|
-
|
182
|
-
def get_textfield_value_by_id(browser, strg)
|
183
|
-
get_textfield_value(browser, :id, strg)
|
184
|
-
end
|
185
|
-
|
186
|
-
# @!endgroup Legacy
|
187
|
-
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
1
|
+
module Awetestlib
|
2
|
+
module Regression
|
3
|
+
# Methods for capture and manipulation of data contained in
|
4
|
+
# text, values, and/or states of spans, text fields, radios, checkboxes, and select_lists.
|
5
|
+
module PageData
|
6
|
+
|
7
|
+
# @!group Core
|
8
|
+
|
9
|
+
=begin rdoc
|
10
|
+
:category: Page Data
|
11
|
+
:tags: data, DOM, page
|
12
|
+
|
13
|
+
_Parameters_::
|
14
|
+
|
15
|
+
*browser* is any container element, usually the browser window or a div within it. Best to use is the smallest that contains the desired data.
|
16
|
+
|
17
|
+
*types* is an array that defaults to all of: :text, :textarea, :select_list, :span, :hidden, :checkbox, and :radio.
|
18
|
+
Set types to an array of a subset of these if fewer elements are desired.
|
19
|
+
|
20
|
+
No positive validations are reported but failure is rescued and reported.
|
21
|
+
=end
|
22
|
+
def capture_page_data(browser, types = [:text, :textarea, :select_list, :span, :hidden, :checkbox, :radio])
|
23
|
+
start = Time.now
|
24
|
+
debug_to_log("Begin #{__method__}")
|
25
|
+
data = Hash.new
|
26
|
+
data[:id] = Hash.new
|
27
|
+
data[:name] = Hash.new
|
28
|
+
data[:index] = Hash.new
|
29
|
+
types.each do |type|
|
30
|
+
#debug_to_log("#{__method__}: #{type}. . .")
|
31
|
+
data[:id][type], data[:name][type], data[:index][type] = parse_elements(browser, type)
|
32
|
+
end
|
33
|
+
data
|
34
|
+
rescue
|
35
|
+
failed_to_log("#{__method__}: '#{$!}'")
|
36
|
+
ensure
|
37
|
+
stop = Time.now
|
38
|
+
passed_to_log("#{__method__.to_s.titleize} finished. (#{"%.5f" % (stop - start)} secs)")
|
39
|
+
#debug_to_log("End #{__method__}")
|
40
|
+
end
|
41
|
+
|
42
|
+
def compare_page_data(before, after, how, desc = '')
|
43
|
+
[:text, :textarea, :select_list, :span, :hidden, :checkbox, :radio].each do |type|
|
44
|
+
before[how][type].each_key do |what|
|
45
|
+
msg = "#{desc} #{type} #{how}=#{what}: Expected '#{before[how][type][what]}'."
|
46
|
+
if after[how][type][what] == before[how][type][what]
|
47
|
+
passed_to_log(msg)
|
48
|
+
else
|
49
|
+
failed_to_log("#{msg} Found '#{after[how][type][what]}'")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
rescue
|
54
|
+
failed_to_log("Unable to compare before and after page data. '#{$!}'")
|
55
|
+
end
|
56
|
+
|
57
|
+
=begin rdoc
|
58
|
+
:category: Page Data
|
59
|
+
:tags:data, DOM
|
60
|
+
|
61
|
+
*data* is the hash returned by capture_page_data().
|
62
|
+
|
63
|
+
*how* is one of :id, :name, :index
|
64
|
+
|
65
|
+
*what* is the target value for how. It can be a string or a regular expression
|
66
|
+
|
67
|
+
*type* is one of :text,:textarea,:select_list,:span,:hidden,:checkbox,:radio
|
68
|
+
|
69
|
+
*get_text* determines whether selected option's text or value is returned. Default is true, i.e., return the selected text.
|
70
|
+
This only applies when the *type* is :select_list.
|
71
|
+
|
72
|
+
=end
|
73
|
+
def fetch_page_data(data, how, what, type, get_text = true)
|
74
|
+
rslt = data[how][type][what]
|
75
|
+
if type == :select_list
|
76
|
+
value, text = rslt.split('::')
|
77
|
+
if get_text
|
78
|
+
rslt = text
|
79
|
+
else
|
80
|
+
rslt = value
|
81
|
+
end
|
82
|
+
end
|
83
|
+
rslt
|
84
|
+
end
|
85
|
+
|
86
|
+
=begin rdoc
|
87
|
+
:category: Page Data
|
88
|
+
:tags:data, DOM
|
89
|
+
|
90
|
+
*browser* is any container element. best to use is the smallest that contains the desired data.
|
91
|
+
|
92
|
+
*type* is one of these symbols: :text,:textarea,:select_list,:span,:hidden,:checkbox,:radio
|
93
|
+
|
94
|
+
Returns three hashes: id[type][id] = value, name[type][id] = value, index[type][id] = value
|
95
|
+
|
96
|
+
A given element appears once in the set of hashes depending on how is is found: id first
|
97
|
+
then name, then index.
|
98
|
+
|
99
|
+
Select list value is in the form 'value::text'. parse with x.split('::')
|
100
|
+
|
101
|
+
No positive validations are reported but failure is rescued and reported.
|
102
|
+
=end
|
103
|
+
def parse_elements(browser, type)
|
104
|
+
id = Hash.new
|
105
|
+
name = Hash.new
|
106
|
+
index = Hash.new
|
107
|
+
idx = 0
|
108
|
+
#debug_to_log("#{__method__}: #{type}")
|
109
|
+
case type
|
110
|
+
when :span
|
111
|
+
collection = browser.spans
|
112
|
+
when :select_list
|
113
|
+
collection = browser.select_lists
|
114
|
+
when :radio
|
115
|
+
collection = browser.radios
|
116
|
+
when :checkbox
|
117
|
+
collection = browser.checkboxes
|
118
|
+
else
|
119
|
+
collection = browser.elements(:type, type.to_s)
|
120
|
+
end
|
121
|
+
#debug_to_log("#{__method__}: collection: #{collection.inspect}")
|
122
|
+
collection.each do |e|
|
123
|
+
case type
|
124
|
+
when :span
|
125
|
+
vlu = e.text
|
126
|
+
when :select_list
|
127
|
+
vlu = "#{e.value}::#{e.selected_options[0]}"
|
128
|
+
when :radio
|
129
|
+
vlu = e.set?
|
130
|
+
when :checkbox
|
131
|
+
vlu = e.set?
|
132
|
+
else
|
133
|
+
vlu = e.value
|
134
|
+
end
|
135
|
+
idx += 1
|
136
|
+
if e.id.length > 0 and not e.id =~ /^__[A-Z]/
|
137
|
+
id[e.id] = vlu
|
138
|
+
elsif e.name.length > 0 and not e.name =~ /^__[A-Z]/
|
139
|
+
name[e.name] = vlu
|
140
|
+
else
|
141
|
+
index[idx] = vlu if not type == :hidden
|
142
|
+
end
|
143
|
+
end
|
144
|
+
[id, name, index]
|
145
|
+
|
146
|
+
rescue
|
147
|
+
failed_to_log("#{__method__}: '#{$!}'")
|
148
|
+
end
|
149
|
+
|
150
|
+
def get_textfield_value(browser, how, what, desc = '')
|
151
|
+
msg = build_message("Return value in textfield #{how}='#{what}'", desc)
|
152
|
+
tf = browser.text_field(how, what)
|
153
|
+
if tf
|
154
|
+
debug_to_log("#{tf.inspect}")
|
155
|
+
vlu = tf.value
|
156
|
+
passed_to_log("#{msg} Value='#{vlu}'")
|
157
|
+
vlu
|
158
|
+
else
|
159
|
+
failed_to_log("#{msg}")
|
160
|
+
end
|
161
|
+
rescue
|
162
|
+
failed_to_log("Unable to #{msg}: '#{$!}'")
|
163
|
+
end
|
164
|
+
|
165
|
+
def get_element_text(browser, element, how, what, desc = '')
|
166
|
+
msg = build_message("Return text in #{element} #{how}='#{what}'", desc)
|
167
|
+
text = browser.element(how, what).text
|
168
|
+
passed_to_log("#{msg} text='#{text}'")
|
169
|
+
text
|
170
|
+
rescue
|
171
|
+
failed_to_log("Unable to #{msg}: '#{$!}'")
|
172
|
+
end
|
173
|
+
|
174
|
+
# @!endgroup Core
|
175
|
+
|
176
|
+
# @!group Legacy (Backward compatible usage)
|
177
|
+
|
178
|
+
def get_textfield_value_by_name(browser, strg, desc = '')
|
179
|
+
get_textfield_value(browser, :name, strg, desc)
|
180
|
+
end
|
181
|
+
|
182
|
+
def get_textfield_value_by_id(browser, strg)
|
183
|
+
get_textfield_value(browser, :id, strg)
|
184
|
+
end
|
185
|
+
|
186
|
+
# @!endgroup Legacy
|
187
|
+
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|