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,307 +1,307 @@
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
+ 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