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
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency('i18n')
24
24
  s.add_dependency('andand')
25
25
  s.add_dependency('watirloo')
26
- s.add_dependency('win32-process')
26
+ s.add_dependency('win32-process', '0.6.6')
27
27
  s.add_dependency('win32screenshot')
28
28
  s.add_dependency('spreadsheet', '0.6.8')
29
29
  s.add_dependency('google-spreadsheet-ruby', '0.1.6')
data/bin/awetestlib CHANGED
@@ -1,5 +1,6 @@
1
1
  $: << "./lib"
2
2
  require File.join(File.dirname(__FILE__),"awetestlib-helpers")
3
+ require 'fileutils'
3
4
 
4
5
  cmd = ARGV[0]
5
6
 
@@ -9,10 +10,17 @@ if cmd.nil?
9
10
  elsif cmd == "regression_setup"
10
11
  require File.join(File.dirname(__FILE__),"awetestlib-regression-setup")
11
12
  awetestlib_regression_setup
12
-
13
+ elsif cmd == "rubymine_setup"
14
+ require File.join(File.dirname(__FILE__),"awetestlib-rubymine-setup")
15
+ awetestlib_rubymine_setup
16
+ elsif cmd == "netbeans_setup"
17
+ require File.join(File.dirname(__FILE__),"awetestlib-netbeans-setup")
18
+ awetestlib_netbeans_setup
13
19
  else
20
+
14
21
  require 'optparse'
15
22
  require 'awetestlib'
23
+
16
24
  options = { }
17
25
  OptionParser.new do |opts|
18
26
  opts.banner = "Usage: awetestlib <script_file> [options]"
@@ -70,11 +78,10 @@ options[:environment] ||= {}
70
78
  options[:environment]["name"] = options[:environment_name]
71
79
  options[:environment]["url"] = options[:environment_url]
72
80
  options[:environment]["nodename"] = options[:environment_nodename]
73
- options[:script_type] = 'AwetestLegacy'
74
- options[:script_file] = ARGV[0]
81
+ check_script_type(options)
75
82
 
76
83
  IS_WIN_2008 = File.exists?("config/win2008.txt")
84
+ Awetestlib::Runner.new(options)
77
85
 
78
- Awetestlib::Runner.new(options).start
79
86
 
80
87
  end
@@ -7,6 +7,33 @@ end
7
7
 
8
8
  def print_usage
9
9
  puts <<EOF
10
- TODO: PUTS HELP INFO
10
+ Usage Options:
11
+
12
+ awetestlib regression_setup
13
+ setup awetest regression and registers autoitx3.dll
14
+
15
+ awetestlib rubymine_setup
16
+ setup a sample rubymine project
17
+
18
+ awetestlib netbeans_setup
19
+ setup a sample netbeans project
20
+
21
+ awetestlib cucumber_setup
22
+ setup cucumber regression and provides skeleton folder structure
23
+
24
+ awetestlib <script_file> [parameters]
25
+ run an awetest regression script
26
+
11
27
  EOF
28
+ end
29
+
30
+ def check_script_type(options)
31
+ script_options = ['Regression', 'Cucumber']
32
+ if script_options.include? ARGV[0]
33
+ options[:script_type] = ARGV[0]
34
+ options[:script_file] = ARGV[1]
35
+ else
36
+ options[:script_type] = 'Regression'
37
+ options[:script_file] = ARGV[0]
38
+ end
12
39
  end
@@ -0,0 +1,39 @@
1
+ def edit_config_file
2
+ @new_config_file = File.join(FileUtils.pwd,"sample_netbeans","nbproject","private","configs", "Demo.properties")
3
+ @demo_script = File.join(FileUtils.pwd,"sample_netbeans", "demo.rb")
4
+ workspace_text = File.read(@new_config_file)
5
+ new_workspace_text = workspace_text.gsub(/SAMPLE-SCRIPT/,@demo_script )
6
+ File.open(@new_config_file, "w") {|file| file.puts new_workspace_text}
7
+ end
8
+
9
+ def edit_private_file
10
+ @new_private_file = File.join(FileUtils.pwd,"sample_netbeans","nbproject","private", "private.properties")
11
+ @bin_dir = File.join(File.dirname(__FILE__))
12
+ workspace_text = File.read(@new_private_file)
13
+ new_workspace_text = workspace_text.gsub(/BIN-DIR/,@bin_dir )
14
+ File.open(@new_private_file, "w") {|file| file.puts new_workspace_text}
15
+ end
16
+
17
+ def awetestlib_netbeans_setup
18
+ @netbeans_dir = File.join(FileUtils.pwd, "sample_netbeans")
19
+ @source_dir = File.join(File.dirname(__FILE__), '..', 'setup_samples', 'sample_netbeans')
20
+
21
+ if File.exists?(@netbeans_dir)
22
+ puts "Sample Netbeans directory already exists."
23
+ exit 1
24
+ end
25
+
26
+ msg("Question") do
27
+ puts "I'm about to create a sample netbeans project in this directory"
28
+ puts "Please hit return to confirm that's what you want."
29
+ puts "NOTE: You may need to run this command as an administrator."
30
+ end
31
+ exit 2 unless STDIN.gets.chomp == ''
32
+ FileUtils.cp_r(@source_dir, @netbeans_dir)
33
+ edit_config_file
34
+ edit_private_file
35
+ msg("Info") do
36
+ puts "Configuring files and settings"
37
+ end
38
+
39
+ end
@@ -0,0 +1,33 @@
1
+
2
+ def edit_config_file
3
+ @new_config_file = File.join(FileUtils.pwd,"sample_rubymine",".idea","workspace.xml")
4
+ @demo_script = File.join(FileUtils.pwd,"sample_rubymine", "demo.rb")
5
+ @awetestlib_file = File.join(File.dirname(__FILE__), "awetestlib")
6
+ workspace_text = File.read(@new_config_file)
7
+ new_workspace_text = workspace_text.gsub(/SAMPLE-SCRIPT/,@demo_script )
8
+ new_workspace_text = new_workspace_text.gsub(/RUBY-SCRIPT/, @awetestlib_file)
9
+ File.open(@new_config_file, "w") {|file| file.puts new_workspace_text}
10
+ end
11
+
12
+ def awetestlib_rubymine_setup
13
+ @rubymine_dir = File.join(FileUtils.pwd, "sample_rubymine")
14
+ @source_dir = File.join(File.dirname(__FILE__), '..', 'setup_samples', 'sample_rubymine')
15
+
16
+ if File.exists?(@rubymine_dir)
17
+ puts "Sample Rubymine directory already exists."
18
+ exit 1
19
+ end
20
+
21
+ msg("Question") do
22
+ puts "I'm about to create a sample rubymine project in this directory"
23
+ puts "Please hit return to confirm that's what you want."
24
+ puts "NOTE: You may need to run this command as an administrator."
25
+ end
26
+ exit 2 unless STDIN.gets.chomp == ''
27
+ FileUtils.cp_r(@source_dir, @rubymine_dir)
28
+ edit_config_file
29
+ msg("Info") do
30
+ puts "Configuring files and settings"
31
+ end
32
+
33
+ end
data/images/logo.png ADDED
Binary file
@@ -0,0 +1,171 @@
1
+ module Awetestlib
2
+ class HtmlReport
3
+ # Initialize the report class
4
+ def initialize(report_name)
5
+ @reportname = report_name
6
+ @reportContent1 = ''
7
+ @reportContent2 = ''
8
+ end
9
+
10
+ # Create a report
11
+ def create_report(reportName)
12
+ # Get current time
13
+ t = Time.now
14
+ # Format the day
15
+ if(t.day.to_s.length == 1)
16
+ strDay = '0' + t.day.to_s
17
+ else
18
+ strDay = t.day.to_s
19
+ end
20
+
21
+ # Format the month
22
+ if(t.month.to_s.length == 1)
23
+ strMonth = '0' + t.month.to_s
24
+ else
25
+ strMonth = t.month.to_s
26
+ end
27
+
28
+ # Format the year
29
+ strYear = t.year.to_s
30
+
31
+ # Format the hour
32
+ if(t.hour.to_s.length == 1)
33
+ strHour = '0' + t.hour.to_s
34
+ else
35
+ strHour = t.hour.to_s
36
+ end
37
+
38
+ # Format the minutes
39
+ if(t.min.to_s.length == 1)
40
+ strMinutes = '0' + t.min.to_s
41
+ else
42
+ strMinutes = t.min.to_s
43
+ end
44
+
45
+ # Format the seconds
46
+ if(t.sec.to_s.length == 1)
47
+ strSeconds = '0' + t.sec.to_s
48
+ elsif (t.sec.to_s.length == 0)
49
+ strSeconds = '00'
50
+ else
51
+ strSeconds = t.sec.to_s
52
+ end
53
+
54
+ # Create the report name
55
+ strTime = '_' + strDay + strMonth + strYear + '_' + strHour + strMinutes + strSeconds + '.html'
56
+ strNiceTime = strDay + '-' + strMonth + '-' + strYear + ' @ ' + strHour + ':' + strMinutes + ':' + strSeconds
57
+ strTotalReport = reportName + strTime
58
+
59
+ # Create the HTML report
60
+ strFile = File.open(strTotalReport, 'w')
61
+
62
+ # Format the header of the HTML report
63
+ @reportContent1 = '<html>
64
+ <head>
65
+ <meta content=text/html; charset=ISO-8859-1 http-equiv=content-type>
66
+ <title>Awetestlib Test Run</title>
67
+ <style type=text/css>
68
+ .title { font-family: verdana; font-size: 30px; font-weight: bold; align: left; color: #000000;}
69
+ .bold_text { font-family: verdana; font-size: 12px; font-weight: bold;}
70
+ .bold_large_text { font-family: verdana; font-size: 13px; font-weight: bold;}
71
+ .normal_text { font-family: verdana; font-size: 12px; font-weight: normal;}
72
+ .small_text { font-family: verdana; font-size: 10px; font-weight: normal; }
73
+ .border { border: 1px solid #000000;}
74
+ .mark_testlevel_left { border-top: 1px solid #858585; border-left: 1px solid #858585;background-color:#E2F4FE;}
75
+ .mark_testlevel_right { border-top: 1px solid #858585; border-right: 1px solid #858585;background-color:#E2F4FE;}
76
+ .border_left { border-top: 1px solid #858585; border-left: 1px solid #858585; border-right: 1px solid #858585;}
77
+ .border_right { border-top: 1px solid #858585; border-right: 1px solid #858585;}
78
+ .result_ok { font-family: verdana; font-size: 12px; font-weight: bold; text-align: center; color: green;}
79
+ .result_nok { font-family: verdana; font-size: 12px; font-weight: bold; text-align: center; color: red;}
80
+ .overall_ok { font-family: verdana; font-size: 12px; font-weight: bold; text-align: left; color: green;}
81
+ .overall_nok { font-family: verdana; font-size: 12px; font-weight: bold; text-align: left; color: red;}
82
+ .bborder_left { border-top: 1px solid #858585; border-left: 1px solid #858585; border-bottom: 1px solid #858585; background-color:#858585;font-family: verdana; font-size: 12px; font-weight: bold; text-align: center; color: white;}
83
+ .bborder_right { border-right: 1px solid #858585; background-color:#858585;font-family: verdana; font-size: 12px; font-weight: bold; text-align: center; color: white;}
84
+ </style>
85
+ </head>
86
+ <body>
87
+ <br>
88
+ <center>
89
+ <table width=800 border=0 cellpadding=2 cellspacing=2>
90
+ <tbody>
91
+ <tr>
92
+ <td>
93
+ <table width=100% border=0 cellpadding=2 cellspacing=2>
94
+ <tbody>
95
+ <tr>
96
+ <td style=width: 150px;>&nbsp;</td>
97
+ <td align=left><img src="../images/logo.png"></img></td>
98
+ <td align=right><p class=title>Test Report</p></td>
99
+ </tr>
100
+ </tbody>
101
+ </table>
102
+ <br>
103
+ <hr width=100% class=border size=1px>
104
+ <center>
105
+ <table border=0 width=95% cellpadding=2 cellspacing=2>
106
+ <tbody>
107
+ <tr>
108
+ <td width=20%><p class=bold_text>Script</p></td>
109
+ <td width=5%><p class=bold_text>:</p></td>
110
+ <td width=75%><p class=normal_text>' + @reportname.capitalize + '</p></td>
111
+ </tr>
112
+ <tr>
113
+ <td width=20%><p class=bold_text>Test Execution</p></td>
114
+ <td width=5%><p class=bold_text>:</p></td>
115
+ <td width=75%><p class=normal_text>' + strNiceTime + '</p></td>
116
+ </tr>
117
+ <tr>'
118
+
119
+ @reportContent2 = '</tr>
120
+ </tbody>
121
+ </table>
122
+ </center>
123
+ <br>
124
+ <center>
125
+ <table width=95% cellpadding=2 cellspacing=0>
126
+ <tbody>
127
+ <tr>
128
+ <td class=bborder_left width=80%><p>Test Step</p></td>
129
+ <td class=bborder_left width=20%><p>Result</p></td>
130
+ </tr>'
131
+
132
+ # Close the report
133
+ strFile.close
134
+
135
+ return strTotalReport
136
+ end
137
+
138
+ def add_to_report(step, result)
139
+ # Format the body of the HTML report
140
+ if (result == 'PASSED')
141
+ @reportContent2 = @reportContent2 + '<tr><td class=border_left width=80%><p class=normal_text>' + step + '</p></td>'
142
+ @reportContent2 = @reportContent2 + '<td class=border_right width=20%><p class=result_ok>' + result + '</p></td>'
143
+ elsif (result == 'FAILED')
144
+ @reportContent2 = @reportContent2 + '<tr><td class=border_left width=80%><p class=normal_text>' + step + '</p></td>'
145
+ @reportContent2 = @reportContent2 + '<td class=border_right width=20%><p class=result_nok>' + result + '</p></td>'
146
+ else
147
+ @reportContent2 = @reportContent2 + '<tr><td class=mark_testlevel_left width=80%><p class=bold_large_text>' + step + '</p></td>'
148
+ @reportContent2 = @reportContent2 + '<td class=mark_testlevel_right width=20%><p class=result_nok>' + result + '</p></td>'
149
+ end
150
+
151
+ end
152
+
153
+ def finish_report(reportName)
154
+ # Open the HTML report
155
+ strFile = File.open(reportName, 'a')
156
+
157
+ @reportContent2 = @reportContent2 + '<tr>
158
+ <td class=bborder_left width=80%><p>&nbsp;</p></td>
159
+ <td class=bborder_left width=20%><p>&nbsp;</p></td>
160
+ </tr>
161
+ </table>'
162
+
163
+ strFile.puts(@reportContent1)
164
+
165
+ strFile.puts(@reportContent2)
166
+
167
+ # Close the report
168
+ strFile.close
169
+ end
170
+ end
171
+ end
@@ -1,4 +1,4 @@
1
- #require 'screencap'
1
+ module Awetestlib
2
2
  module Logging
3
3
 
4
4
  def self.included(mod)
@@ -13,43 +13,8 @@ module Logging
13
13
 
14
14
  t = Time.now.utc
15
15
  @last_t ||= t
16
-
17
- # if log_properties
18
- # log_args = {
19
- # :cycle => @cycle,
20
- # :browser_sequence => @browser_sequence,
21
- # :session_num => @session_num,
22
- # :sequence => @sequence,
23
- # :job_id => log_properties['job_id'],
24
- ## :project_version_id => log_properties['project_version_id'],
25
- # :test_run_id => log_properties['test_run_id'],
26
- # :script_id => log_properties['script_id'],
27
- # :caller => caller.split(":")[0] || 'unknown',
28
- # :caller_line => caller.split(":")[1].to_i,
29
- # :caller_method => caller.split(":")[2],
30
- # :severity => severity,
31
- # :message => message.gsub(/[\x80-\xff]/,"?"),
32
- # :detail_timestamp => t.to_f.to_s,
33
- # :duration => t.to_f-@last_t.to_f,
34
- # :created_at => t,
35
- ### :company_id => log_properties['company_id'],
36
- # :project_id => log_properties['project_id'],
37
- # :level => tag.andand.is_a?(Fixnum) ? tag : nil,
38
- # :pass => pass_code_for(tag),
39
- # :test_category_id => log_properties['test_category_id'],
40
- # :test_case_id => log_properties['test_case_id'],
41
- # :application_role_id => nil, # not implemented yet
42
- # :screen_path => nil
43
- # }
44
- # Resque::Job.create(log_queue.to_sym, log_class, log_args) if log_queue && log_class
45
- #
46
- # ::Screencap.capture(Shamisen::BROWSER_MAP[@browser],
47
- # log_properties['test_run_id'], @sequence, root_path) if @screencap_path
48
- #end
49
-
50
16
  @last_t = t
51
-
52
- dt = t.strftime("%Y%m%d %H%M%S")+' '+t.usec.to_s[0, 4]
17
+ dt = t.strftime("%H%M%S")
53
18
  mySev = translate_severity(severity)
54
19
  myCaller = get_caller(lnbr) || 'unknown'
55
20
 
@@ -60,7 +25,6 @@ module Logging
60
25
  tag = '-LVL' + tag.to_s
61
26
  end
62
27
  end
63
-
64
28
  myMsg << "[%-5s]:" % tag
65
29
  #myMsg << '[' + t.to_f.to_s + ']:'
66
30
  #myMsg << '[' + myCaller + ']:'
@@ -171,6 +135,7 @@ tags: report, log, test level
171
135
  strg << message
172
136
  strg << " [#{desc}]" if desc.length > 0
173
137
  strg << " \n#{get_debug_list}" if dbg or @debug_calls
138
+ @report_class.add_to_report(message, "&nbsp")
174
139
  log_message(INFO, strg, lvl, 1)
175
140
  rescue
176
141
  failed_to_log("#{__method__}: #{$!}")
@@ -220,6 +185,7 @@ tags: log, error, pass, reference, tag, report
220
185
  message << " \n#{get_debug_list}" if dbg or @debug_calls # and not @debug_calls_fail_only)
221
186
  @my_passed_count += 1 if @my_passed_count
222
187
  parse_error_references(message)
188
+ @report_class.add_to_report(message, "PASSED")
223
189
  log_message(INFO, "#{message}", PASS, lnbr)
224
190
  end
225
191
 
@@ -234,11 +200,11 @@ category: Logging
234
200
  tags: log, error, fail, reference, tag, report
235
201
  =end
236
202
  def failed_to_log(message, lnbr = __LINE__, dbg = false)
237
- message << " \n#{get_debug_list}" # if dbg or @debug_calls or @debug_calls_fail_only
203
+ message << " \n#{get_debug_list}" if dbg or @debug_calls or @debug_calls_fail_only
238
204
  @my_failed_count += 1 if @my_failed_count
239
205
  parse_error_references(message, true)
206
+ @report_class.add_to_report("#{message}" + " [#{get_caller(lnbr)}]","FAILED")
240
207
  log_message(WARN, "#{message}" + " (#{lnbr})]", FAIL, lnbr)
241
- #debugger if debug_on_fail
242
208
  end
243
209
 
244
210
  alias validate_failed_tolog failed_to_log
@@ -252,7 +218,7 @@ category: Logging
252
218
  tags: log, error, fail, reference, tag, fatal, report
253
219
  =end
254
220
  def fatal_to_log(message, lnbr = __LINE__, dbg = false)
255
- message << " \n#{get_debug_list}" # if dbg or (@debug_calls and not @debug_calls_fail_only)
221
+ message << " \n#{get_debug_list}" if dbg or (@debug_calls and not @debug_calls_fail_only)
256
222
  @my_failed_count += 1 if @my_failed_count
257
223
  parse_error_references(message, true)
258
224
  debug_to_report("#{__method__}:\n#{dump_caller(lnbr)}")
@@ -352,7 +318,7 @@ tags: error, fail, reference, tag
352
318
  @start_timestamp = Time.now unless ts
353
319
  utc_ts = @start_timestamp.getutc
354
320
  loc_tm = "#{@start_timestamp.strftime("%H:%M:%S")} #{@start_timestamp.zone}"
355
- mark_testlevel(">> Starting #{@myName.titleize} #{utc_ts} (#{loc_tm})", 9)
321
+ debug_to_log(">> Starting #{@myName.titleize}")
356
322
  end
357
323
 
358
324
  alias start_to_log start_run
@@ -373,7 +339,7 @@ tags: log, begin, error, reference, validation, pass, fail, tallies, tag
373
339
 
374
340
  utc_ts = timestamp.getutc
375
341
  loc_tm = "#{timestamp.strftime("%H:%M:%S")} #{timestamp.zone}"
376
- mark_testlevel(">> End #{@myName.titleize} #{utc_ts} (#{loc_tm})", 9)
342
+ mark_testlevel(">> End #{@myName.titleize}", 9)
377
343
 
378
344
  end
379
345
 
@@ -442,3 +408,4 @@ tags: error, fail, hits, reference, tag, tallies
442
408
  end
443
409
 
444
410
  end
411
+ end