awetestlib 0.1.30-x86-mingw32 → 1.2.4-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +101 -41
  3. data/awetestlib.gemspec +36 -47
  4. data/awetestlib_osx.gemspec +24 -18
  5. data/awetestlib_windows.gemspec +46 -0
  6. data/bin/awetestlib +130 -111
  7. data/bin/awetestlib-driver-setup.rb +0 -2
  8. data/bin/awetestlib-helpers.rb +43 -30
  9. data/lib/awetestlib.rb +196 -20
  10. data/lib/awetestlib/command_line.rb +44 -0
  11. data/lib/awetestlib/html_report.rb +57 -50
  12. data/lib/awetestlib/logging.rb +242 -171
  13. data/lib/awetestlib/regression/awetest_dsl.rb +4240 -0
  14. data/lib/awetestlib/regression/browser.rb +514 -397
  15. data/lib/awetestlib/regression/date_and_time.rb +280 -0
  16. data/lib/awetestlib/regression/drag_and_drop.rb +24 -0
  17. data/lib/awetestlib/regression/find.rb +70 -43
  18. data/lib/awetestlib/regression/legacy.rb +1 -1
  19. data/lib/awetestlib/regression/mobile.rb +293 -0
  20. data/lib/awetestlib/regression/reporting.rb +298 -0
  21. data/lib/awetestlib/regression/runner.rb +156 -200
  22. data/lib/awetestlib/regression/tables.rb +117 -7
  23. data/lib/awetestlib/regression/test_data.rb +354 -0
  24. data/lib/awetestlib/regression/user_input.rb +179 -93
  25. data/lib/awetestlib/regression/utilities.rb +755 -286
  26. data/lib/awetestlib/regression/validations.rb +325 -115
  27. data/lib/awetestlib/regression/waits.rb +60 -133
  28. data/lib/awetestlib/runner.rb +5 -2
  29. data/lib/version.rb +11 -2
  30. data/setup_samples/sample_cucumber/features/step_definitions/predefined_steps.rb +109 -49
  31. data/setup_samples/sample_mobile_app/features/support/env.rb +1 -1
  32. data/test/google_search2.rb +7 -6
  33. data/test/popup_child_0.rb +13 -0
  34. data/test/popup_child_1.rb +33 -0
  35. data/test/watir_no_require.rb +13 -0
  36. data/test/watir_with_require.rb +16 -0
  37. data/test/zoho_exercise.rb +8 -8
  38. metadata +216 -303
  39. data/AwetestLib Instructions.rtf +0 -0
  40. data/awetestlib.windows.gemspec +0 -42
  41. data/lib/patches/README +0 -2
  42. data/lib/patches/firewatir.rb +0 -106
  43. data/lib/patches/watir.rb +0 -175
@@ -13,10 +13,10 @@ module Awetestlib
13
13
  # @param [Fixnum] seconds The number of seconds to wait.
14
14
  # @param [Boolean] dbg If true, includes a trace in the message
15
15
  # @param [String] desc Contains a message or description intended to appear in the log and/or report output.
16
- def sleep_for(seconds, dbg = true, desc = '')
17
- trace = "\n#{get_debug_list}" if dbg
16
+ def sleep_for(seconds, desc = '')
17
+ trace = $debug ? "\n#{get_debug_list}" : ''
18
18
  msg = build_message("Sleeping for #{seconds} seconds.", desc, trace)
19
- info_to_log(msg)
19
+ info_to_log(msg, 3)
20
20
  sleep(seconds)
21
21
  end
22
22
 
@@ -51,6 +51,7 @@ module Awetestlib
51
51
  start = Time.now.to_f
52
52
  # TODO: try Watir::Wait.until { browser.element(how, what).exists? } instead of this (cumbersome) case statement
53
53
  # TODO: above fails on frame
54
+ # TODO: Webdriver compatibility?
54
55
  Watir::Wait.until { browser.exists? }
55
56
  begin
56
57
  case element
@@ -88,12 +89,11 @@ module Awetestlib
88
89
  end
89
90
  end
90
91
  stop = Time.now.to_f
91
- #debug_to_log("#{__method__}: start:#{start} stop:#{stop}")
92
- # sleep 1
93
- passed_to_log("#{msg} (#{stop - start} seconds)")
92
+ msg += " (#{"%.5f" % (stop - start)} seconds)"
93
+ passed_to_log(msg)
94
94
  true
95
95
  rescue
96
- failed_to_log("Unable to complete #{msg}: '#{$!}'")
96
+ failed_to_log(unable_to(msg))
97
97
  end
98
98
 
99
99
  # Wait _while_ expression in *&block* returns true.
@@ -111,7 +111,7 @@ module Awetestlib
111
111
  # @return [Boolean] True if condition returns false within time limit.
112
112
  def wait_while(browser, desc, timeout = 45, &block)
113
113
  #TODO: Would like to be able to see the block code in the log message instead of the identification
114
- msg = "Wait while #{desc}:"
114
+ msg = build_message("Wait while", desc)
115
115
  start = Time.now.to_f
116
116
  Watir::Wait.until { browser.exists? }
117
117
  begin
@@ -128,9 +128,8 @@ module Awetestlib
128
128
  end
129
129
  end
130
130
  stop = Time.now.to_f
131
- #debug_to_log("#{__method__}: start:#{start} stop:#{stop} block: #{block.to_s}")
132
- # sleep 1
133
- passed_to_log("#{msg} (#{"%.5f" % (stop - start)} seconds)") # {#{block.to_s}}")
131
+ msg += " (#{"%.5f" % (stop - start)} seconds)"
132
+ passed_to_log(msg)
134
133
  true
135
134
  rescue
136
135
  failed_to_log("Unable to complete #{msg}. '#{$!}'")
@@ -146,7 +145,7 @@ module Awetestlib
146
145
  # @return [Boolean] True if condition in *&block* returns true within time limit.
147
146
  def wait_until(browser, desc, timeout = 45, skip_pass = false, &block)
148
147
  #TODO: Would like to be able to see the block code in the log message instead of the identification
149
- msg = "Wait until #{desc}"
148
+ msg = build_message("Wait until", desc)
150
149
  start = Time.now.to_f
151
150
  Watir::Wait.until { browser.exists? }
152
151
  begin
@@ -160,12 +159,11 @@ module Awetestlib
160
159
  end
161
160
  end
162
161
  stop = Time.now.to_f
163
- #debug_to_log("#{__method__}: start:#{start} stop:#{stop} block: #{block.to_s}")
164
- # sleep 1
165
- passed_to_log("#{msg} (#{"%.5f" % (stop - start)} seconds)") unless skip_pass # {#{block.to_s}}")
162
+ msg += " (#{"%.5f" % (stop - start)} seconds)"
163
+ passed_to_log(msg) unless skip_pass # {#{block.to_s}}")
166
164
  true
167
165
  rescue
168
- failed_to_log("Unable to complete #{msg} '#{$!}'")
166
+ failed_to_log(unable_to(msg))
169
167
  end
170
168
 
171
169
  alias wait_until_true wait_until
@@ -179,147 +177,77 @@ module Awetestlib
179
177
  # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
180
178
  # @param [String] desc Contains a message or description intended to appear in the log and/or report output
181
179
  # @param [Fixnum] timeout Maximum time to wait, in seconds.
182
- # @param [Boolean] verbose When set to true, more debug information is written to the log and
183
- # all steps return pass/fail messages in the report.
184
- # @return [Boolean] True if condition returns false within time limit.
185
- def wait_until_ready(browser, how, what, desc = '', timeout = 90, verbose = false)
186
- msg = "#{__method__.to_s.titleize}: element: #{how}='#{what}'"
187
- msg << " #{desc}" if desc.length > 0
188
- proc_exists = Proc.new { browser.element(how, what).exists? }
189
- proc_enabled = Proc.new { browser.element(how, what).enabled? }
190
- case how
191
- when :href
180
+ # @param [Boolean] verbose When set to true, actual wait time is reported.
181
+ # @param [Boolean] quiet When set to true, only fail messages are logged and reported.
182
+ # @return [Boolean] True if element is ready within time limit.
183
+ def wait_until_ready(browser, how, what, desc = '', timeout = 90, verbose = true, quiet = false)
184
+ msg = build_message("Wait until element :#{how}=>'#{what}') is ready.", desc)
185
+ ok = false
186
+ start = Time.now.to_f if verbose
187
+ Watir::Wait.until(timeout) { browser.exists? }
188
+
189
+ if $using_webdriver
190
+ proc_present = Proc.new { browser.element(how, what).present? }
191
+ if Watir::Wait.until(timeout) { proc_present.call(nil) }
192
+ ok = true
193
+ end
194
+ else
195
+ proc_exists = Proc.new { browser.element(how, what).exists? }
196
+ proc_enabled = Proc.new { browser.element(how, what).enabled? }
197
+ if how == :href
192
198
  proc_exists = Proc.new { browser.link(how, what).exists? }
193
199
  proc_enabled = Proc.new { browser.link(how, what).enabled? }
194
- end
195
- if verbose
196
- if wait_until(browser, "#{msg} Element exists.", timeout) { proc_exists.call(nil) }
197
- if wait_until(browser, "#{msg} Element enabled.", timeout) { proc_enabled.call(nil) }
198
- passed_to_log(msg)
199
- true
200
- else
201
- failed_to_log(msg)
202
- end
203
- else
204
- failed_to_log(msg)
205
200
  end
206
- else
207
- start = Time.now.to_f
208
- Watir::Wait.until { browser.exists? }
209
201
  if Watir::Wait.until(timeout) { proc_exists.call(nil) }
210
202
  if Watir::Wait.until(timeout) { proc_enabled.call(nil) }
211
- stop = Time.now.to_f
212
- #debug_to_log("#{__method__}: start:#{"%.5f" % start} stop:#{"%.5f" % stop}")
213
- passed_to_log("#{msg} (#{"%.5f" % (stop - start)} seconds)")
214
- true
215
- else
216
- failed_to_log(msg)
203
+ ok = true
217
204
  end
218
- else
219
- failed_to_log(msg)
220
205
  end
221
206
  end
222
- rescue
223
- failed_to_log("Unable to #{msg}. '#{$!}'")
224
- end
225
207
 
226
- # Wait _until_ element, identified by attribute *how* and its value *what*, exists.
227
- # If it exists within *timeout* seconds then wait _until_ it is enabled. Report only failures.
228
- # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
229
- # @param [Symbol] how The element attribute used to identify the specific element.
230
- # Valid values depend on the kind of element.
231
- # Common values: :text, :id, :title, :name, :class, :href (:link only)
232
- # @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
233
- # @param [String] desc Contains a message or description intended to appear in the log and/or report output
234
- # @param [Fixnum] timeout Maximum time to wait, in seconds.
235
- # @param [Boolean] quiet When set to true, only fail messages are logged and reported.
236
- # @return [Boolean] True if condition returns false within time limit.
237
- def wait_until_ready_quiet(browser, how, what, desc = '', timeout = 45, quiet = true)
238
- msg = "#{__method__.to_s.titleize}: element: #{how}='#{what}'"
239
- msg << " #{desc}" if desc.length > 0
240
- proc_exists = Proc.new { browser.element(how, what).exists? }
241
- proc_enabled = Proc.new { browser.element(how, what).enabled? }
242
- case how
243
- when :href
244
- proc_exists = Proc.new { browser.link(how, what).exists? }
245
- proc_enabled = Proc.new { browser.link(how, what).enabled? }
208
+ if verbose
209
+ stop = Time.now.to_f
210
+ msg += " (#{"%.5f" % (stop - start)} seconds)"
246
211
  end
247
- start = Time.now.to_f
248
- Watir::Wait.until { browser.exists? }
249
- sleep_for(1)
250
- if Watir::Wait.until(timeout) { proc_exists.call(nil) }
251
- if Watir::Wait.until(timeout) { proc_enabled.call(nil) }
252
- stop = Time.now.to_f
253
- #debug_to_log("#{msg}: start:#{"%.5f" % start} stop:#{"%.5f" % stop}")
254
- passed_to_log("#{msg} (#{"%.5f" % (stop - start)} seconds)") unless quiet
255
- true
256
- else
257
- failed_to_log(msg)
212
+ if ok
213
+ unless quiet
214
+ passed_to_log(msg)
258
215
  end
259
216
  else
260
217
  failed_to_log(msg)
261
218
  end
219
+ ok
262
220
  rescue
263
- failed_to_log("Unable to #{msg}. '#{$!}'")
221
+ failed_to_log(unable_to(msg))
222
+ end
223
+
224
+ # Wait _until_ element, identified by attribute *how* and its value *what*, exists.
225
+ # If it exists within *timeout* seconds then wait _until_ it is enabled. By default reports only failures.
226
+ # @param (see #wait_until_ready)
227
+ # @return [Boolean] True if element is ready within time limit.
228
+ def wait_until_ready_quiet(browser, how, what, desc = '', timeout = 90, quiet = true, verbose = false)
229
+ wait_until_ready(browser, how, what, desc, timeout, verbose, quiet)
264
230
  end
265
231
 
266
- def wait_until_text(browser, strg, desc = '', timeout = 60)
267
- if not strg.class.to_s.match('String')
232
+ def wait_until_text(browser, strg, desc = '', refs = '', timeout = 60)
233
+ unless strg.class.to_s.match('String')
268
234
  raise "#{__method__} requires String for search target. #{strg.class} is not supported."
269
235
  end
270
- wait_until(browser, "'#{strg}' #{desc}", timeout) { browser.text.include? strg }
236
+ wait_until(browser, "'#{strg}' #{desc} #{refs}", timeout) { browser.text.include? strg }
271
237
  end
272
238
 
273
239
  alias wait_until_by_text wait_until_text
274
240
 
275
- def wait_until_enabled(browser, what, how, value, desc = '')
276
- # TODO: This can be simplified
277
- start = Time.now.to_f
278
- Watir::Wait.until { browser.exists? }
279
- sleep_for(1)
280
- begin
281
- case what
282
- when :link
283
- Watir::Wait.until { browser.link(how, value).enabled? }
284
- when :button
285
- Watir::Wait.until { browser.button(how, value).enabled? }
286
- when :radio
287
- Watir::Wait.until { browser.radio(how, value).enabled? }
288
- when :checkbox
289
- Watir::Wait.until { browser.checkbox(how, value).enabled? }
290
- when :div
291
- Watir::Wait.until { browser.div(how, value).enabled? }
292
- when :select_list
293
- Watir::Wait.until { browser.select_list(how, value).enabled? }
294
- when :text_field
295
- Watir::Wait.until { browser.text_field(how, value).enabled? }
296
- when :table
297
- Watir::Wait.until { browser.table(how, value).enabled? }
298
- else
299
- Watir::Wait.until { browser.element(how, value).enabled? }
300
- end
301
- rescue => e
302
- if e.class.to_s =~ /TimeOutException/
303
- failed_to_log("Wait until (#{what} :#{how}=>#{value}) enabled. #{desc}: '#{$!}' #{desc}")
304
- return false
305
- elsif not rescue_me(e, __method__, "#{block.to_s}", "#{browser.class}")
306
- raise e
307
- end
308
- end
309
- stop = Time.now.to_f
310
- #debug_to_log("#{__method__}: start:#{start} stop:#{stop}")
311
- # sleep 1
312
- passed_to_log("Wait until (#{what} :#{how}=>#{value}) enabled. #{desc} (#{stop - start} seconds)")
313
- true
314
- rescue
315
- failed_to_log("Unable to complete wait until (#{what} :#{how}=>#{value}) enabled. #{desc}: '#{$!}'")
241
+ def wait_until_enabled(browser, element, how, what, desc = '')
242
+ wait_until_ready(browser, how, what, desc, timeout = 90, verbose = true, quiet = false)
316
243
  end
317
244
 
318
- def wait_until_visible(browser, element, how, what, desc = '')
245
+ def wait_until_visible(browser, element, how, what, desc = '', timeout = 60)
246
+ msg = build_message("Wait until #{element} :#{how}=>'#{what}') is visible.", desc)
319
247
  start = Time.now.to_f
320
248
  Watir::Wait.until { browser.exists? }
321
249
  sleep_for(1)
322
- Watir::Wait.until(20) { browser.element(how, what).exists? }
250
+ Watir::Wait.until(timeout) { browser.element(how, what).exists? }
323
251
  begin
324
252
  case element
325
253
  when :link
@@ -349,12 +277,11 @@ module Awetestlib
349
277
  end
350
278
  end
351
279
  stop = Time.now.to_f
352
- #debug_to_log("#{__method__}: start:#{start} stop:#{stop}")
353
- # sleep 1
354
- passed_to_log("Wait until (#{element} :#{how}=>#{what}) visible. #{desc} (#{stop - start} seconds)")
280
+ msg += " (#{"%.5f" % (stop - start)} seconds)"
281
+ passed_to_log(msg)
355
282
  true
356
283
  rescue
357
- failed_to_log("Unable to complete wait until (#{element} :#{how}=>#{what}) visible. #{desc}: '#{$!}'")
284
+ failed_to_log(unable_to(msg))
358
285
  end
359
286
 
360
287
  # @!endgroup Core
@@ -1,5 +1,6 @@
1
1
  require 'open-uri' #; load_time
2
2
  module Awetestlib
3
+ # TODO replace this with regression/runner. Only one script type.
3
4
  # Parent class. Each script type will have a Runner that inherits from this class.
4
5
  class Runner
5
6
  def initialize(options = {})
@@ -9,8 +10,10 @@ module Awetestlib
9
10
 
10
11
  def check_script_type(script_type)
11
12
  case script_type
12
- when "Regression" ; "Regression" #Should this be regression? possible rename
13
- else ; script_type
13
+ when 'Regression', 'Awetest', 'AwetestDSL', 'Awetestlib'
14
+ 'Regression'
15
+ else
16
+ script_type
14
17
  end
15
18
  end
16
19
  end
data/lib/version.rb CHANGED
@@ -1,4 +1,13 @@
1
1
  module Awetestlib
2
- VERSION = "0.1.30"
3
- VERSION_DATE = "2013-05-21"
2
+ VERSION = "1.2.4"
3
+ VERSION_DATE = "2016-07-19"
4
+ if Dir.exists?('.git')
5
+ require 'git'
6
+ git = Git.open(Dir.pwd)
7
+ branch = git.current_branch
8
+ commit = git.gblob(branch).log(5).first
9
+ BRANCH = branch
10
+ SHA = commit.sha
11
+ SHA_DATE = commit.date
12
+ end
4
13
  end
@@ -5,20 +5,20 @@ rescue
5
5
  end
6
6
 
7
7
  def setup_classic_watir
8
- require 'watir'
9
- require 'win32ole'
10
- $ai = ::WIN32OLE.new('AutoItX3.Control')
11
- $first_index = 1
12
- $timestamp = Time.now.strftime("%Y%m%d%H%M%S")
13
- $watir_script = true
14
- Watir::IE.close_all
15
- Watir::IE.visible = true
16
- end
8
+ require 'watir'
9
+ require 'win32ole'
10
+ $ai = ::WIN32OLE.new('AutoItX3.Control')
11
+ $first_index = 1
12
+ $timestamp = Time.now.strftime("%Y%m%d%H%M%S")
13
+ $watir_script = true
14
+ Watir::IE.close_all
15
+ Watir::IE.visible = true
16
+ end
17
17
 
18
18
  def setup_watir_webdriver
19
19
  require 'watir-webdriver'
20
- $first_index = 0
21
- $timestamp = Time.now.strftime("%Y%m%d%H%M%S")
20
+ $first_index = 0
21
+ $timestamp = Time.now.strftime("%Y%m%d%H%M%S")
22
22
  $watir_script = false
23
23
  end
24
24
 
@@ -29,7 +29,7 @@ end
29
29
 
30
30
  def open_safari
31
31
  setup_watir_webdriver
32
- @browser = Watir::Browser.new(:remote, :desired_capabilities => :'safari')
32
+ @browser = Watir::Browser.new(:remote, :desired_capabilities=>:'safari')
33
33
  end
34
34
 
35
35
  def open_chrome
@@ -52,7 +52,7 @@ end
52
52
 
53
53
  def navigate_to_environment_url
54
54
  if @params and @params['environment'] and @params['environment']['url']
55
- url = @params['environment']['url']
55
+ url = @params['environment']['url']
56
56
  elsif @login and @login['url']
57
57
  url = @login['url']
58
58
  elsif @role and @login[@role] and @login[@role]['url']
@@ -63,24 +63,24 @@ end
63
63
 
64
64
  def open_a_browser
65
65
  if @params
66
- puts "@params: #{@params}"
67
- case @params["browser"]
68
- when "FF"
69
- open_firefox
70
- when "IE"
71
- open_internet_explorer
72
- when "C", "GC"
73
- open_chrome
74
- when "S"
75
- open_safari
76
- end
77
- else
78
- if $watir_script
79
- open_internet_explorer
80
- else
81
- open_firefox
82
- end
83
- end
66
+ puts "@params: #{@params}"
67
+ case @params["browser"]
68
+ when "FF"
69
+ open_firefox
70
+ when "IE"
71
+ open_internet_explorer
72
+ when "C", "GC"
73
+ open_chrome
74
+ when "S"
75
+ open_safari
76
+ end
77
+ else
78
+ if $watir_script
79
+ open_internet_explorer
80
+ else
81
+ open_firefox
82
+ end
83
+ end
84
84
  end
85
85
 
86
86
  Given /^I run with Watir$/ do
@@ -187,7 +187,7 @@ And /^I enter the value for "(.*?)" in text field with "?(.*?)"? "(.*?)"$/ do |i
187
187
  if index =~ /zipcode/
188
188
  value = @var[index].to_i.to_s
189
189
  else
190
- value = @var[index]
190
+ value = index
191
191
  end
192
192
  step "I enter \"#{value}\" in text field with #{how} \"#{what}\""
193
193
  end
@@ -260,9 +260,9 @@ When /^I wait until "?(.*?)"? with "?(.*?)"? "(.*?)" is ready$/ do |element, how
260
260
  #what = Regexp.new(Regexp.escape(what)) unless how =~ /index|text/i or what.is_a?(Regexp)
261
261
  ok = false
262
262
  if $watir_script
263
- if Watir::Wait.until { @browser.element(how, what).exists? }
264
- if Watir::Wait.until { @browser.element(how, what).visible? }
265
- if Watir::Wait.until { @browser.element(how, what).enabled? }
263
+ if Watir::Wait.until {@browser.element(how, what).exists?}
264
+ if Watir::Wait.until {@browser.element(how, what).visible?}
265
+ if Watir::Wait.until {@browser.element(how, what).enabled?}
266
266
  ok = true
267
267
  end
268
268
  end
@@ -276,8 +276,8 @@ When /^I wait until "?(.*?)"? with "?(.*?)"? "(.*?)" is ready$/ do |element, how
276
276
  when 'text field'
277
277
  sleep 2
278
278
  #if @browser.text_field(how.to_sym, what).wait_until_present
279
- ok = true
280
- #end
279
+ ok = true
280
+ #end
281
281
  else
282
282
  if @browser.element(how.to_sym, what).wait_until_present
283
283
  ok = true
@@ -311,16 +311,45 @@ And /^I close the browser$/ do
311
311
  @browser.close
312
312
  end
313
313
 
314
+ When(/^I should see "([^"]*)" but proceed if not present$/) do |arg|
315
+ @text_list[arg]= @browser.link(:text, "#{arg}").exists?
316
+ File.open(@error_file,"w") do |f|
317
+ f.write(@text_list.to_json)
318
+ end
319
+
320
+ if @browser.link(:text, "#{arg}").exists?
321
+ # Do not take a screen shot
322
+ else
323
+ step "I take a screenshot"
324
+ end
325
+ end
326
+
327
+ Then(/^I interact with window having title "(.*?)"$/) do |arg1| # title of child window
328
+ sleep 5
329
+ counter = 0
330
+ if arg1 == "Parent_Window_Title"
331
+ @browser.driver.switch_to.window(@browser.driver.window_handles[0])
332
+ else
333
+ @browser.windows.each do |win|
334
+ if win.title == arg1 # switches control to child window
335
+ @browser.driver.switch_to.window(@browser.driver.window_handles[counter])
336
+ else
337
+ counter = counter + 1
338
+ end
339
+ end
340
+ end
341
+ end
342
+
314
343
  Given /^I load data spreadsheet "(.*?)" for "(.*?)"$/ do |file, feature|
315
344
  require 'roo'
316
- @workbook = Excel.new(file)
317
- @feature_name = feature #File.basename(feature, ".feature")
345
+ @workbook = Excel.new(file)
346
+ @feature_name = feature #File.basename(feature, ".feature")
318
347
  step "I load @login from spreadsheet"
319
348
  step "I load @var from spreadsheet"
320
349
  end
321
350
 
322
351
  Then /^I load @login from spreadsheet$/ do
323
- @login = Hash.new
352
+ @login = Hash.new
324
353
  @workbook.default_sheet = @workbook.sheets[0]
325
354
 
326
355
  script_col = 0
@@ -369,10 +398,10 @@ Then /^I load @login from spreadsheet$/ do
369
398
  end
370
399
 
371
400
  Then /^I load @var from spreadsheet$/ do
372
- @var = Hash.new
401
+ @var = Hash.new
373
402
  @workbook.default_sheet = @workbook.sheets[1]
374
- script_col = 0
375
- name_col = 0
403
+ script_col = 0
404
+ name_col = 0
376
405
 
377
406
  1.upto(@workbook.last_column) do |col|
378
407
  header = @workbook.cell(1, col)
@@ -391,9 +420,40 @@ Then /^I load @var from spreadsheet$/ do
391
420
  end
392
421
  end
393
422
 
394
- #Before do
395
- # unless awetestlib?
396
- # manifest_file = File.join(File.dirname(__FILE__), '..', 'manifest.json')
397
- # @params = JSON.parse(File.open(manifest_file).read)['params'] #Have access to all params in manifest file
398
- # end
399
- #end
423
+ And(/^I take a screenshot$/) do
424
+ take_screenshot
425
+ end
426
+
427
+ Before do
428
+ # unless awetestlib?
429
+ # manifest_file = File.join(File.dirname(__FILE__), '..', 'manifest.json')
430
+ # @params = JSON.parse(File.open(manifest_file).read)['params'] #Have access to all params in manifest file
431
+ # end
432
+ @text_list = Hash.new()
433
+ @error_file = File.join(File.dirname(__FILE__), '..', '..', 'error.txt')
434
+
435
+ if $step_no.to_i < 3
436
+ $step_no = 2
437
+ else
438
+ $step_no = $step_no + 2
439
+ end
440
+ end
441
+
442
+ AfterStep() do
443
+ $step_no = $step_no + 1
444
+ end
445
+
446
+ After do |scenario|
447
+ if scenario.failed?
448
+ take_screenshot
449
+ else
450
+ $step_no = $step_no - 1
451
+ end
452
+ end
453
+
454
+ def take_screenshot
455
+ abc = File.expand_path("../..",File.dirname(__FILE__))
456
+ file_na = abc.split("/").last
457
+ file_path = File.join(File.dirname(__FILE__), '..', '..', "#{file_na.to_s}_#{$step_no}.jpg")
458
+ @browser.screenshot.save(file_path)
459
+ end