awetestlib 0.1.3-x86-mingw32 → 0.1.5-x86-mingw32

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