awetestlib 0.1.29pre3-x86-mingw32 → 0.1.29pre4-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,9 +3,7 @@ Awetestlib
3
3
 
4
4
  Run automated regression and mobile tests
5
5
 
6
- After completing this guide you will be able to run tests locally from command line or from an IDE
7
-
8
- v0.1.29pre3 fixes an issue with running scripts against Safari on OSX
6
+ After completing this guide you will be able to run tests locally from command line or from an IDE.
9
7
 
10
8
  ------------
11
9
 
@@ -18,21 +16,23 @@ You can check your Ruby version using:
18
16
 
19
17
  ruby -v
20
18
 
21
- Additionally, you will need to install DevKit to compile a few dependent gems. You can download DevKit
19
+ Additionally, for Windows, you will need to install the RubyInstaller DevKit to compile a few dependent gems. You can download DevKit
22
20
  [here](http://rubyinstaller.org/downloads/)
21
+ and the installation directions can be found
22
+ [here](https://github.com/oneclick/rubyinstaller/wiki/Development-Kit)
23
23
 
24
24
  ## Install
25
25
 
26
- In a terminal or command prompt, install the awetestlib gem
26
+ In a terminal or command prompt, install the awetestlib gem:
27
27
 
28
28
  gem install awetestlib --no-ri --no-rdoc
29
29
 
30
- Note: This could take up to 5 minutes for first time installs and you may need to use 'sudo'
30
+ Note: This could take up to 5 minutes for first time installs. You may need to use 'sudo' on OSX
31
31
 
32
32
 
33
33
  ## Setup Regression Module
34
34
 
35
- To setup the regression module, run the following command and verify the step
35
+ Run the following command and verify the step
36
36
 
37
37
  awetestlib regression_setup
38
38
 
@@ -99,10 +99,18 @@ The full list of parameters for the command line currently are:
99
99
 
100
100
  Usage: awetestlib <script_file> [parameters] [options]
101
101
  -b, --browser BROWSER Specify a browser (IE, FF, S, C)
102
- -l, --library LIBRARY Specify a library to be loaded
103
102
  -r, --root_path ROOT_PATH Specify the root path
103
+ -l, --library LIBRARY Specify a library to be loaded
104
104
  -x, --excel EXCEL_FILE Specify an excel file containing variables to be loaded
105
105
  -v, --version VERSION Specify a browser version
106
+ -e, --environment_url URL Specify the environment URL
107
+ -f, --environment_nodename NODE Specify the environment node name
108
+ -n, --environment_name NAME Specify the environment name
109
+ -u, --selenium_remote_url URL Specify the device's remote url and port
110
+ -s, --screencap_path PATH Specify the path where screenshots will be saved
111
+ -o, --output_to_log Write to log file
112
+ --log_path_subdir SUBDIR Specify log path relative to root_path
113
+ --report_all_test_refs Include list of all error/test case reference ids actually validated
106
114
 
107
115
  To start writing your own script, refer to the [Scripting Guide/Wiki](https://github.com/3qilabs/awetestlib/wiki/Getting-Started---Scripting) wiki
108
116
 
@@ -32,7 +32,8 @@ Gem::Specification.new do |s|
32
32
  s.add_dependency('pry')
33
33
  s.add_dependency('rdoc', '~> 3.11')
34
34
  s.add_dependency('cucumber')
35
- s.add_dependency('calabash-android', '0.4.2')
35
+ s.add_dependency('calabash-android', '0.4.3')
36
+ s.add_dependency('sys-uname')
36
37
  s.require_paths = ["lib"]
37
38
  s.files = `git ls-files`.split("\n")
38
39
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -16,14 +16,8 @@ Gem::Specification.new do |s|
16
16
  s.description = %q{Awetest DSL for automated testing of browser-based applications.}
17
17
 
18
18
  s.add_dependency('watir-webdriver')
19
- #s.add_dependency('watir', '1.8.1')
20
- #s.add_dependency('commonwatir', '1.8.1')
21
- #s.add_dependency('firewatir', '1.8.1')
22
19
  s.add_dependency('activesupport', '~> 3.0.0')
23
20
  s.add_dependency('andand')
24
- #s.add_dependency('watirloo')
25
- #s.add_dependency('win32-process')
26
- #s.add_dependency('win32screenshot')
27
21
  s.add_dependency('spreadsheet', '0.6.8')
28
22
  s.add_dependency('google-spreadsheet-ruby', '0.1.6')
29
23
  s.add_dependency('roo', '1.10.1')
@@ -32,10 +26,10 @@ Gem::Specification.new do |s|
32
26
  s.add_dependency('nokogiri')
33
27
  s.add_dependency('i18n')
34
28
  s.add_dependency('rb-appscript')
35
- #s.add_dependency('json', '1.6.1') #for safari support
36
29
  s.add_dependency('pry')
37
30
  s.add_dependency('cucumber')
38
31
  s.add_dependency('calabash-cucumber')
32
+ s.add_dependency('sys-uname')
39
33
  s.require_paths = ["lib"] #,"ext"]
40
34
  s.files = `git ls-files`.split("\n")
41
35
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -16,6 +16,7 @@ def awetestlib_android_setup
16
16
  msg("Question") do
17
17
  puts "I'm about to create an android project named #{@proj_dir} in this directory"
18
18
  puts "Please hit return to confirm that's what you want."
19
+ puts "Enter anything else and hit return to abort."
19
20
  puts "NOTE: You may need to run this command as an administrator."
20
21
  end
21
22
  exit 2 unless STDIN.gets.chomp == ''
@@ -24,4 +25,4 @@ def awetestlib_android_setup
24
25
  puts "Configuring files and settings"
25
26
  end
26
27
 
27
- end
28
+ end
@@ -16,6 +16,7 @@ def awetestlib_cucumber_setup
16
16
  msg("Question") do
17
17
  puts "I'm about to create a cucumber project named #{@proj_dir} in this directory"
18
18
  puts "Please hit return to confirm that's what you want."
19
+ puts "Enter anything else and hit return to abort."
19
20
  puts "NOTE: You may need to run this command as an administrator."
20
21
  end
21
22
  exit 2 unless STDIN.gets.chomp == ''
@@ -26,4 +27,4 @@ def awetestlib_cucumber_setup
26
27
  puts "cucumber yahoo_mail.feature"
27
28
  end
28
29
 
29
- end
30
+ end
@@ -9,6 +9,7 @@ def awetestlib_driver_setup
9
9
  puts "I'm about to put the chromedriver and IEDriverServer in this directory"
10
10
  puts "If it already exists, we will overwrite it"
11
11
  puts "Please hit return to confirm that's what you want."
12
+ puts "Enter anything else and hit return to abort."
12
13
  puts "NOTE: You may need to run this command as an administrator."
13
14
  end
14
15
  exit 2 unless STDIN.gets.chomp == ''
@@ -10,7 +10,7 @@ def print_usage
10
10
  Usage Options:
11
11
 
12
12
  awetestlib regression_setup
13
- setup awetest regression and register autoitx3.dll
13
+ setup awetest regression and register autoitx3.dll in Windows
14
14
 
15
15
  awetestlib rubymine_setup <project_name>
16
16
  setup a rubymine project
@@ -39,4 +39,4 @@ def check_script_type(options)
39
39
  options[:script_type] = 'Regression'
40
40
  options[:script_file] = ARGV[0]
41
41
  end
42
- end
42
+ end
@@ -17,6 +17,7 @@ def awetestlib_mobile_app_setup
17
17
  puts "I'm about to create a mobile app project named #{ARGV[1]} in this directory" if ARGV[1]
18
18
  puts "I'm about to create a mobile app project named sample_mobile_app in this directory" if ARGV[1].nil?
19
19
  puts "Please hit return to confirm that's what you want."
20
+ puts "Enter anything else and hit return to abort."
20
21
  puts "NOTE: You may need to run this command as an administrator."
21
22
  end
22
23
  exit 2 unless STDIN.gets.chomp == ''
@@ -43,6 +43,7 @@ def awetestlib_netbeans_setup
43
43
  puts "I'm about to create a netbeans project named #{ARGV[1]} in this directory" if ARGV[1]
44
44
  puts "I'm about to create a netbeans project named sample_netbeans in this directory" if ARGV[1].nil?
45
45
  puts "Please hit return to confirm that's what you want."
46
+ puts "Enter anything else and hit return to abort."
46
47
  puts "NOTE: You may need to run this command as an administrator."
47
48
  end
48
49
  exit 2 unless STDIN.gets.chomp == ''
@@ -56,4 +57,4 @@ def awetestlib_netbeans_setup
56
57
  puts "Configuring files and settings"
57
58
  end
58
59
 
59
- end
60
+ end
@@ -1,16 +1,30 @@
1
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}")
2
+ using_windows = !!((RUBY_PLATFORM =~ /(win|w)(32|64)$/) || (RUBY_PLATFORM =~ /mswin|mingw/))
3
+ using_osx = RUBY_PLATFORM =~ /darwin/
4
+
5
+ if using_windows
6
+ msg("Question") do
7
+ puts "I'm about to setup awetest regression support and register the AutoItX3.dll"
8
+ puts "Please hit return to confirm that's what you want."
9
+ puts "Enter anything else and hit return to abort."
10
+ puts "NOTE: You may need to run this command as an administrator."
11
+ end
12
+ exit 2 unless STDIN.gets.chomp == ''
13
+
14
+ autoit_file = File.join(File.dirname(__FILE__),"AutoItX3.dll")
15
+ system("regsvr32 #{autoit_file}")
11
16
 
12
- msg("Info") do
13
- puts "Configuring files and settings"
17
+ msg("Info") do
18
+ puts "Configuring files and settings for Windows"
19
+ end
20
+ elsif using_osx
21
+ msg("Info") do
22
+ puts "Currently nothing needed to configure settings for OSX"
23
+ end
24
+ else
25
+ msg("Error") do
26
+ puts "Unsupported operating system: #{RUBY_PLATFORM}"
27
+ end
14
28
  end
15
29
 
16
- end
30
+ end
@@ -20,21 +20,26 @@ def awetestlib_rubymine_setup
20
20
  @source_dir = File.join(File.dirname(__FILE__), '..', 'setup_samples', 'sample_rubymine')
21
21
 
22
22
  if File.exists?(@rubymine_dir)
23
- puts "Rubymine project directory already exists."
23
+ puts "Rubymine project directory (#{@rubymine_dir}) already exists."
24
24
  exit 1
25
25
  end
26
26
 
27
27
  msg("Question") do
28
- puts "I'm about to create a rubymine project named #{ARGV[1]} in this directory" if ARGV[1]
29
- puts "I'm about to create a rubymine project named sample_rubymine in this directory" if ARGV[1].nil?
28
+ if ARGV[1]
29
+ puts "I'm about to create a rubymine project named #{ARGV[1]} in this directory"
30
+ else
31
+ puts "I'm about to create a rubymine project named sample_rubymine in this directory"
32
+ end
30
33
  puts "Please hit return to confirm that's what you want."
34
+ puts "Enter anything else and hit return to abort."
31
35
  puts "NOTE: You may need to run this command as an administrator."
32
36
  end
33
37
  exit 2 unless STDIN.gets.chomp == ''
38
+
34
39
  FileUtils.cp_r(@source_dir, @rubymine_dir)
35
40
  edit_config_file
36
41
  msg("Info") do
37
42
  puts "Configuring files and settings"
38
43
  end
39
44
 
40
- end
45
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -182,12 +182,12 @@ module Awetestlib
182
182
 
183
183
  # @param [String] message The text to place in the log and report
184
184
  # @return [void]
185
- def failed_to_log(message, lnbr = nil, dbg = false)
186
- message << " \n#{get_debug_list}" if dbg or @debug_calls or @debug_calls_fail_only
185
+ def failed_to_log(message, lnbr = nil, dbg = false, exception = nil)
186
+ message << " \n#{get_debug_list}" if dbg.to_s == 'true' or @debug_calls or @debug_calls_fail_only
187
187
  @my_failed_count += 1 if @my_failed_count
188
188
  parse_error_references(message, true)
189
189
  @report_class.add_to_report("#{message}" + " [#{get_caller(lnbr)}]", "FAILED") unless Awetestlib::Runner.nil?
190
- log_message(WARN, "#{message}", FAIL, lnbr)
190
+ log_message(WARN, "#{message}", FAIL, lnbr, nil, exception)
191
191
  end
192
192
 
193
193
  alias validate_failed_tolog failed_to_log
@@ -198,13 +198,13 @@ module Awetestlib
198
198
 
199
199
  # @param [String] message The text to place in the log and report
200
200
  # @return [void]
201
- def fatal_to_log(message, lnbr = nil, dbg = false)
202
- message << " \n#{get_debug_list}" if dbg or (@debug_calls and not @debug_calls_fail_only)
201
+ def fatal_to_log(message, lnbr = nil, dbg = false, exception = nil)
202
+ message << " \n#{get_debug_list}" if dbg.to_s == 'true' or (@debug_calls and not @debug_calls_fail_only)
203
203
  @my_failed_count += 1 if @my_failed_count
204
204
  parse_error_references(message, true)
205
205
  @report_class.add_to_report("#{message}" + " [#{get_caller(lnbr)}]", "FAILED") unless Awetestlib::Runner.nil?
206
206
  debug_to_report("#{__method__}:\n#{dump_caller(lnbr)}")
207
- log_message(FATAL, "#{message} (#{lnbr})", FAIL, lnbr)
207
+ log_message(FATAL, "#{message} (#{lnbr})", FAIL, lnbr, nil, exception)
208
208
  end
209
209
 
210
210
  alias fatal_tolog fatal_to_log
@@ -720,7 +720,9 @@ module Awetestlib
720
720
  # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
721
721
  # @param [String] title The title of the window to be closed. Matched from beginning of string.
722
722
  # @param [String] button The display name of the button to be clicked.
723
- # @param [String] text The text of the window to be closed. Matched from beginning of string.
723
+ # @param [String] text The text of the window to be closed. Matched from beginning of string in Windows
724
+ # with Internet Explorer (regular expressions will fail). Use enough of beginning of the text string, in quotes,
725
+ # to assure the correct modal is found. This will give best portability.
724
726
  # @param [String] side A string identifying which mouse button to click.
725
727
  # @param [Fixnum] wait Number of seconds to wait for the popup to be seen.
726
728
  def close_modal(browser, title="", button="OK", text='', side = 'primary', wait = WAIT)
@@ -743,17 +745,18 @@ module Awetestlib
743
745
  end
744
746
 
745
747
  # TODO: Logging
746
- # Close a Safari modal popup by closing the frontmost Safari dialog. MacOS only
748
+ # Close a Safari modal popup by closing the frontmost Safari dialog. Mac OSX only.
747
749
  def close_modal_s
748
750
  # simply closes the frontmost Safari dialog
749
- Appscript.app("Safari").activate; Appscript.app("System Events").processes["Safari"].key_code(52)
751
+ Appscript.app("Safari").activate
752
+ Appscript.app("System Events").processes["Safari"].key_code(52)
750
753
  end
751
754
 
752
- # Close an IE modal popup by its title.
755
+ # Close an IE modal popup by its title using AutoItX3. Windows only.
753
756
  # @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
754
757
  # @param [String] title The title of the window to be closed. Matched from beginning of string.
755
758
  # @param [String] button The display name of the button to be clicked.
756
- # @param [String] text The text of the window to be closed. Matched from beginning of string.
759
+ # @param [String] text The text of the window to be closed. Matched from beginning of string. Do not use regular expression
757
760
  # @param [String] side A string identifying which mouse button to click.
758
761
  # @param [Fixnum] wait Number of seconds to wait for the popup to be seen.
759
762
  # @param [String] desc Contains a message or description intended to appear in the log and/or report output
@@ -762,7 +765,7 @@ module Awetestlib
762
765
  #TODO needs simplifying, incorporating text verification, and debug code cleaned up
763
766
  title = translate_popup_title(title)
764
767
  msg = "Modal window (popup) '#{title}'"
765
- if @ai.WinWait(title, text, wait)
768
+ if @ai.WinWait(title, text, wait) > 0
766
769
  myHandle = @ai.WinGetHandle(title, text)
767
770
  if myHandle.length > 0
768
771
  debug_to_log("hwnd: #{myHandle.inspect}")
@@ -770,7 +773,7 @@ module Awetestlib
770
773
  window_handle = "[HANDLE:#{myHandle}]"
771
774
  sleep_for(0.5)
772
775
  @ai.WinActivate(window_handle)
773
- if @ai.WinActive(window_handle)
776
+ if @ai.WinActive(window_handle) > 0
774
777
  debug_to_log("#{msg} activated.")
775
778
  controlHandle = @ai.ControlGetHandle(title, '', "[CLASS:Button; TEXT:#{button}]")
776
779
  if not controlHandle.length > 0
@@ -779,16 +782,16 @@ module Awetestlib
779
782
  end
780
783
  debug_to_log("Handle for button '#{button}': [#{controlHandle}]")
781
784
  debug_to_log("#{msg} focus gained.")
782
- if @ai.ControlClick(title, '', "[CLASS:Button; TEXT:#{button}]")
785
+ if @ai.ControlClick(title, '', "[CLASS:Button; TEXT:#{button}]") > 0
783
786
  passed_to_log("#{msg} #{side} click on '[CLASS:Button; TEXT:#{button}]' successful.")
784
787
  sleep_for(0.5)
785
- if @ai.WinExists(window_handle)
788
+ if @ai.WinExists(window_handle) > 0
786
789
  debug_to_log("#{msg} close popup failed on click '#{button}'. Trying WinClose. (#{__LINE__})")
787
790
  @ai.WinClose(title, text)
788
- if @ai.WinExists(window_handle)
791
+ if @ai.WinExists(window_handle) > 0
789
792
  debug_to_log("#{msg} close popup failed with WinClose(#{window_handle}). (#{__LINE__})")
790
793
  @ai.WinKill(window_handle)
791
- if @ai.WinExists(window_handle)
794
+ if @ai.WinExists(window_handle) > 0
792
795
  debug_to_log("#{msg} close popup failed with WinKill(#{window_handle}). (#{__LINE__})")
793
796
  else
794
797
  debug_to_log("#{msg} closed successfully with WinKill(#{window_handle}).")
@@ -820,7 +823,7 @@ module Awetestlib
820
823
 
821
824
  # private :close_modal_ie
822
825
 
823
- # Close an IE modal popup by its title. Calls close_modal_ie.
826
+ # Close an Internet Explorer modal popup by its title. Calls close_modal_ie. Windows only.
824
827
  # @deprecated Use close_modal.
825
828
  # @param [String] title The title of the window to be closed. Matched from beginning of string.
826
829
  # @param [String] button The display name of the button to be clicked.
@@ -216,6 +216,9 @@ module Awetestlib
216
216
 
217
217
  def require_gems
218
218
 
219
+ require 'sys/uname'
220
+ include Sys
221
+
219
222
  case @targetBrowser.abbrev
220
223
 
221
224
  when 'IE'
@@ -267,6 +270,7 @@ module Awetestlib
267
270
  end
268
271
 
269
272
  def start
273
+ get_os
270
274
  before_run
271
275
  run
272
276
  rescue Exception => e
@@ -15,13 +15,13 @@ module Awetestlib
15
15
  end
16
16
 
17
17
  def setup
18
- # if @os_sysname =~ /Windows.+Server\s+2003/
18
+ # if @os.name =~ /Windows.+Server\s+2003/
19
19
  ## 'Microsoft(R) Windows(R) Server 2003, Enterprise Edition'
20
20
  # @vertical_hack_ie = 110
21
21
  # @vertical_hack_ff = 138
22
22
  # @horizontal_hack_ie = 5
23
23
  # @horizontal_hack_ff = 4
24
- # elsif @os_sysname =~ /Windows XP Professional/
24
+ # elsif @os.name =~ /Windows XP Professional/
25
25
  # 'Microsoft Windows XP Professional'
26
26
  @vertical_hack_ie = 118
27
27
  @vertical_hack_ff = 144
@@ -428,7 +428,7 @@ module Awetestlib
428
428
  myList << "[#{$1.gsub(/eval/, @myName)}] "
429
429
  break
430
430
  end
431
- break if x > depth or myCaller =~ /:in .run.$/
431
+ break if x > depth or myCaller =~ /:in .run.$/ # this break causes error in Ruby 1.9.x
432
432
  end
433
433
  if @projName
434
434
  call_list.each_index do |x|
@@ -439,7 +439,7 @@ module Awetestlib
439
439
  break
440
440
  end
441
441
  end
442
- break if x > depth or myCaller =~ /:in .run.$/
442
+ break if x > depth or myCaller =~ /:in .run.$/ # this break causes error in Ruby 1.9.
443
443
  end
444
444
  myList
445
445
  end
@@ -1041,6 +1041,16 @@ module Awetestlib
1041
1041
  return false
1042
1042
  end
1043
1043
 
1044
+ def get_os
1045
+ @os = OpenStruct.new(
1046
+ :name => Uname.sysname,
1047
+ :version => Uname.version,
1048
+ :release => Uname.release,
1049
+ :nodename => Uname.nodename,
1050
+ :machine => Uname.machine
1051
+ )
1052
+ end
1053
+
1044
1054
  end
1045
1055
  end
1046
1056
  end