awetestlib 0.1.2 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. data/README.md +55 -0
  2. data/awetestlib.windows.gemspec +1 -1
  3. data/awetestlib_osx.gemspec +1 -0
  4. data/bin/AutoItX3.dll +0 -0
  5. data/bin/awetestlib +23 -3
  6. data/bin/awetestlib-helpers.rb +39 -0
  7. data/bin/awetestlib-netbeans-setup.rb +39 -0
  8. data/bin/awetestlib-regression-setup.rb +16 -0
  9. data/bin/awetestlib-rubymine-setup.rb +33 -0
  10. data/images/logo.png +0 -0
  11. data/lib/awetestlib.rb +4 -4
  12. data/lib/awetestlib/html_report.rb +171 -0
  13. data/lib/{regression → awetestlib}/logging.rb +13 -46
  14. data/lib/awetestlib/regression/browser.rb +1233 -0
  15. data/lib/awetestlib/regression/drag_and_drop.rb +379 -0
  16. data/lib/awetestlib/regression/find.rb +431 -0
  17. data/lib/awetestlib/regression/legacy.rb +45 -0
  18. data/lib/awetestlib/regression/page_data.rb +190 -0
  19. data/lib/awetestlib/regression/runner.rb +307 -0
  20. data/lib/awetestlib/regression/tables.rb +491 -0
  21. data/lib/awetestlib/regression/user_input.rb +1256 -0
  22. data/lib/awetestlib/regression/utilities.rb +895 -0
  23. data/lib/awetestlib/regression/validations.rb +1184 -0
  24. data/lib/awetestlib/regression/waits.rb +391 -0
  25. data/lib/awetestlib/runner.rb +16 -0
  26. data/lib/version.rb +2 -2
  27. data/setup_samples/sample_netbeans/demo.rb +86 -0
  28. data/setup_samples/sample_netbeans/nbproject/configs/Demo.properties +2 -0
  29. data/setup_samples/sample_netbeans/nbproject/private/config.properties +1 -0
  30. data/setup_samples/sample_netbeans/nbproject/private/configs/Demo.properties +1 -0
  31. data/setup_samples/sample_netbeans/nbproject/private/private.properties +2 -0
  32. data/setup_samples/sample_netbeans/nbproject/project.properties +5 -0
  33. data/setup_samples/sample_netbeans/nbproject/project.xml +13 -0
  34. data/setup_samples/sample_rubymine/.idea/.name +1 -0
  35. data/setup_samples/sample_rubymine/.idea/encodings.xml +5 -0
  36. data/setup_samples/sample_rubymine/.idea/misc.xml +5 -0
  37. data/setup_samples/sample_rubymine/.idea/modules.xml +9 -0
  38. data/setup_samples/sample_rubymine/.idea/sample_rubymine.iml +9 -0
  39. data/setup_samples/sample_rubymine/.idea/scopes/scope_settings.xml +5 -0
  40. data/setup_samples/sample_rubymine/.idea/vcs.xml +7 -0
  41. data/setup_samples/sample_rubymine/.idea/workspace.xml +213 -0
  42. data/setup_samples/sample_rubymine/demo.rb +86 -0
  43. metadata +64 -17
  44. data/lib/regression/browser.rb +0 -1259
  45. data/lib/regression/drag_and_drop.rb +0 -374
  46. data/lib/regression/find.rb +0 -426
  47. data/lib/regression/legacy.rb +0 -40
  48. data/lib/regression/page_data.rb +0 -185
  49. data/lib/regression/runner.rb +0 -278
  50. data/lib/regression/tables.rb +0 -486
  51. data/lib/regression/user_input.rb +0 -1255
  52. data/lib/regression/utilities.rb +0 -891
  53. data/lib/regression/validations.rb +0 -1179
  54. data/lib/regression/waits.rb +0 -387
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ Awetestlib
2
+ ==========
3
+
4
+ Run automated regression and mobile tests
5
+
6
+ After completing this guide you will be able to run tests locally from command line or from an IDE
7
+
8
+ ------------
9
+
10
+ ### Prerequisites
11
+
12
+ You need to have Ruby 1.8.7 installed. You can download Ruby 1.8.7
13
+ [here](http://http://rubyinstaller.org/downloads/)
14
+
15
+ Additionally, you will need to install DevKit to compile a few dependent gems. You can download DevKit
16
+ [here](http://http://rubyinstaller.org/downloads/)
17
+
18
+ ### Install
19
+
20
+ 1. In a terminal or command prompt, install the awetestlib gem
21
+ - `gem install awetestlib --no-ri --no-rdoc`
22
+
23
+
24
+ 2. To setup the regression module, run the following command and verify the step
25
+ - `awetestlib regression_setup`
26
+
27
+ ### Usage
28
+
29
+ 1. Run the following command to see the different usages
30
+ - `awetestlib`
31
+
32
+ 2. To setup the awetestlib gem with Netbeans or Rubymine, run either of the commands
33
+ - `awetestlib rubymine_setup`
34
+
35
+ or
36
+ - `awetestlib netbeans_setup`
37
+
38
+ You can now start your scripts within the IDE. Use the Run Configuration button.
39
+
40
+ 3. If you prefer to run your tests from command line, you can use the following command
41
+ - `awetestlib <script_file> [parameters]`
42
+
43
+ For example: To run a script named demo.rb in Firefox, your command will look like.
44
+ - `awetestlib demo.rb -b FF`
45
+
46
+ The full list of parameters for the command line currently are:
47
+
48
+ Usage: awetestlib <script_file> [parameters] [options]
49
+ -b, --browser BROWSER Specify a browser (IE, FF, S, C)
50
+ -l, --library LIBRARY Specify a library to be loaded
51
+ -r, --root_path ROOT_PATH Specify the root path
52
+ -x, --excel EXCEL_FILE Specify an excel file containing variables to be loaded
53
+ -v, --version VERSION Specify a browser version
54
+
55
+
@@ -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')
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
32
32
  s.add_dependency('nokogiri')
33
33
  s.add_dependency('i18n')
34
34
  s.add_dependency('rb-appscript')
35
+ s.add_dependency('json', '1.4.6') #for safari support
35
36
 
36
37
  s.require_paths = ["lib"] #,"ext"]
37
38
  s.files = `git ls-files`.split("\n")
data/bin/AutoItX3.dll ADDED
Binary file
data/bin/awetestlib CHANGED
@@ -1,4 +1,23 @@
1
1
  $: << "./lib"
2
+ require File.join(File.dirname(__FILE__),"awetestlib-helpers")
3
+ require 'fileutils'
4
+
5
+ cmd = ARGV[0]
6
+
7
+ if cmd.nil?
8
+ print_usage
9
+
10
+ elsif cmd == "regression_setup"
11
+ require File.join(File.dirname(__FILE__),"awetestlib-regression-setup")
12
+ awetestlib_regression_setup
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
19
+ else
20
+
2
21
  require 'optparse'
3
22
  require 'awetestlib'
4
23
 
@@ -59,9 +78,10 @@ options[:environment] ||= {}
59
78
  options[:environment]["name"] = options[:environment_name]
60
79
  options[:environment]["url"] = options[:environment_url]
61
80
  options[:environment]["nodename"] = options[:environment_nodename]
62
- options[:script_type] = 'AwetestLegacy'
63
- options[:script_file] = ARGV[0]
81
+ check_script_type(options)
64
82
 
65
83
  IS_WIN_2008 = File.exists?("config/win2008.txt")
84
+ Awetestlib::Runner.new(options)
85
+
66
86
 
67
- Awetestlib::Runner.new(options).start
87
+ end
@@ -0,0 +1,39 @@
1
+ def msg(title, &block)
2
+ puts "\n" + "-"*10 + title + "-"*10
3
+ block.call
4
+ puts "-"*10 + "-------" + "-"*10 + "\n"
5
+ end
6
+
7
+
8
+ def print_usage
9
+ puts <<EOF
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
+
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
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,16 @@
1
+ def awetestlib_regression_setup
2
+ msg("Question") do
3
+ puts "I'm about to setup awetest regression support and register the AutoIt.dll"
4
+ puts "Please hit return to confirm that's what you want."
5
+ puts "NOTE: You may need to run this command as an administrator."
6
+ end
7
+ exit 2 unless STDIN.gets.chomp == ''
8
+
9
+ autoit_file = File.join(File.dirname(__FILE__),"AutoItX3.dll")
10
+ system("regsvr32 #{autoit_file}")
11
+
12
+ msg("Info") do
13
+ puts "Configuring files and settings"
14
+ end
15
+
16
+ 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
data/lib/awetestlib.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'yaml'
1
+ #require 'yaml' #Couldn't find use anywhere
2
2
  require 'active_support/core_ext/hash'
3
3
 
4
4
  module Awetestlib
@@ -25,15 +25,15 @@ module Awetestlib
25
25
  #require 'active_support/inflector'
26
26
  #require 'active_support/core_ext/object'
27
27
  #require 'active_support/core_ext/hash'
28
-
28
+ require 'awetestlib/runner'
29
29
  require 'andand'
30
- require 'regression/runner'
30
+ require 'awetestlib/regression/runner'
31
31
 
32
32
 
33
33
  if USING_OSX
34
34
  require 'appscript'
35
35
  end
36
36
 
37
- require 'roo'
37
+ #require 'roo' #moved to awetestlib runner
38
38
 
39
39
  end
@@ -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