awetestlib 0.1.28 → 0.1.29pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/.gitattributes +22 -22
  2. data/.gitignore +69 -69
  3. data/.yardopts +7 -7
  4. data/README.md +108 -108
  5. data/awetestlib.gemspec +57 -57
  6. data/awetestlib.windows.gemspec +41 -41
  7. data/awetestlib_notes.txt +4 -4
  8. data/awetestlib_osx.gemspec +47 -48
  9. data/bin/awetestlib +99 -99
  10. data/bin/awetestlib-android-setup.rb +26 -26
  11. data/bin/awetestlib-cucumber-setup.rb +28 -28
  12. data/bin/awetestlib-driver-setup.rb +21 -21
  13. data/bin/awetestlib-helpers.rb +41 -41
  14. data/bin/awetestlib-mobile-app-setup.rb +31 -31
  15. data/bin/awetestlib-netbeans-setup.rb +58 -58
  16. data/bin/awetestlib-regression-setup.rb +15 -15
  17. data/bin/awetestlib-rubymine-setup.rb +39 -39
  18. data/drivers/chromedriver.exe +0 -0
  19. data/ext/Rakefile +1 -1
  20. data/ext/mkrf_conf.rb +27 -27
  21. data/lib/awetestlib/html_report.rb +142 -142
  22. data/lib/awetestlib/logging.rb +366 -366
  23. data/lib/awetestlib/regression/browser.rb +1380 -1375
  24. data/lib/awetestlib/regression/drag_and_drop.rb +421 -420
  25. data/lib/awetestlib/regression/find.rb +345 -345
  26. data/lib/awetestlib/regression/legacy.rb +1187 -1187
  27. data/lib/awetestlib/regression/page_data.rb +191 -191
  28. data/lib/awetestlib/regression/runner.rb +307 -307
  29. data/lib/awetestlib/regression/tables.rb +627 -619
  30. data/lib/awetestlib/regression/user_input.rb +576 -576
  31. data/lib/awetestlib/regression/utilities.rb +1046 -988
  32. data/lib/awetestlib/regression/validations.rb +1093 -1074
  33. data/lib/awetestlib/regression/waits.rb +470 -470
  34. data/lib/awetestlib/runner.rb +18 -18
  35. data/lib/awetestlib.rb +41 -41
  36. data/lib/patches/README +2 -2
  37. data/lib/patches/firewatir.rb +106 -106
  38. data/lib/patches/watir.rb +175 -175
  39. data/lib/version.rb +2 -2
  40. data/license.txt +13 -13
  41. data/netbeans_setup.md +29 -29
  42. data/rdoc_test.bat +1 -1
  43. data/rubymine_setup.md +23 -23
  44. data/setup_samples/sample_android/features/dk.mejer.hansen.control.FlyingColorsPlayerAidActivity.apk +0 -0
  45. data/setup_samples/sample_android/features/sample_android.feature +5 -5
  46. data/setup_samples/sample_android/features/step_definitions/calabash_steps.rb +1 -1
  47. data/setup_samples/sample_android/features/support/app_installation_hooks.rb +36 -36
  48. data/setup_samples/sample_android/features/support/app_life_cycle_hooks.rb +14 -14
  49. data/setup_samples/sample_android/features/test_servers/8ba795a0288381ae346b67867b586881_0.3.2.apk +0 -0
  50. data/setup_samples/sample_cucumber/features/step_definitions/predefined_steps.rb +76 -76
  51. data/setup_samples/sample_cucumber/features/yahoo_mail.feature +11 -11
  52. data/setup_samples/sample_mobile_app/features/my_first.feature +14 -14
  53. data/setup_samples/sample_mobile_app/features/step_definitions/predefined_webview_steps.rb +80 -80
  54. data/setup_samples/sample_mobile_app/features/support/env.rb +2 -2
  55. data/setup_samples/sample_netbeans/demo.rb +86 -86
  56. data/setup_samples/sample_netbeans/nbproject/configs/Demo.properties +2 -2
  57. data/setup_samples/sample_netbeans/nbproject/private/config.properties +1 -1
  58. data/setup_samples/sample_netbeans/nbproject/private/configs/Demo.properties +2 -2
  59. data/setup_samples/sample_netbeans/nbproject/private/private.properties +2 -2
  60. data/setup_samples/sample_netbeans/nbproject/project.properties +5 -5
  61. data/setup_samples/sample_netbeans/nbproject/project.xml +13 -13
  62. data/setup_samples/sample_rubymine/.idea/encodings.xml +5 -5
  63. data/setup_samples/sample_rubymine/.idea/misc.xml +5 -5
  64. data/setup_samples/sample_rubymine/.idea/modules.xml +9 -9
  65. data/setup_samples/sample_rubymine/.idea/sample_rubymine.iml +9 -9
  66. data/setup_samples/sample_rubymine/.idea/scopes/scope_settings.xml +4 -4
  67. data/setup_samples/sample_rubymine/.idea/vcs.xml +7 -7
  68. data/setup_samples/sample_rubymine/.idea/workspace.xml +213 -213
  69. data/setup_samples/sample_rubymine/demo.rb +86 -86
  70. data/test/create_zoho.rb +66 -66
  71. data/test/create_zoho_account1.rb +68 -68
  72. data/test/create_zoho_account2.rb +72 -72
  73. data/test/demo.rb +87 -87
  74. data/test/google_search1.rb +16 -16
  75. data/test/google_search2.rb +19 -19
  76. data/test/login_1.rb +37 -37
  77. data/test/login_1a.rb +37 -37
  78. data/test/login_2.rb +32 -32
  79. data/test/zoho_exercise.rb +21 -21
  80. data/test/zoho_util.rb +487 -487
  81. data/tmp/placeholder.html +71 -71
  82. 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
+