awetestlib 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -7,37 +7,76 @@ After completing this guide you will be able to run tests locally from command l
7
7
 
8
8
  ------------
9
9
 
10
- ### Prerequisites
10
+ ## Prerequisites
11
11
 
12
12
  You need to have Ruby 1.8.7 installed. You can download Ruby 1.8.7
13
13
  [here](http://rubyinstaller.org/downloads/)
14
14
 
15
+ You can check your Ruby version using:
16
+
17
+ ruby -v
18
+
15
19
  Additionally, you will need to install DevKit to compile a few dependent gems. You can download DevKit
16
20
  [here](http://rubyinstaller.org/downloads/)
17
21
 
18
- ### Install
22
+ ## Install
23
+
24
+ In a terminal or command prompt, install the awetestlib gem
25
+
26
+ gem install awetestlib --no-ri --no-rdoc
27
+
28
+ Note: This could take up to 5 minutes for first time installs and you may need to use 'sudo'
29
+
30
+
31
+ ## Setup Regression Module
32
+
33
+ To setup the regression module, run the following command and verify the step
34
+
35
+ awetestlib regression_setup
36
+
37
+ ## Usage
19
38
 
20
- 1. In a terminal or command prompt, install the awetestlib gem
21
- - `gem install awetestlib --no-ri --no-rdoc`
39
+ Run the following command to see the different usages
22
40
 
41
+ awetestlib
23
42
 
24
- 2. To setup the regression module, run the following command and verify the step
25
- - `awetestlib regression_setup`
43
+ ## Setup Browsers
26
44
 
27
- ### Usage
45
+ ### Setup Safari (Mac OS X only)
28
46
 
29
- 1. Run the following command to see the different usages
30
- - `awetestlib`
47
+ To setup support for Safari browser, please follow the instructions at [SafariDriver](http://code.google.com/p/selenium/wiki/SafariDriver)
31
48
 
32
- 2. To setup the awetestlib gem with Netbeans or Rubymine, run either of the commands
33
- - `awetestlib rubymine_setup`
49
+ ### Setup Chrome
50
+ To setup support for Google Chrome browser, please download the latest Chromedriver version from [here](http://code.google.com/p/chromedriver/downloads/list)
34
51
 
35
- or
36
- - `awetestlib netbeans_setup`
52
+ Then move the executables in your PATH. To find your PATHs, type the command below in your terminal/command prompt
37
53
 
38
- You can now start your scripts within the IDE. Use the Run Configuration button.
54
+ For Mac OSX:
39
55
 
40
- For additional information on IDE setup, refer to the links below:
56
+ echo $PATH
57
+
58
+ For Windows:
59
+
60
+ PATH
61
+
62
+ ### Setup Internet Explorer
63
+ To setup support for Internet Explorer, please download the latest IEDriver version from [here](http://code.google.com/p/selenium/downloads/list)
64
+ and move the executable into your PATH.
65
+
66
+
67
+ ### Setup IDEs (Rubymine, Netbeans)
68
+
69
+ To setup the awetestlib gem with Rubymine use:
70
+
71
+ awetestlib rubymine_setup <ProjectName>
72
+
73
+ To setup awetestlib with Netbeans use:
74
+
75
+ awetestlib netbeans_setup <ProjectName>
76
+
77
+ You can now start your scripts within the IDE. Use the Run Configuration button.
78
+
79
+ For additional information on IDE setup, refer to the links below:
41
80
 
42
81
  - [Netbeans IDE setup](https://github.com/3qilabs/awetestlib/blob/develop/netbeans_setup.md)
43
82
 
@@ -58,12 +97,12 @@ The full list of parameters for the command line currently are:
58
97
  -x, --excel EXCEL_FILE Specify an excel file containing variables to be loaded
59
98
  -v, --version VERSION Specify a browser version
60
99
 
61
- To get started writing your own script, refer to the [Getting Started Scripting](https://github.com/3qilabs/awetestlib/wiki/Getting-Started---Scripting) wiki
100
+ To start writing your own script, refer to the [Scripting Guide/Wiki](https://github.com/3qilabs/awetestlib/wiki/Getting-Started---Scripting) wiki
62
101
 
63
102
  ### Cucumber Support
64
103
 
65
104
  One of the technologies that the Awetest framework supports is [Cucumber](http://cukes.info/). To get setup with cucumber, you can run the following command: `awetestlib cucumber_setup` which will create your typical cucumber folder structure.
66
105
 
67
-
106
+ Visit our [wiki](https://github.com/3qilabs/awetestlib/wiki/Predefined-Cucumber-Web-Steps) to see the list of predefined steps provided by awetestlib
68
107
 
69
108
 
@@ -1,14 +1,20 @@
1
1
  def awetestlib_cucumber_setup
2
- @cucumber_dir = File.join(FileUtils.pwd, "sample_cucumber")
3
- @source_dir = File.join(File.dirname(__FILE__), '..', 'setup_samples', 'sample_cucumber')
2
+ if ARGV[1].nil?
3
+ @proj_dir = "sample_cucumber"
4
+ else
5
+ @proj_dir = ARGV[1]
6
+ end
7
+
8
+ @cucumber_dir = File.join(FileUtils.pwd, @proj_dir)
9
+ @source_dir = File.join(File.dirname(__FILE__), '..', 'setup_samples', @proj_dir)
4
10
 
5
11
  if File.exists?(@cucumber_dir)
6
- puts "Sample Cucumber features directory already exists."
12
+ puts "Cucumber project directory already exists."
7
13
  exit 1
8
14
  end
9
15
 
10
16
  msg("Question") do
11
- puts "I'm about to create a sample cucumber feature in this directory"
17
+ puts "I'm about to create a cucumber project named #{@proj_dir} in this directory"
12
18
  puts "Please hit return to confirm that's what you want."
13
19
  puts "NOTE: You may need to run this command as an administrator."
14
20
  end
@@ -21,7 +21,7 @@ def print_usage
21
21
  awetestlib mobile_app_setup <project_name>
22
22
  setup a mobile app project
23
23
 
24
- awetestlib cucumber_setup
24
+ awetestlib cucumber_setup <project_name>
25
25
  setup cucumber regression and provide skeleton folder structure
26
26
 
27
27
  awetestlib <script_file> [parameters]
@@ -1050,9 +1050,183 @@ tags: system, http, fatal, error
1050
1050
  example: See click()
1051
1051
  related methods: rescue_me()
1052
1052
  =end
1053
- def validate(browser, fileName = '', lnbr = __LINE__, dbg = false) # need to get rid of validate call, issues if modal comes up after click
1054
- end
1055
-
1053
+ def validate(browser, fileName = '', lnbr = __LINE__, dbg = false)
1054
+ debug_to_log("#{__method__} begin") if dbg
1055
+ msg = ''
1056
+ myOK = true
1057
+ if not browser
1058
+ msg = "#{fileName}----browser is nil object. (#{lnbr})"
1059
+ myOK = false
1060
+ elsif not is_browser?(browser)
1061
+ msg = "#{fileName}----not a browser. (#{lnbr})"
1062
+ debug_to_log(browser.inspect)
1063
+ myOK = false
1064
+
1065
+ else
1066
+ if browser.respond_to?(:url)
1067
+ if not browser.url == @currentURL
1068
+ @currentURL = browser.url
1069
+ debug_to_log("Current URL: [#{@currentURL}]")
1070
+ # mark_testlevel( "Current URL: [#{@currentURL}]", 1 )
1071
+ end
1072
+ end
1073
+
1074
+ if @capture_js_errors
1075
+ if browser.respond_to?(:status)
1076
+ if browser.status.downcase =~ /errors? on page/ and
1077
+ not browser.status.downcase.include?('Waiting for')
1078
+ capture_js_error(browser)
1079
+ end
1080
+ end
1081
+ end
1082
+
1083
+ begin
1084
+ browser_text = browser.text.downcase
1085
+ rescue => e
1086
+ if not rescue_me(e, __method__, "browser.text.downcase", "#{browser.class}", browser)
1087
+ debug_to_log("browser.text.downcase in #{__method__} #{browser.class}")
1088
+ debug_to_log("#{get_callers}")
1089
+ raise e
1090
+ else
1091
+ return true
1092
+ end
1093
+ end
1094
+
1095
+ if browser_text
1096
+ if browser_text.match(/unrecognized error condition has occurred/i)
1097
+ msg = "#{fileName}----Unrecognized Exception occurred. (#{lnbr})"
1098
+ myOK = false
1099
+
1100
+ elsif browser_text.match(/cannot find server or dns error/i)
1101
+ msg = "#{fileName}----Cannot find server error or DNS error. (#{lnbr})"
1102
+ myOK = false
1103
+
1104
+ elsif browser_text.match(/the rpc server is unavailable/i)
1105
+ msg = "#{fileName}----RPC server unavailable. (#{lnbr})"
1106
+ myOK = false
1107
+
1108
+ elsif browser_text.match(/404 not found/i) or
1109
+ browser_text.match(/the page you were looking for does\s*n[o']t exist/i)
1110
+ msg = "#{fileName}----RFC 2068 HTTP/1.1: 404 URI Not Found. (#{lnbr})"
1111
+ myOK = false
1112
+
1113
+ elsif browser_text.match(/we're sorry, but something went wrong/i) or
1114
+ browser_text.match(/http status 500/i)
1115
+ msg = "#{fileName}----RFC 2068 HTTP/1.1: 500 Internal Server Error. (#{lnbr})"
1116
+ myOK = false
1117
+
1118
+ elsif browser_text.match(/internet explorer cannot display the webpage/i)
1119
+ msg = "#{fileName}----Probably RFC 2068 HTTP/1.1: 500 Internal Server Error. (#{lnbr})"
1120
+ myOK = false
1121
+
1122
+ elsif browser_text.match(/503.*service unavailable/i)
1123
+ msg = "#{fileName}----RFC 2068 HTTP/1.1: 503 Service Unavailable. (#{lnbr})"
1124
+ myOK = false
1125
+
1126
+ elsif browser_text.match(/java.lang.NullPointerException/i)
1127
+ msg = "#{fileName}----java.lang.NullPointerException. (#{lnbr})"
1128
+ myOK = false
1129
+
1130
+ elsif browser_text.match(/due to unscheduled maintenance/i)
1131
+ msg = "#{fileName}----Due to unscheduled maintenance. (#{lnbr})"
1132
+ myOK = false
1133
+
1134
+ elsif browser_text.match(/network\s+error\s*(.+)$/i)
1135
+ $1.chomp!
1136
+ msg = "#{fileName}----Network Error #{$1}. (#{lnbr})"
1137
+ myOK = false
1138
+
1139
+ elsif browser_text.match(/warning: page has expired/i)
1140
+ msg = "#{fileName}----Page using information from form has expired. Not automatically resubmitted. (#{lnbr})"
1141
+ myOK = false
1142
+
1143
+ elsif browser_text.match(/no backend server available/i)
1144
+ msg = "#{fileName}----Cannot Reach Server (#{lnbr})"
1145
+ myOK = false
1146
+
1147
+ elsif browser_text.match(/sign on\s+.+\s+unsuccessful/i)
1148
+ msg = "#{fileName}----Invalid Id or Password (#{lnbr})"
1149
+ myOK = false
1150
+
1151
+ elsif browser_text.match(/you are not authorized/i)
1152
+ msg = "#{fileName}----Not authorized to view this page. (#{lnbr})"
1153
+ myOK = false
1154
+
1155
+ elsif browser_text.match(/too many incorrect login attempts have been made/i)
1156
+ msg = "#{fileName}----Invalid Id or Password. Too many tries. (#{lnbr})"
1157
+ myOK = false
1158
+
1159
+ elsif browser_text.match(/system error\.\s+an error has occurred/i)
1160
+ msg = "#{fileName}----System Error. An error has occurred. Please try again or call the Help Line for assistance. (#{lnbr})"
1161
+ myOK = false
1162
+
1163
+ elsif browser_text.match(/Internal Server failure,\s+NSAPI plugin/i)
1164
+ msg = "#{fileName}----Internal Server failure, NSAPI plugin. (#{lnbr})"
1165
+ myOK = false
1166
+
1167
+ elsif browser_text.match(/Error Page/i)
1168
+ msg = "#{fileName}----Error Page. (#{lnbr})"
1169
+ myOK = false
1170
+
1171
+ elsif browser_text.match(/The website cannot display the page/i)
1172
+ msg = "#{fileName}----HTTP 500. (#{lnbr})"
1173
+ myOK = false
1174
+
1175
+ # elsif browser_text.match(/Insufficient Data/i)
1176
+ # msg = "#{fileName}----Insufficient Data. (#{lnbr})"
1177
+ # myOK = false
1178
+
1179
+ elsif browser_text.match(/The timeout period elapsed/i)
1180
+ msg = "#{fileName}----Time out period elapsed or server not responding. (#{lnbr})"
1181
+ myOK = false
1182
+
1183
+ elsif browser_text.match(/Unexpected\s+errors*\s+occur+ed\.\s+(?:-+)\s+(.+)/i)
1184
+ msg = "#{fileName}----Unexpected errors occurred. #{$2.slice(0, 120)} (#{lnbr})"
1185
+ if not browser_text.match(/close the window and try again/i)
1186
+ myOK = false
1187
+ else
1188
+ debug_to_log("#{msg}")
1189
+ end
1190
+
1191
+ elsif browser_text.match(/Server Error in (.+) Application\.\s+(?:-+)\s+(.+)/i)
1192
+ msg = "#{fileName}----Server Error in #{1} Application. #{$2.slice(0, 100)} (#{lnbr})"
1193
+ myOK = false
1194
+
1195
+ elsif browser_text.match(/Server Error in (.+) Application\./i)
1196
+ msg = "#{fileName}----Server Error in #{1} Application. '#{browser_text.slice(0, 250)}...' (#{lnbr})"
1197
+ myOK = false
1198
+
1199
+ elsif browser_text.match(/An error has occur+ed\. Please contact support/i)
1200
+ msg = "#{fileName}----An error has occurred. Please contact support (#{lnbr})"
1201
+ myOK = false
1202
+
1203
+ end
1204
+ else
1205
+ debug_to_log("browser.text returned nil")
1206
+ end
1207
+ end
1208
+
1209
+ if not myOK
1210
+ msg << " (#{browser.url})"
1211
+ puts msg
1212
+ debug_to_log(browser.inspect)
1213
+ debug_to_log(browser.text)
1214
+ fatal_to_log(msg, lnbr)
1215
+ raise(RuntimeError, msg, caller)
1216
+ else
1217
+ debug_to_log("#{__method__} returning OK") if dbg
1218
+ return myOK
1219
+ end
1220
+
1221
+ rescue
1222
+ errmsg = $!
1223
+ if errmsg.match(msg)
1224
+ errmsg = ''
1225
+ end
1226
+ bail_out(browser, lnbr, "#{msg} #{errmsg}")
1227
+ end
1228
+
1229
+ alias validate_browser validate
1056
1230
 
1057
1231
 
1058
1232
  end
data/lib/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Awetestlib
2
- VERSION = "0.1.12"
3
- VERSION_DATE = "2012-09-10"
2
+ VERSION = "0.1.13"
3
+ VERSION_DATE = "2012-09-18"
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awetestlib
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 12
10
- version: 0.1.12
9
+ - 13
10
+ version: 0.1.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Anthony Woo
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-09-10 00:00:00 Z
19
+ date: 2012-09-18 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: watir-webdriver