awetestlib 0.1.29pre3 → 0.1.29pre4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/README.md +16 -8
  2. data/awetestlib.windows.gemspec +42 -41
  3. data/awetestlib_osx.gemspec +41 -47
  4. data/bin/awetestlib-android-setup.rb +2 -1
  5. data/bin/awetestlib-cucumber-setup.rb +2 -1
  6. data/bin/awetestlib-driver-setup.rb +1 -0
  7. data/bin/awetestlib-helpers.rb +2 -2
  8. data/bin/awetestlib-mobile-app-setup.rb +1 -0
  9. data/bin/awetestlib-netbeans-setup.rb +2 -1
  10. data/bin/awetestlib-regression-setup.rb +26 -12
  11. data/bin/awetestlib-rubymine-setup.rb +9 -4
  12. data/images/netbeans1.jpg +0 -0
  13. data/images/netbeans2.jpg +0 -0
  14. data/images/netbeans3.jpg +0 -0
  15. data/images/netbeans4.jpg +0 -0
  16. data/images/netbeans5.jpg +0 -0
  17. data/images/rubymine1.jpg +0 -0
  18. data/images/rubymine2.jpg +0 -0
  19. data/images/rubymine3.jpg +0 -0
  20. data/images/rubymine4.jpg +0 -0
  21. data/images/scripting1.png +0 -0
  22. data/images/scripting2.png +0 -0
  23. data/images/scripting3.png +0 -0
  24. data/images/scripting4.png +0 -0
  25. data/lib/awetestlib/logging.rb +6 -6
  26. data/lib/awetestlib/regression/browser.rb +15 -12
  27. data/lib/awetestlib/regression/drag_and_drop.rb +421 -421
  28. data/lib/awetestlib/regression/runner.rb +311 -307
  29. data/lib/awetestlib/regression/tables.rb +627 -627
  30. data/lib/awetestlib/regression/user_input.rb +576 -576
  31. data/lib/awetestlib/regression/utilities.rb +1056 -1046
  32. data/lib/awetestlib/regression/validations.rb +2 -1
  33. data/lib/version.rb +2 -2
  34. data/netbeans_setup.md +30 -30
  35. data/rubymine_setup.md +24 -24
  36. data/setup_samples/sample_cucumber/features/step_definitions/predefined_steps.rb +303 -25
  37. metadata +160 -34
  38. checksums.yaml +0 -7
@@ -1,307 +1,311 @@
1
- require 'awetestlib/regression/browser'
2
- require 'awetestlib/regression/find'
3
- require 'awetestlib/regression/user_input'
4
- require 'awetestlib/regression/waits'
5
- require 'awetestlib/regression/tables'
6
- require 'awetestlib/regression/page_data'
7
- require 'awetestlib/regression/drag_and_drop'
8
- require 'awetestlib/regression/utilities'
9
- require 'awetestlib/regression/legacy'
10
- require 'awetestlib/logging'
11
- require 'awetestlib/regression/validations'
12
- require 'awetestlib/html_report'
13
- #require 'rbconfig'
14
- require 'ostruct'
15
- require 'active_support'
16
- require 'active_support/inflector'
17
-
18
- module Awetestlib
19
- module Regression
20
- # Collects all the components needed to run the script and executes it.
21
- class Runner < Awetestlib::Runner
22
-
23
- # order matters here
24
- include ActiveSupport::Inflector
25
- include Awetestlib::Logging
26
- include Awetestlib::Regression::Utilities
27
- include Awetestlib::Regression::Browser
28
- include Awetestlib::Regression::Find
29
- include Awetestlib::Regression::UserInput
30
- include Awetestlib::Regression::Waits
31
- include Awetestlib::Regression::Tables
32
- include Awetestlib::Regression::PageData
33
- include Awetestlib::Regression::DragAndDrop
34
- include Awetestlib::Regression::Validations
35
- include Awetestlib::Regression::Legacy
36
-
37
- ::DEBUG = 0
38
- ::INFO = 1
39
- ::WARN = 2
40
- ::ERROR = 3
41
- ::FATAL = 4
42
- ::UNKNOWN = 5
43
-
44
- ::TOP_LEVEL = 7
45
- ::SECOND_LEVEL = ::TOP_LEVEL - 1
46
-
47
- ::WAIT = 20
48
- ::PASS = '-PASS'
49
- ::FAIL = '-FAIL'
50
-
51
- attr_accessor :browser, :browser_abbrev, :version, :env,
52
- :library, :script_type, :script_file,
53
- :log_properties, :log_queue, :log_class,
54
- :notify_queue, :notify_class, :notify_id,
55
- :screencap_path, :xls_path, :script_path, :user_token, :root_path,
56
- :debug_on_fail,
57
- :environment, :environment_name, :environment_url, :environment_nodename,
58
- :cycle, :browser_sequence,
59
- :output_to_log, :log_path_subdir, :report_all_test_refs,
60
- :timeout
61
-
62
- #def self.build(options)
63
- # #build_class = "Awetestlib::#{script_module_for options[:script_type]}::Runner".constantize
64
- # build_class = "Awetestlib::Runner".constantize
65
- # #options = options.merge(:script_file => options[:script_file])
66
- # #if build_class.respond_to?(:runner_class)
67
- # # build_class.runner_class(options)
68
- # #else
69
- # build_class.new(options)
70
- # #end
71
- #end
72
-
73
- # TODO: Encapsulate in some kind of config
74
- ###################################
75
- def setup_global_test_vars(options)
76
- @my_failed_count = 0
77
- @my_passed_count = 0
78
- @my_error_references = Hash.new
79
- @my_error_hits = Hash.new
80
-
81
- @report_all_refs = options[:report_all_test_refs]
82
-
83
- if options[:environment]
84
- @myAppEnv = OpenStruct.new(
85
- :name => options[:environment]['name'],
86
- :url => options[:environment]['url'],
87
- :nodename => options[:environment]['nodename']
88
- )
89
- @runenv = options[:environment]['nodename'] || options[:environment]['name']
90
- @myURL = options[:environment]['url']
91
- else
92
- @runenv = options[:environment_name]
93
- end
94
-
95
- @targetBrowser = browser_to_use(options[:browser], options[:version])
96
- @targetVersion = @targetBrowser.version
97
- @browserAbbrev = @targetBrowser.abbrev
98
- @myRoot = options[:root_path] || Dir.pwd # NOTE: bug fix pmn 05dec2012
99
- @myName = File.basename(options[:script_file]).sub(/\.rb$/, '')
100
-
101
- if options[:output_to_log]
102
- log_name = "#{@myName}_#{Time.now.strftime("%Y%m%d%H%M%S")}.log"
103
- if options[:log_path_subdir]
104
- FileUtils.mkdir options[:log_path_subdir] unless File.directory? options[:log_path_subdir]
105
- log_path = options[:log_path_subdir]
106
- log_spec = File.join(log_path, log_name)
107
- else
108
- log_spec = log_name
109
- end
110
- @myLog = init_logger(log_spec, @myName)
111
- end
112
-
113
- if options[:xls_path]
114
- @xls_path = options[:xls_path]
115
- end
116
-
117
- #TODO need to find way to calculate these on the fly
118
- # window top border 30
119
- # IE toolbars 86
120
- @vertical_hack_ie = 117
121
- # FF toolbars 114
122
- @vertical_hack_ff = 144
123
- # window left border 4
124
- @horizontal_hack_ie = 5
125
- @horizontal_hack_ff = 4
126
- #
127
- # @x_tolerance = 12
128
- # @y_tolerance = 12
129
- require_gems
130
- end
131
-
132
- #def self.runner_class(options)
133
- # script_file = options[:script_file]
134
- # load script_file # force a load
135
- #
136
- # runner_module = self.module_for script_file
137
- # klass_name = "#{runner_module.to_s}::Runner"
138
- #
139
- # # Define a Runner class in the test script's module inheriting from AwetestLegacy::Runner
140
- # runner_module.module_eval do
141
- # eval <<-RUBY
142
- # class #{klass_name} < Awetestlib::Runner
143
- # def initialize(options)
144
- # #super(options)
145
- # setup_global_test_vars(options)
146
- # end
147
- # end
148
- # RUBY
149
- # end
150
- #
151
- # runner = runner_module::Runner.new(options)
152
- #
153
- # if options[:library]
154
- # lib_file = options[:library]
155
- # load lib_file
156
- # lib_module = self.module_for lib_file
157
- # runner.extend(lib_module)
158
- # end
159
- #
160
- # # Add in the methods defined in the script's module
161
- # runner.extend(runner_module)
162
- # runner
163
- #end
164
-
165
- def initialize(options)
166
-
167
- options.each_pair do |k, v|
168
- self.send("#{k}=", v)
169
- end
170
- script_file = options[:script_file]
171
- load script_file
172
- setup_global_test_vars(options)
173
-
174
- # load and extend with library module if it exists
175
- if options[:library]
176
- lib_file = options[:library]
177
- load lib_file # force a fresh load
178
- lib_module = module_for lib_file
179
- self.extend(lib_module)
180
- end
181
-
182
- # load and extend with script
183
- script_file = options[:script_file]
184
- load script_file # force a fresh load
185
- runner_module = module_for script_file
186
- self.extend(runner_module)
187
-
188
- end
189
-
190
- def browser_to_use(browser, browser_version = nil)
191
- platform = ''
192
- platform = 'Windows' if !!((RUBY_PLATFORM =~ /(win|w)(32|64)$/) || (RUBY_PLATFORM =~ /mswin|mingw/))
193
- platform = 'OSX' if RUBY_PLATFORM =~ /darwin/
194
-
195
- browser_abbrev =
196
- Awetestlib::BROWSER_ALTERNATES[platform][browser] ?
197
- Awetestlib::BROWSER_ALTERNATES[platform][browser] : browser
198
- if not browser_version
199
- case browser_abbrev
200
- when 'IE'
201
- browser_version = 8
202
- when 'FF'
203
- browser_version = 11
204
- when 'C', 'GC'
205
- browser_version = 10
206
- when 'S'
207
- browser_version = 10
208
- end
209
- end
210
- return OpenStruct.new(
211
- :name => (Awetestlib::BROWSER_MAP[browser_abbrev]),
212
- :abbrev => browser_abbrev,
213
- :version => browser_version
214
- )
215
- end
216
-
217
- def require_gems
218
-
219
- case @targetBrowser.abbrev
220
-
221
- when 'IE'
222
- if $watir_script
223
- require 'watir/ie'
224
- require 'watir'
225
- require 'watir/process'
226
- require 'watirloo'
227
- require 'patches/watir'
228
- Watir::IE.visible = true
229
- else
230
- require 'watir-webdriver'
231
- end
232
- when 'FF'
233
- require 'watir-webdriver'
234
- when 'S'
235
- require 'watir-webdriver'
236
-
237
- when 'C', 'GC'
238
- require 'watir-webdriver'
239
-
240
- # when 'CL'
241
- # require 'celerity'
242
- # require 'watir-webdriver'
243
-
244
- end
245
-
246
- if USING_WINDOWS
247
- require 'watir/win32ole'
248
- @ai = ::WIN32OLE.new('AutoItX3.Control')
249
- else
250
- # TODO: Need alternative for Mac?
251
- @ai = ''
252
- end
253
-
254
- if @xls_path
255
- require 'roo'
256
- end
257
-
258
- end
259
-
260
- def module_for(script_file)
261
- File.read(script_file).match(/^module\s+(\w+)/)[1].constantize
262
- end
263
-
264
- def before_run
265
- initiate_html_report
266
- start_run
267
- end
268
-
269
- def start
270
- before_run
271
- run
272
- rescue Exception => e
273
- failed_to_log(e.to_s)
274
- ensure
275
- after_run
276
- end
277
-
278
- def after_run
279
- finish_run
280
- @report_class.finish_report(@html_report_file)
281
- open_report_file
282
- @myLog.close if @myLog
283
- end
284
-
285
- def initiate_html_report
286
- @html_report_name = File.join(FileUtils.pwd, 'awetest_reports', @myName)
287
- @html_report_dir = File.dirname(@html_report_name)
288
- FileUtils.mkdir @html_report_dir unless File.directory? @html_report_dir
289
- @report_class = Awetestlib::HtmlReport.new(@myName)
290
- @html_report_file = @report_class.create_report(@html_report_name)
291
- end
292
-
293
- def open_report_file
294
- full_report_file = File.expand_path(@html_report_file)
295
- if USING_WINDOWS
296
- system("explorer file:///#{full_report_file}")
297
- elsif USING_OSX
298
- system("open #{full_report_file}")
299
- else
300
- puts "Can find report in #{full_report_file}"
301
- end
302
-
303
- end
304
-
305
- end
306
- end
307
- end
1
+ require 'awetestlib/regression/browser'
2
+ require 'awetestlib/regression/find'
3
+ require 'awetestlib/regression/user_input'
4
+ require 'awetestlib/regression/waits'
5
+ require 'awetestlib/regression/tables'
6
+ require 'awetestlib/regression/page_data'
7
+ require 'awetestlib/regression/drag_and_drop'
8
+ require 'awetestlib/regression/utilities'
9
+ require 'awetestlib/regression/legacy'
10
+ require 'awetestlib/logging'
11
+ require 'awetestlib/regression/validations'
12
+ require 'awetestlib/html_report'
13
+ #require 'rbconfig'
14
+ require 'ostruct'
15
+ require 'active_support'
16
+ require 'active_support/inflector'
17
+
18
+ module Awetestlib
19
+ module Regression
20
+ # Collects all the components needed to run the script and executes it.
21
+ class Runner < Awetestlib::Runner
22
+
23
+ # order matters here
24
+ include ActiveSupport::Inflector
25
+ include Awetestlib::Logging
26
+ include Awetestlib::Regression::Utilities
27
+ include Awetestlib::Regression::Browser
28
+ include Awetestlib::Regression::Find
29
+ include Awetestlib::Regression::UserInput
30
+ include Awetestlib::Regression::Waits
31
+ include Awetestlib::Regression::Tables
32
+ include Awetestlib::Regression::PageData
33
+ include Awetestlib::Regression::DragAndDrop
34
+ include Awetestlib::Regression::Validations
35
+ include Awetestlib::Regression::Legacy
36
+
37
+ ::DEBUG = 0
38
+ ::INFO = 1
39
+ ::WARN = 2
40
+ ::ERROR = 3
41
+ ::FATAL = 4
42
+ ::UNKNOWN = 5
43
+
44
+ ::TOP_LEVEL = 7
45
+ ::SECOND_LEVEL = ::TOP_LEVEL - 1
46
+
47
+ ::WAIT = 20
48
+ ::PASS = '-PASS'
49
+ ::FAIL = '-FAIL'
50
+
51
+ attr_accessor :browser, :browser_abbrev, :version, :env,
52
+ :library, :script_type, :script_file,
53
+ :log_properties, :log_queue, :log_class,
54
+ :notify_queue, :notify_class, :notify_id,
55
+ :screencap_path, :xls_path, :script_path, :user_token, :root_path,
56
+ :debug_on_fail,
57
+ :environment, :environment_name, :environment_url, :environment_nodename,
58
+ :cycle, :browser_sequence,
59
+ :output_to_log, :log_path_subdir, :report_all_test_refs,
60
+ :timeout
61
+
62
+ #def self.build(options)
63
+ # #build_class = "Awetestlib::#{script_module_for options[:script_type]}::Runner".constantize
64
+ # build_class = "Awetestlib::Runner".constantize
65
+ # #options = options.merge(:script_file => options[:script_file])
66
+ # #if build_class.respond_to?(:runner_class)
67
+ # # build_class.runner_class(options)
68
+ # #else
69
+ # build_class.new(options)
70
+ # #end
71
+ #end
72
+
73
+ # TODO: Encapsulate in some kind of config
74
+ ###################################
75
+ def setup_global_test_vars(options)
76
+ @my_failed_count = 0
77
+ @my_passed_count = 0
78
+ @my_error_references = Hash.new
79
+ @my_error_hits = Hash.new
80
+
81
+ @report_all_refs = options[:report_all_test_refs]
82
+
83
+ if options[:environment]
84
+ @myAppEnv = OpenStruct.new(
85
+ :name => options[:environment]['name'],
86
+ :url => options[:environment]['url'],
87
+ :nodename => options[:environment]['nodename']
88
+ )
89
+ @runenv = options[:environment]['nodename'] || options[:environment]['name']
90
+ @myURL = options[:environment]['url']
91
+ else
92
+ @runenv = options[:environment_name]
93
+ end
94
+
95
+ @targetBrowser = browser_to_use(options[:browser], options[:version])
96
+ @targetVersion = @targetBrowser.version
97
+ @browserAbbrev = @targetBrowser.abbrev
98
+ @myRoot = options[:root_path] || Dir.pwd # NOTE: bug fix pmn 05dec2012
99
+ @myName = File.basename(options[:script_file]).sub(/\.rb$/, '')
100
+
101
+ if options[:output_to_log]
102
+ log_name = "#{@myName}_#{Time.now.strftime("%Y%m%d%H%M%S")}.log"
103
+ if options[:log_path_subdir]
104
+ FileUtils.mkdir options[:log_path_subdir] unless File.directory? options[:log_path_subdir]
105
+ log_path = options[:log_path_subdir]
106
+ log_spec = File.join(log_path, log_name)
107
+ else
108
+ log_spec = log_name
109
+ end
110
+ @myLog = init_logger(log_spec, @myName)
111
+ end
112
+
113
+ if options[:xls_path]
114
+ @xls_path = options[:xls_path]
115
+ end
116
+
117
+ #TODO need to find way to calculate these on the fly
118
+ # window top border 30
119
+ # IE toolbars 86
120
+ @vertical_hack_ie = 117
121
+ # FF toolbars 114
122
+ @vertical_hack_ff = 144
123
+ # window left border 4
124
+ @horizontal_hack_ie = 5
125
+ @horizontal_hack_ff = 4
126
+ #
127
+ # @x_tolerance = 12
128
+ # @y_tolerance = 12
129
+ require_gems
130
+ end
131
+
132
+ #def self.runner_class(options)
133
+ # script_file = options[:script_file]
134
+ # load script_file # force a load
135
+ #
136
+ # runner_module = self.module_for script_file
137
+ # klass_name = "#{runner_module.to_s}::Runner"
138
+ #
139
+ # # Define a Runner class in the test script's module inheriting from AwetestLegacy::Runner
140
+ # runner_module.module_eval do
141
+ # eval <<-RUBY
142
+ # class #{klass_name} < Awetestlib::Runner
143
+ # def initialize(options)
144
+ # #super(options)
145
+ # setup_global_test_vars(options)
146
+ # end
147
+ # end
148
+ # RUBY
149
+ # end
150
+ #
151
+ # runner = runner_module::Runner.new(options)
152
+ #
153
+ # if options[:library]
154
+ # lib_file = options[:library]
155
+ # load lib_file
156
+ # lib_module = self.module_for lib_file
157
+ # runner.extend(lib_module)
158
+ # end
159
+ #
160
+ # # Add in the methods defined in the script's module
161
+ # runner.extend(runner_module)
162
+ # runner
163
+ #end
164
+
165
+ def initialize(options)
166
+
167
+ options.each_pair do |k, v|
168
+ self.send("#{k}=", v)
169
+ end
170
+ script_file = options[:script_file]
171
+ load script_file
172
+ setup_global_test_vars(options)
173
+
174
+ # load and extend with library module if it exists
175
+ if options[:library]
176
+ lib_file = options[:library]
177
+ load lib_file # force a fresh load
178
+ lib_module = module_for lib_file
179
+ self.extend(lib_module)
180
+ end
181
+
182
+ # load and extend with script
183
+ script_file = options[:script_file]
184
+ load script_file # force a fresh load
185
+ runner_module = module_for script_file
186
+ self.extend(runner_module)
187
+
188
+ end
189
+
190
+ def browser_to_use(browser, browser_version = nil)
191
+ platform = ''
192
+ platform = 'Windows' if !!((RUBY_PLATFORM =~ /(win|w)(32|64)$/) || (RUBY_PLATFORM =~ /mswin|mingw/))
193
+ platform = 'OSX' if RUBY_PLATFORM =~ /darwin/
194
+
195
+ browser_abbrev =
196
+ Awetestlib::BROWSER_ALTERNATES[platform][browser] ?
197
+ Awetestlib::BROWSER_ALTERNATES[platform][browser] : browser
198
+ if not browser_version
199
+ case browser_abbrev
200
+ when 'IE'
201
+ browser_version = 8
202
+ when 'FF'
203
+ browser_version = 11
204
+ when 'C', 'GC'
205
+ browser_version = 10
206
+ when 'S'
207
+ browser_version = 10
208
+ end
209
+ end
210
+ return OpenStruct.new(
211
+ :name => (Awetestlib::BROWSER_MAP[browser_abbrev]),
212
+ :abbrev => browser_abbrev,
213
+ :version => browser_version
214
+ )
215
+ end
216
+
217
+ def require_gems
218
+
219
+ require 'sys/uname'
220
+ include Sys
221
+
222
+ case @targetBrowser.abbrev
223
+
224
+ when 'IE'
225
+ if $watir_script
226
+ require 'watir/ie'
227
+ require 'watir'
228
+ require 'watir/process'
229
+ require 'watirloo'
230
+ require 'patches/watir'
231
+ Watir::IE.visible = true
232
+ else
233
+ require 'watir-webdriver'
234
+ end
235
+ when 'FF'
236
+ require 'watir-webdriver'
237
+ when 'S'
238
+ require 'watir-webdriver'
239
+
240
+ when 'C', 'GC'
241
+ require 'watir-webdriver'
242
+
243
+ # when 'CL'
244
+ # require 'celerity'
245
+ # require 'watir-webdriver'
246
+
247
+ end
248
+
249
+ if USING_WINDOWS
250
+ require 'watir/win32ole'
251
+ @ai = ::WIN32OLE.new('AutoItX3.Control')
252
+ else
253
+ # TODO: Need alternative for Mac?
254
+ @ai = ''
255
+ end
256
+
257
+ if @xls_path
258
+ require 'roo'
259
+ end
260
+
261
+ end
262
+
263
+ def module_for(script_file)
264
+ File.read(script_file).match(/^module\s+(\w+)/)[1].constantize
265
+ end
266
+
267
+ def before_run
268
+ initiate_html_report
269
+ start_run
270
+ end
271
+
272
+ def start
273
+ get_os
274
+ before_run
275
+ run
276
+ rescue Exception => e
277
+ failed_to_log(e.to_s)
278
+ ensure
279
+ after_run
280
+ end
281
+
282
+ def after_run
283
+ finish_run
284
+ @report_class.finish_report(@html_report_file)
285
+ open_report_file
286
+ @myLog.close if @myLog
287
+ end
288
+
289
+ def initiate_html_report
290
+ @html_report_name = File.join(FileUtils.pwd, 'awetest_reports', @myName)
291
+ @html_report_dir = File.dirname(@html_report_name)
292
+ FileUtils.mkdir @html_report_dir unless File.directory? @html_report_dir
293
+ @report_class = Awetestlib::HtmlReport.new(@myName)
294
+ @html_report_file = @report_class.create_report(@html_report_name)
295
+ end
296
+
297
+ def open_report_file
298
+ full_report_file = File.expand_path(@html_report_file)
299
+ if USING_WINDOWS
300
+ system("explorer file:///#{full_report_file}")
301
+ elsif USING_OSX
302
+ system("open #{full_report_file}")
303
+ else
304
+ puts "Can find report in #{full_report_file}"
305
+ end
306
+
307
+ end
308
+
309
+ end
310
+ end
311
+ end