awetestlib 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/awetestlib_osx.gemspec +1 -0
- data/bin/awetestlib +3 -0
- data/bin/awetestlib-helpers.rb +3 -0
- data/bin/awetestlib-mobile-app-setup.rb +31 -0
- data/lib/awetestlib/regression/browser.rb +3 -177
- data/lib/version.rb +2 -2
- data/setup_samples/sample_mobile_app/TheElements.zip +0 -0
- data/setup_samples/sample_mobile_app/features/my_first.feature +14 -0
- data/setup_samples/sample_mobile_app/features/step_definitions/predefined_webview_steps.rb +80 -0
- data/setup_samples/sample_mobile_app/features/support/env.rb +3 -0
- metadata +24 -4
data/awetestlib_osx.gemspec
CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
s.add_dependency('json', '1.4.6') #for safari support
|
36
36
|
s.add_dependency('pry')
|
37
37
|
s.add_dependency('cucumber')
|
38
|
+
s.add_dependency('calabash-cucumber')
|
38
39
|
s.require_paths = ["lib"] #,"ext"]
|
39
40
|
s.files = `git ls-files`.split("\n")
|
40
41
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
data/bin/awetestlib
CHANGED
@@ -19,6 +19,9 @@ elsif cmd == "netbeans_setup"
|
|
19
19
|
elsif cmd == 'cucumber_setup'
|
20
20
|
require File.join(File.dirname(__FILE__),"awetestlib-cucumber-setup")
|
21
21
|
awetestlib_cucumber_setup
|
22
|
+
elsif cmd == 'mobile_app_setup'
|
23
|
+
require File.join(File.dirname(__FILE__),"awetestlib-mobile-app-setup")
|
24
|
+
awetestlib_mobile_app_setup
|
22
25
|
else
|
23
26
|
|
24
27
|
require 'optparse'
|
data/bin/awetestlib-helpers.rb
CHANGED
@@ -18,6 +18,9 @@ def print_usage
|
|
18
18
|
awetestlib netbeans_setup <project_name>
|
19
19
|
setup a netbeans project
|
20
20
|
|
21
|
+
awetestlib mobile_app_setup <project_name>
|
22
|
+
setup a mobile app project
|
23
|
+
|
21
24
|
awetestlib cucumber_setup
|
22
25
|
setup cucumber regression and provide skeleton folder structure
|
23
26
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
def awetestlib_mobile_app_setup
|
2
|
+
if ARGV[1].nil?
|
3
|
+
@proj_dir = "sample_mobile_app"
|
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', 'sample_mobile_app')
|
10
|
+
|
11
|
+
if File.exists?(@cucumber_dir)
|
12
|
+
puts "Mobile app project directory already exists."
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
|
16
|
+
msg("Question") do
|
17
|
+
puts "I'm about to create a mobile app project named #{ARGV[1]} in this directory" if ARGV[1]
|
18
|
+
puts "I'm about to create a mobile app project named sample_mobile_app in this directory" if ARGV[1].nil?
|
19
|
+
puts "Please hit return to confirm that's what you want."
|
20
|
+
puts "NOTE: You may need to run this command as an administrator."
|
21
|
+
end
|
22
|
+
exit 2 unless STDIN.gets.chomp == ''
|
23
|
+
|
24
|
+
FileUtils.cp_r(@source_dir, @cucumber_dir)
|
25
|
+
|
26
|
+
msg("Info") do
|
27
|
+
puts "Configuring files and settings..."
|
28
|
+
puts "A skeleton project has been created with a features and step definitions folder"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -1050,183 +1050,9 @@ 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)
|
1054
|
-
|
1055
|
-
|
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
|
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
|
+
|
1230
1056
|
|
1231
1057
|
|
1232
1058
|
end
|
data/lib/version.rb
CHANGED
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature:
|
2
|
+
I want to test cucumber
|
3
|
+
|
4
|
+
Scenario:
|
5
|
+
|
6
|
+
When I touch "Number"
|
7
|
+
Then I should see "Sorted by Atomic Number"
|
8
|
+
When I touch "Symbol"
|
9
|
+
Then I should see "Sorted by Atomic Symbol"
|
10
|
+
When I touch "State"
|
11
|
+
Then I should see "Grouped by State"
|
12
|
+
|
13
|
+
|
14
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
Then /^let me debug$/ do
|
2
|
+
binding.pry
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^I swipe "(.*?)" from the "(.*?)" label$/ do |dir, ele| #Then I swipe "up" from the "Locations" label
|
6
|
+
query("view:'UILabel' marked:'#{ele}' first", "swipeInDirection:", dir)
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^I use the keyboard to fill in the textfield marked "(.*?)" with "(.*?)"$/ do |text_field_mark, text_to_type|
|
10
|
+
query( "view marked:'#{text_field_mark}'", 'setText:', text_to_type )
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /^I touch the switch with index "(.*?)"$/ do |idx| #Then I touch the switch with index "1"
|
14
|
+
touch("view:'UISwitch' index:#{idx}")
|
15
|
+
end
|
16
|
+
|
17
|
+
And /I wait (\d+) seconds?/ do |seconds| #Then I wait 3 seconds
|
18
|
+
sleep(seconds.to_i)
|
19
|
+
end
|
20
|
+
|
21
|
+
Then /^I type "(.*?)" in the text field with id "(.*?)"$/ do |txt, id|
|
22
|
+
set_text("webView css:'input' id:'#{id}'", txt)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
Then /^I touch the WebView text "(.*?)"$/ do |txt|
|
27
|
+
sleep 1
|
28
|
+
wait_for(10){element_exists("webView css:'a' textContent:'#{txt}'")}
|
29
|
+
touch("webView css:'a' textContent:'#{txt}'")
|
30
|
+
end
|
31
|
+
|
32
|
+
Then /^I touch the WebView button "(.*?)"$/ do |txt|
|
33
|
+
sleep 1
|
34
|
+
wait_for(10){element_exists("webView css:'input' textContent:'#{txt}'")}
|
35
|
+
touch("webView css:'input' textContent:'#{txt}'")
|
36
|
+
end
|
37
|
+
|
38
|
+
Then /^I should see the WebView text "(.*?)"$/ do |txt|
|
39
|
+
sleep 1
|
40
|
+
if !query("webView textContent:'#{txt}'").empty?
|
41
|
+
true
|
42
|
+
else
|
43
|
+
fail("Did not find WebView text '#{txt}")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
Then /^I should not see the WebView text "(.*?)"$/ do |txt|
|
48
|
+
sleep 1
|
49
|
+
if query("webView textContent:'#{txt}'").empty?
|
50
|
+
true
|
51
|
+
else
|
52
|
+
fail("Found WebView text '#{txt}'")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
Then /^I touch the WebView button with value "(.*?)"$/ do |val|
|
57
|
+
wait_for(10){element_exists("webView css:'input' value:'#{val}'")}
|
58
|
+
touch("webView css:'input' value:'#{val}'")
|
59
|
+
end
|
60
|
+
|
61
|
+
When /^I touch the WebView link with index "(.*?)"$/ do |idx|
|
62
|
+
wait_for(10){element_exists("webView css:'a' index:#{idx}")}
|
63
|
+
touch("webView css:'a' index:#{idx}")
|
64
|
+
end
|
65
|
+
|
66
|
+
def send_command ( command )
|
67
|
+
%x{osascript<<APPLESCRIPT
|
68
|
+
tell application "System Events"
|
69
|
+
tell application "iPhone Simulator" to activate
|
70
|
+
keystroke "#{command}"
|
71
|
+
delay 1
|
72
|
+
key code 36
|
73
|
+
end tell
|
74
|
+
APPLESCRIPT}
|
75
|
+
end
|
76
|
+
|
77
|
+
When /^I send the command "([^\\"]*)"$/ do |cmd|
|
78
|
+
send_command(cmd)
|
79
|
+
end
|
80
|
+
|
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:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 12
|
10
|
+
version: 0.1.12
|
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-
|
19
|
+
date: 2012-09-10 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: watir-webdriver
|
@@ -226,6 +226,20 @@ dependencies:
|
|
226
226
|
version: "0"
|
227
227
|
type: :runtime
|
228
228
|
version_requirements: *id014
|
229
|
+
- !ruby/object:Gem::Dependency
|
230
|
+
name: calabash-cucumber
|
231
|
+
prerelease: false
|
232
|
+
requirement: &id015 !ruby/object:Gem::Requirement
|
233
|
+
none: false
|
234
|
+
requirements:
|
235
|
+
- - ">="
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
hash: 3
|
238
|
+
segments:
|
239
|
+
- 0
|
240
|
+
version: "0"
|
241
|
+
type: :runtime
|
242
|
+
version_requirements: *id015
|
229
243
|
description: Awetest DSL for automated testing of browser-based applications.
|
230
244
|
email: patrick@3qilabs.com
|
231
245
|
executables:
|
@@ -233,6 +247,7 @@ executables:
|
|
233
247
|
- awetestlib
|
234
248
|
- awetestlib-cucumber-setup.rb
|
235
249
|
- awetestlib-helpers.rb
|
250
|
+
- awetestlib-mobile-app-setup.rb
|
236
251
|
- awetestlib-netbeans-setup.rb
|
237
252
|
- awetestlib-regression-setup.rb
|
238
253
|
- awetestlib-rubymine-setup.rb
|
@@ -253,6 +268,7 @@ files:
|
|
253
268
|
- bin/awetestlib
|
254
269
|
- bin/awetestlib-cucumber-setup.rb
|
255
270
|
- bin/awetestlib-helpers.rb
|
271
|
+
- bin/awetestlib-mobile-app-setup.rb
|
256
272
|
- bin/awetestlib-netbeans-setup.rb
|
257
273
|
- bin/awetestlib-regression-setup.rb
|
258
274
|
- bin/awetestlib-rubymine-setup.rb
|
@@ -285,6 +301,10 @@ files:
|
|
285
301
|
- setup_samples/sample_cucumber/features/step_definitions/predefined_steps.rb
|
286
302
|
- setup_samples/sample_cucumber/features/support/env.rb
|
287
303
|
- setup_samples/sample_cucumber/features/yahoo_mail.feature
|
304
|
+
- setup_samples/sample_mobile_app/TheElements.zip
|
305
|
+
- setup_samples/sample_mobile_app/features/my_first.feature
|
306
|
+
- setup_samples/sample_mobile_app/features/step_definitions/predefined_webview_steps.rb
|
307
|
+
- setup_samples/sample_mobile_app/features/support/env.rb
|
288
308
|
- setup_samples/sample_netbeans/demo.rb
|
289
309
|
- setup_samples/sample_netbeans/nbproject/configs/Demo.properties
|
290
310
|
- setup_samples/sample_netbeans/nbproject/private/config.properties
|