awetestlib 0.1.29pre4-x86-mingw32 → 0.1.29-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +123 -123
- data/bin/awetestlib-android-setup.rb +28 -28
- data/bin/awetestlib-cucumber-setup.rb +30 -30
- data/bin/awetestlib-driver-setup.rb +22 -22
- data/bin/awetestlib-helpers.rb +42 -42
- data/bin/awetestlib-mobile-app-setup.rb +32 -32
- data/bin/awetestlib-netbeans-setup.rb +60 -60
- data/bin/awetestlib-regression-setup.rb +30 -30
- data/bin/awetestlib-rubymine-setup.rb +45 -45
- data/lib/awetestlib/logging.rb +366 -366
- data/lib/awetestlib/regression/browser.rb +1378 -1385
- data/lib/awetestlib/regression/drag_and_drop.rb +3 -4
- data/lib/awetestlib/regression/runner.rb +2 -3
- data/lib/awetestlib/regression/tables.rb +9 -17
- data/lib/awetestlib/regression/user_input.rb +1 -1
- data/lib/awetestlib/regression/utilities.rb +24 -82
- data/lib/awetestlib/regression/validations.rb +1075 -1094
- data/lib/version.rb +2 -2
- data/netbeans_setup.md +6 -6
- data/rubymine_setup.md +5 -5
- data/setup_samples/sample_cucumber/features/step_definitions/predefined_steps.rb +354 -354
- metadata +8 -26
- data/images/netbeans1.jpg +0 -0
- data/images/netbeans2.jpg +0 -0
- data/images/netbeans3.jpg +0 -0
- data/images/netbeans4.jpg +0 -0
- data/images/netbeans5.jpg +0 -0
- data/images/rubymine1.jpg +0 -0
- data/images/rubymine2.jpg +0 -0
- data/images/rubymine3.jpg +0 -0
- data/images/rubymine4.jpg +0 -0
- data/images/scripting1.png +0 -0
- data/images/scripting2.png +0 -0
- data/images/scripting3.png +0 -0
- data/images/scripting4.png +0 -0
- data/test/demo_wwd.rb +0 -7
@@ -1,354 +1,354 @@
|
|
1
|
-
require 'pry'
|
2
|
-
|
3
|
-
def awetestlib?
|
4
|
-
not Awetestlib::Runner.nil?
|
5
|
-
rescue
|
6
|
-
return false
|
7
|
-
end
|
8
|
-
|
9
|
-
Given /^I run with Watir$/ do
|
10
|
-
require 'watir'
|
11
|
-
require 'win32ole'
|
12
|
-
$ai = ::WIN32OLE.new('AutoItX3.Control')
|
13
|
-
$first_index = 1
|
14
|
-
$timestamp = Time.now.strftime("%Y%m%d%H%M%S")
|
15
|
-
$watir_script = true
|
16
|
-
Watir::IE.close_all
|
17
|
-
Watir::IE.visible = true
|
18
|
-
end
|
19
|
-
|
20
|
-
Given /^I run with Classic Watir$/ do
|
21
|
-
step "I run with Watir$"
|
22
|
-
end
|
23
|
-
|
24
|
-
Given /^I run with Watir-webdriver$/i do
|
25
|
-
require 'watir-webdriver'
|
26
|
-
$first_index = 0
|
27
|
-
$timestamp = Time.now.strftime("%Y%m%d%H%M%S")
|
28
|
-
$watir_script = false
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
When /^I open a new browser$/i do
|
33
|
-
if @params
|
34
|
-
puts "@params: #{@params}"
|
35
|
-
case @params["browser"]
|
36
|
-
when "FF"
|
37
|
-
step "I open Firefox"
|
38
|
-
when "IE"
|
39
|
-
step "I open Internet Explorer"
|
40
|
-
when "C", "GC"
|
41
|
-
step "I open Chrome"
|
42
|
-
end
|
43
|
-
else
|
44
|
-
step "I open Firefox"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
Given /^I open a F?f?irefox B?b?rowser$/i do
|
49
|
-
step "I open Firefox"
|
50
|
-
end
|
51
|
-
|
52
|
-
Given /^I open Firefox$/ do
|
53
|
-
step "I run with Watir-webdriver"
|
54
|
-
@browser = Watir::Browser.new :firefox
|
55
|
-
end
|
56
|
-
|
57
|
-
Given /^I open a C?c?hrome B?b?rowser$/i do
|
58
|
-
step "I open Chrome"
|
59
|
-
end
|
60
|
-
|
61
|
-
Given /^I open Chrome$/ do
|
62
|
-
step "I run with Watir-webdriver"
|
63
|
-
@browser = Watir::Browser.new :chrome
|
64
|
-
end
|
65
|
-
|
66
|
-
When /^I open an IE B?b?rowser$/i do
|
67
|
-
step "I open Internet Explorer"
|
68
|
-
end
|
69
|
-
|
70
|
-
Given /^I open an I?i?nternet E?e?xplorer B?b?rowser$/i do
|
71
|
-
step "I open Internet Explorer"
|
72
|
-
end
|
73
|
-
|
74
|
-
Given /^I open Internet Explorer$/i do
|
75
|
-
if $watir_script
|
76
|
-
step "I run with Watir"
|
77
|
-
@browser = Watir::IE.new
|
78
|
-
@browser.speed = :fast
|
79
|
-
else
|
80
|
-
step "I run with Watir-webdriver"
|
81
|
-
client = Selenium::WebDriver::Remote::Http::Default.new
|
82
|
-
client.timeout = 300 # seconds – default is 60
|
83
|
-
@browser = Watir::Browser.new :ie, :http_client => client
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
Then /^I navigate to the environment url$/ do
|
88
|
-
if @params and @params['environment'] and @params['environment']['url']
|
89
|
-
url = @params['environment']['url']
|
90
|
-
elsif @login and @login['url']
|
91
|
-
url = @login['url']
|
92
|
-
elsif @role and @login[@role] and @login[@role]['url']
|
93
|
-
url = @login[@role]['url']
|
94
|
-
end
|
95
|
-
@browser.goto url
|
96
|
-
end
|
97
|
-
|
98
|
-
Then /^I go to the url "(.*?)"$/ do |url|
|
99
|
-
@browser.goto url
|
100
|
-
end
|
101
|
-
|
102
|
-
Then /^I go to the (URL|url)$/ do |dummy|
|
103
|
-
step "I navigate to the environment url"
|
104
|
-
end
|
105
|
-
|
106
|
-
Then /^I click "(.*?)"$/ do |element_text|
|
107
|
-
step "I click the element with \"text\" \"#{element_text}\""
|
108
|
-
end
|
109
|
-
|
110
|
-
Then /^I click the button "(.*?)"$/ do |element_text|
|
111
|
-
step "I click the button with \"text\" \"#{element_text}\""
|
112
|
-
end
|
113
|
-
|
114
|
-
Then /^I click the "?(.*?)"? with "(.*?)" "(.*?)"$/ do |element, how, what|
|
115
|
-
step "I wait until #{element} with #{how} \"#{what}\" is ready"
|
116
|
-
#what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
117
|
-
case element
|
118
|
-
when 'link'
|
119
|
-
target = @browser.link(how.to_sym, what)
|
120
|
-
when 'button'
|
121
|
-
target = @browser.button(how.to_sym, what)
|
122
|
-
else
|
123
|
-
target = @browser.element(how.to_sym, what)
|
124
|
-
end
|
125
|
-
if target.respond_to?("click")
|
126
|
-
if $watir_script
|
127
|
-
target.click
|
128
|
-
else
|
129
|
-
target.fire_event('onclick')
|
130
|
-
end
|
131
|
-
else
|
132
|
-
fail("#{element} with #{how} '#{what}' does not respond to 'click'")
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
And /^I enter "(.*?)" in text field with "?(.*?)"? "(.*?)"$/ do |value, how, what|
|
137
|
-
what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
138
|
-
#step "I wait until text field with #{how} \"#{what}\" is ready"
|
139
|
-
@browser.text_field(how.to_sym, /#{what}/).set(value)
|
140
|
-
end
|
141
|
-
|
142
|
-
And /^I enter the value for "(.*?)" in text field with "?(.*?)"? "(.*?)"$/ do |index, how, what|
|
143
|
-
if index =~ /zipcode/
|
144
|
-
value = @var[index].to_i.to_s
|
145
|
-
else
|
146
|
-
value = @var[index]
|
147
|
-
end
|
148
|
-
step "I enter \"#{value}\" in text field with #{how} \"#{what}\""
|
149
|
-
end
|
150
|
-
|
151
|
-
And /^I select the value "(.*?)" in select list with "?(.*?)"? "(.*?)"$/ do |value, how, what|
|
152
|
-
#what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
153
|
-
@browser.select_list(how.to_sym, what).select_value(/#{value}/)
|
154
|
-
end
|
155
|
-
|
156
|
-
And /^I select the option "(.*?)" in select list with "?(.*?)"? "(.*?)"$/ do |option, how, what|
|
157
|
-
#what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
158
|
-
@browser.select_list(how.to_sym, what).select(/#{option}/)
|
159
|
-
end
|
160
|
-
|
161
|
-
And /^I select the value for "(.*?)" in select list with "?(.*?)"? "(.*?)"$/ do |index, how, what|
|
162
|
-
value = @var[index]
|
163
|
-
step "I select the value \"#{value}\" in select list with #{how} \"#{what}\""
|
164
|
-
end
|
165
|
-
|
166
|
-
Then /^I check that the "?(.*?)"? with "?(.*?)"? "(.*?)" contains "(.*?)"$/ do |element, how, what, target|
|
167
|
-
#what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
168
|
-
step "I wait until #{element} with #{how} \"#{what}\" is ready"
|
169
|
-
unless @browser.element(how.to_sym, what).text.include?(target)
|
170
|
-
fail ("#{element} with #{how} '#{what}' does not contain '#{target}'")
|
171
|
-
end
|
172
|
-
|
173
|
-
end
|
174
|
-
|
175
|
-
Then /^I check that the text field with "?(.*?)"? "(.*?)" contains the value for "(.*?)"$/ do |how, what, index|
|
176
|
-
if index =~ /zipcode/
|
177
|
-
value = @var[index].to_i.to_s
|
178
|
-
else
|
179
|
-
value = @var[index]
|
180
|
-
end
|
181
|
-
#what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
182
|
-
unless @browser.text_field(how.to_sym, what).value.include?(value)
|
183
|
-
fail("The text field with #{how} '#{what}' does not contain the value for '${index}' ('#{value}'")
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
Then /^I should see "(.*?)"$/ do |text|
|
188
|
-
step "I wait 1 second"
|
189
|
-
unless @browser.text.include? text
|
190
|
-
fail("Did not find text #{text}")
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
Then /^I should not see "(.*?)"$/ do |text|
|
195
|
-
if @browser.text.include? text
|
196
|
-
fail("Found text #{text}")
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
Then /^I fill in "(.*?)" with "(.*?)"$/ do |field, value| # assumes a label element and its associated element has id
|
201
|
-
associated_label = @browser.label(:text, field).attribute_value("for")
|
202
|
-
#associated_label = @browser.element(:xpath, '//label[contains(text(),"#{arg1}")]').attribute_value("for"))
|
203
|
-
@browser.text_field(:id, associated_label).set value
|
204
|
-
end
|
205
|
-
|
206
|
-
Then /^let me debug$|^pry$|^execute binding.pry$/ do
|
207
|
-
binding.pry
|
208
|
-
end
|
209
|
-
|
210
|
-
When /^I wait (\d+) seconds?$/ do |seconds|
|
211
|
-
sleep seconds.to_i
|
212
|
-
end
|
213
|
-
|
214
|
-
When /^I wait until "?(.*?)"? with "?(.*?)"? "(.*?)" is ready$/ do |element, how, what|
|
215
|
-
#what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
216
|
-
ok = false
|
217
|
-
if $watir_script
|
218
|
-
if Watir::Wait.until {@browser.element(how, what).exists?}
|
219
|
-
if Watir::Wait.until {@browser.element(how, what).visible?}
|
220
|
-
if Watir::Wait.until {@browser.element(how, what).enabled?}
|
221
|
-
ok = true
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
else
|
226
|
-
case element
|
227
|
-
when 'button'
|
228
|
-
if @browser.button(how.to_sym, what).wait_until_present
|
229
|
-
ok = true
|
230
|
-
end
|
231
|
-
when 'text field'
|
232
|
-
sleep 2
|
233
|
-
#if @browser.text_field(how.to_sym, what).wait_until_present
|
234
|
-
ok = true
|
235
|
-
#end
|
236
|
-
else
|
237
|
-
if @browser.element(how.to_sym, what).wait_until_present
|
238
|
-
ok = true
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
unless ok
|
243
|
-
fail("#{element} with #{how} '#{what}' is not ready")
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
And /^I click "(.*?)" in the browser alert$/ do |button|
|
248
|
-
if $watir_script
|
249
|
-
$ai.WinWait("Message from webpage")
|
250
|
-
sleep(1)
|
251
|
-
$ai.ControlClick("Message from webpage", "", button)
|
252
|
-
else
|
253
|
-
@browser.alert.wait_until_present
|
254
|
-
case button
|
255
|
-
when /ok/i, /yes/i, /submit/i
|
256
|
-
@browser.alert.ok
|
257
|
-
when /cancel/i, /close/i
|
258
|
-
@browser.alert.close
|
259
|
-
else
|
260
|
-
fail("'#{button} for alert not recognized.")
|
261
|
-
end
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
And /^I close the browser$/ do
|
266
|
-
@browser.close
|
267
|
-
end
|
268
|
-
|
269
|
-
Given /^I load data spreadsheet "(.*?)" for "(.*?)"$/ do |file, feature|
|
270
|
-
require 'roo'
|
271
|
-
@workbook = Excel.new(file)
|
272
|
-
@feature_name = feature #File.basename(feature, ".feature")
|
273
|
-
step "I load @login from spreadsheet"
|
274
|
-
step "I load @var from spreadsheet"
|
275
|
-
end
|
276
|
-
|
277
|
-
Then /^I load @login from spreadsheet$/ do
|
278
|
-
@login = Hash.new
|
279
|
-
@workbook.default_sheet = @workbook.sheets[0]
|
280
|
-
|
281
|
-
script_col = 0
|
282
|
-
role_col = 0
|
283
|
-
userid_col = 0
|
284
|
-
password_col = 0
|
285
|
-
url_col = 0
|
286
|
-
name_col = 0
|
287
|
-
|
288
|
-
1.upto(@workbook.last_column) do |col|
|
289
|
-
header = @workbook.cell(1, col)
|
290
|
-
case header
|
291
|
-
when @feature_name
|
292
|
-
script_col = col
|
293
|
-
when 'role'
|
294
|
-
role_col = col
|
295
|
-
when 'userid'
|
296
|
-
userid_col = col
|
297
|
-
when 'password'
|
298
|
-
password_col = col
|
299
|
-
when 'url'
|
300
|
-
url_col = col
|
301
|
-
when 'name'
|
302
|
-
name_col = col
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
2.upto(@workbook.last_row) do |line|
|
307
|
-
role = @workbook.cell(line, role_col)
|
308
|
-
userid = @workbook.cell(line, userid_col)
|
309
|
-
password = @workbook.cell(line, password_col)
|
310
|
-
url = @workbook.cell(line, url_col)
|
311
|
-
username = @workbook.cell(line, name_col)
|
312
|
-
enabled = @workbook.cell(line, script_col).to_s
|
313
|
-
|
314
|
-
if enabled == 'Y'
|
315
|
-
@login['role'] = role
|
316
|
-
@login['userid'] = userid
|
317
|
-
@login['password'] = password
|
318
|
-
@login['url'] = url
|
319
|
-
@login['name'] = username
|
320
|
-
@login['enabled'] = enabled
|
321
|
-
break
|
322
|
-
end
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
|
-
Then /^I load @var from spreadsheet$/ do
|
327
|
-
@var = Hash.new
|
328
|
-
@workbook.default_sheet = @workbook.sheets[1]
|
329
|
-
script_col = 0
|
330
|
-
name_col = 0
|
331
|
-
|
332
|
-
1.upto(@workbook.last_column) do |col|
|
333
|
-
header = @workbook.cell(1, col)
|
334
|
-
case header
|
335
|
-
when @feature_name
|
336
|
-
script_col = col
|
337
|
-
when 'Variable'
|
338
|
-
name_col = col
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
2.upto(@workbook.last_row) do |line|
|
343
|
-
name = @workbook.cell(line, name_col)
|
344
|
-
value = @workbook.cell(line, script_col).to_s.strip
|
345
|
-
@var[name] = value
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
#Before do
|
350
|
-
# unless awetestlib?
|
351
|
-
# manifest_file = File.join(File.dirname(__FILE__), '..', 'manifest.json')
|
352
|
-
# @params = JSON.parse(File.open(manifest_file).read)['params'] #Have access to all params in manifest file
|
353
|
-
# end
|
354
|
-
#end
|
1
|
+
require 'pry'
|
2
|
+
|
3
|
+
def awetestlib?
|
4
|
+
not Awetestlib::Runner.nil?
|
5
|
+
rescue
|
6
|
+
return false
|
7
|
+
end
|
8
|
+
|
9
|
+
Given /^I run with Watir$/ do
|
10
|
+
require 'watir'
|
11
|
+
require 'win32ole'
|
12
|
+
$ai = ::WIN32OLE.new('AutoItX3.Control')
|
13
|
+
$first_index = 1
|
14
|
+
$timestamp = Time.now.strftime("%Y%m%d%H%M%S")
|
15
|
+
$watir_script = true
|
16
|
+
Watir::IE.close_all
|
17
|
+
Watir::IE.visible = true
|
18
|
+
end
|
19
|
+
|
20
|
+
Given /^I run with Classic Watir$/ do
|
21
|
+
step "I run with Watir$"
|
22
|
+
end
|
23
|
+
|
24
|
+
Given /^I run with Watir-webdriver$/i do
|
25
|
+
require 'watir-webdriver'
|
26
|
+
$first_index = 0
|
27
|
+
$timestamp = Time.now.strftime("%Y%m%d%H%M%S")
|
28
|
+
$watir_script = false
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
When /^I open a new browser$/i do
|
33
|
+
if @params
|
34
|
+
puts "@params: #{@params}"
|
35
|
+
case @params["browser"]
|
36
|
+
when "FF"
|
37
|
+
step "I open Firefox"
|
38
|
+
when "IE"
|
39
|
+
step "I open Internet Explorer"
|
40
|
+
when "C", "GC"
|
41
|
+
step "I open Chrome"
|
42
|
+
end
|
43
|
+
else
|
44
|
+
step "I open Firefox"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Given /^I open a F?f?irefox B?b?rowser$/i do
|
49
|
+
step "I open Firefox"
|
50
|
+
end
|
51
|
+
|
52
|
+
Given /^I open Firefox$/ do
|
53
|
+
step "I run with Watir-webdriver"
|
54
|
+
@browser = Watir::Browser.new :firefox
|
55
|
+
end
|
56
|
+
|
57
|
+
Given /^I open a C?c?hrome B?b?rowser$/i do
|
58
|
+
step "I open Chrome"
|
59
|
+
end
|
60
|
+
|
61
|
+
Given /^I open Chrome$/ do
|
62
|
+
step "I run with Watir-webdriver"
|
63
|
+
@browser = Watir::Browser.new :chrome
|
64
|
+
end
|
65
|
+
|
66
|
+
When /^I open an IE B?b?rowser$/i do
|
67
|
+
step "I open Internet Explorer"
|
68
|
+
end
|
69
|
+
|
70
|
+
Given /^I open an I?i?nternet E?e?xplorer B?b?rowser$/i do
|
71
|
+
step "I open Internet Explorer"
|
72
|
+
end
|
73
|
+
|
74
|
+
Given /^I open Internet Explorer$/i do
|
75
|
+
if $watir_script
|
76
|
+
step "I run with Watir"
|
77
|
+
@browser = Watir::IE.new
|
78
|
+
@browser.speed = :fast
|
79
|
+
else
|
80
|
+
step "I run with Watir-webdriver"
|
81
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
82
|
+
client.timeout = 300 # seconds – default is 60
|
83
|
+
@browser = Watir::Browser.new :ie, :http_client => client
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
Then /^I navigate to the environment url$/ do
|
88
|
+
if @params and @params['environment'] and @params['environment']['url']
|
89
|
+
url = @params['environment']['url']
|
90
|
+
elsif @login and @login['url']
|
91
|
+
url = @login['url']
|
92
|
+
elsif @role and @login[@role] and @login[@role]['url']
|
93
|
+
url = @login[@role]['url']
|
94
|
+
end
|
95
|
+
@browser.goto url
|
96
|
+
end
|
97
|
+
|
98
|
+
Then /^I go to the url "(.*?)"$/ do |url|
|
99
|
+
@browser.goto url
|
100
|
+
end
|
101
|
+
|
102
|
+
Then /^I go to the (URL|url)$/ do |dummy|
|
103
|
+
step "I navigate to the environment url"
|
104
|
+
end
|
105
|
+
|
106
|
+
Then /^I click "(.*?)"$/ do |element_text|
|
107
|
+
step "I click the element with \"text\" \"#{element_text}\""
|
108
|
+
end
|
109
|
+
|
110
|
+
Then /^I click the button "(.*?)"$/ do |element_text|
|
111
|
+
step "I click the button with \"text\" \"#{element_text}\""
|
112
|
+
end
|
113
|
+
|
114
|
+
Then /^I click the "?(.*?)"? with "(.*?)" "(.*?)"$/ do |element, how, what|
|
115
|
+
step "I wait until #{element} with #{how} \"#{what}\" is ready"
|
116
|
+
#what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
117
|
+
case element
|
118
|
+
when 'link'
|
119
|
+
target = @browser.link(how.to_sym, what)
|
120
|
+
when 'button'
|
121
|
+
target = @browser.button(how.to_sym, what)
|
122
|
+
else
|
123
|
+
target = @browser.element(how.to_sym, what)
|
124
|
+
end
|
125
|
+
if target.respond_to?("click")
|
126
|
+
if $watir_script
|
127
|
+
target.click
|
128
|
+
else
|
129
|
+
target.fire_event('onclick')
|
130
|
+
end
|
131
|
+
else
|
132
|
+
fail("#{element} with #{how} '#{what}' does not respond to 'click'")
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
And /^I enter "(.*?)" in text field with "?(.*?)"? "(.*?)"$/ do |value, how, what|
|
137
|
+
what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
138
|
+
#step "I wait until text field with #{how} \"#{what}\" is ready"
|
139
|
+
@browser.text_field(how.to_sym, /#{what}/).set(value)
|
140
|
+
end
|
141
|
+
|
142
|
+
And /^I enter the value for "(.*?)" in text field with "?(.*?)"? "(.*?)"$/ do |index, how, what|
|
143
|
+
if index =~ /zipcode/
|
144
|
+
value = @var[index].to_i.to_s
|
145
|
+
else
|
146
|
+
value = @var[index]
|
147
|
+
end
|
148
|
+
step "I enter \"#{value}\" in text field with #{how} \"#{what}\""
|
149
|
+
end
|
150
|
+
|
151
|
+
And /^I select the value "(.*?)" in select list with "?(.*?)"? "(.*?)"$/ do |value, how, what|
|
152
|
+
#what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
153
|
+
@browser.select_list(how.to_sym, what).select_value(/#{value}/)
|
154
|
+
end
|
155
|
+
|
156
|
+
And /^I select the option "(.*?)" in select list with "?(.*?)"? "(.*?)"$/ do |option, how, what|
|
157
|
+
#what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
158
|
+
@browser.select_list(how.to_sym, what).select(/#{option}/)
|
159
|
+
end
|
160
|
+
|
161
|
+
And /^I select the value for "(.*?)" in select list with "?(.*?)"? "(.*?)"$/ do |index, how, what|
|
162
|
+
value = @var[index]
|
163
|
+
step "I select the value \"#{value}\" in select list with #{how} \"#{what}\""
|
164
|
+
end
|
165
|
+
|
166
|
+
Then /^I check that the "?(.*?)"? with "?(.*?)"? "(.*?)" contains "(.*?)"$/ do |element, how, what, target|
|
167
|
+
#what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
168
|
+
step "I wait until #{element} with #{how} \"#{what}\" is ready"
|
169
|
+
unless @browser.element(how.to_sym, what).text.include?(target)
|
170
|
+
fail ("#{element} with #{how} '#{what}' does not contain '#{target}'")
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
Then /^I check that the text field with "?(.*?)"? "(.*?)" contains the value for "(.*?)"$/ do |how, what, index|
|
176
|
+
if index =~ /zipcode/
|
177
|
+
value = @var[index].to_i.to_s
|
178
|
+
else
|
179
|
+
value = @var[index]
|
180
|
+
end
|
181
|
+
#what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
182
|
+
unless @browser.text_field(how.to_sym, what).value.include?(value)
|
183
|
+
fail("The text field with #{how} '#{what}' does not contain the value for '${index}' ('#{value}'")
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
Then /^I should see "(.*?)"$/ do |text|
|
188
|
+
step "I wait 1 second"
|
189
|
+
unless @browser.text.include? text
|
190
|
+
fail("Did not find text #{text}")
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
Then /^I should not see "(.*?)"$/ do |text|
|
195
|
+
if @browser.text.include? text
|
196
|
+
fail("Found text #{text}")
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
Then /^I fill in "(.*?)" with "(.*?)"$/ do |field, value| # assumes a label element and its associated element has id
|
201
|
+
associated_label = @browser.label(:text, field).attribute_value("for")
|
202
|
+
#associated_label = @browser.element(:xpath, '//label[contains(text(),"#{arg1}")]').attribute_value("for"))
|
203
|
+
@browser.text_field(:id, associated_label).set value
|
204
|
+
end
|
205
|
+
|
206
|
+
Then /^let me debug$|^pry$|^execute binding.pry$/ do
|
207
|
+
binding.pry
|
208
|
+
end
|
209
|
+
|
210
|
+
When /^I wait (\d+) seconds?$/ do |seconds|
|
211
|
+
sleep seconds.to_i
|
212
|
+
end
|
213
|
+
|
214
|
+
When /^I wait until "?(.*?)"? with "?(.*?)"? "(.*?)" is ready$/ do |element, how, what|
|
215
|
+
#what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
|
216
|
+
ok = false
|
217
|
+
if $watir_script
|
218
|
+
if Watir::Wait.until {@browser.element(how, what).exists?}
|
219
|
+
if Watir::Wait.until {@browser.element(how, what).visible?}
|
220
|
+
if Watir::Wait.until {@browser.element(how, what).enabled?}
|
221
|
+
ok = true
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
else
|
226
|
+
case element
|
227
|
+
when 'button'
|
228
|
+
if @browser.button(how.to_sym, what).wait_until_present
|
229
|
+
ok = true
|
230
|
+
end
|
231
|
+
when 'text field'
|
232
|
+
sleep 2
|
233
|
+
#if @browser.text_field(how.to_sym, what).wait_until_present
|
234
|
+
ok = true
|
235
|
+
#end
|
236
|
+
else
|
237
|
+
if @browser.element(how.to_sym, what).wait_until_present
|
238
|
+
ok = true
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
unless ok
|
243
|
+
fail("#{element} with #{how} '#{what}' is not ready")
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
And /^I click "(.*?)" in the browser alert$/ do |button|
|
248
|
+
if $watir_script
|
249
|
+
$ai.WinWait("Message from webpage")
|
250
|
+
sleep(1)
|
251
|
+
$ai.ControlClick("Message from webpage", "", button)
|
252
|
+
else
|
253
|
+
@browser.alert.wait_until_present
|
254
|
+
case button
|
255
|
+
when /ok/i, /yes/i, /submit/i
|
256
|
+
@browser.alert.ok
|
257
|
+
when /cancel/i, /close/i
|
258
|
+
@browser.alert.close
|
259
|
+
else
|
260
|
+
fail("'#{button} for alert not recognized.")
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
And /^I close the browser$/ do
|
266
|
+
@browser.close
|
267
|
+
end
|
268
|
+
|
269
|
+
Given /^I load data spreadsheet "(.*?)" for "(.*?)"$/ do |file, feature|
|
270
|
+
require 'roo'
|
271
|
+
@workbook = Excel.new(file)
|
272
|
+
@feature_name = feature #File.basename(feature, ".feature")
|
273
|
+
step "I load @login from spreadsheet"
|
274
|
+
step "I load @var from spreadsheet"
|
275
|
+
end
|
276
|
+
|
277
|
+
Then /^I load @login from spreadsheet$/ do
|
278
|
+
@login = Hash.new
|
279
|
+
@workbook.default_sheet = @workbook.sheets[0]
|
280
|
+
|
281
|
+
script_col = 0
|
282
|
+
role_col = 0
|
283
|
+
userid_col = 0
|
284
|
+
password_col = 0
|
285
|
+
url_col = 0
|
286
|
+
name_col = 0
|
287
|
+
|
288
|
+
1.upto(@workbook.last_column) do |col|
|
289
|
+
header = @workbook.cell(1, col)
|
290
|
+
case header
|
291
|
+
when @feature_name
|
292
|
+
script_col = col
|
293
|
+
when 'role'
|
294
|
+
role_col = col
|
295
|
+
when 'userid'
|
296
|
+
userid_col = col
|
297
|
+
when 'password'
|
298
|
+
password_col = col
|
299
|
+
when 'url'
|
300
|
+
url_col = col
|
301
|
+
when 'name'
|
302
|
+
name_col = col
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
2.upto(@workbook.last_row) do |line|
|
307
|
+
role = @workbook.cell(line, role_col)
|
308
|
+
userid = @workbook.cell(line, userid_col)
|
309
|
+
password = @workbook.cell(line, password_col)
|
310
|
+
url = @workbook.cell(line, url_col)
|
311
|
+
username = @workbook.cell(line, name_col)
|
312
|
+
enabled = @workbook.cell(line, script_col).to_s
|
313
|
+
|
314
|
+
if enabled == 'Y'
|
315
|
+
@login['role'] = role
|
316
|
+
@login['userid'] = userid
|
317
|
+
@login['password'] = password
|
318
|
+
@login['url'] = url
|
319
|
+
@login['name'] = username
|
320
|
+
@login['enabled'] = enabled
|
321
|
+
break
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
Then /^I load @var from spreadsheet$/ do
|
327
|
+
@var = Hash.new
|
328
|
+
@workbook.default_sheet = @workbook.sheets[1]
|
329
|
+
script_col = 0
|
330
|
+
name_col = 0
|
331
|
+
|
332
|
+
1.upto(@workbook.last_column) do |col|
|
333
|
+
header = @workbook.cell(1, col)
|
334
|
+
case header
|
335
|
+
when @feature_name
|
336
|
+
script_col = col
|
337
|
+
when 'Variable'
|
338
|
+
name_col = col
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
2.upto(@workbook.last_row) do |line|
|
343
|
+
name = @workbook.cell(line, name_col)
|
344
|
+
value = @workbook.cell(line, script_col).to_s.strip
|
345
|
+
@var[name] = value
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
#Before do
|
350
|
+
# unless awetestlib?
|
351
|
+
# manifest_file = File.join(File.dirname(__FILE__), '..', 'manifest.json')
|
352
|
+
# @params = JSON.parse(File.open(manifest_file).read)['params'] #Have access to all params in manifest file
|
353
|
+
# end
|
354
|
+
#end
|