rwebspec-webdriver 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,6 +1,9 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ == 0.1.5
5
+ * Support TestWise 2
6
+
4
7
  == 0.1.4
5
8
  * Squeeze spaces out of browser.text
6
9
 
data/Rakefile CHANGED
@@ -69,7 +69,7 @@ end
69
69
  spec = Gem::Specification.new do |s|
70
70
  s.platform= Gem::Platform::RUBY
71
71
  s.name = "rwebspec-webdriver"
72
- s.version = "0.1.4"
72
+ s.version = "0.1.5"
73
73
  s.summary = "Executable functional specification for web applications in RSpec syntax and Selenium-WebDriver"
74
74
  s.description = "Alternative web test syntax on top of Selenium-WebDriver"
75
75
 
@@ -36,14 +36,14 @@ module RWebSpec
36
36
  # New Options:
37
37
  # :browser => :ie | :firefox | :chrome
38
38
  def open_browser(base_url = nil, options = {})
39
- puts "[DEBUG] [SeleniumDriver] Callling open_browser #{base_url}"
39
+ # puts "[DEBUG] [SeleniumDriver] Callling open_browser #{base_url}"
40
40
  begin
41
41
  support_unicode
42
42
  rescue => e
43
43
  puts "Unicode may not work in IE, #{e}"
44
44
  end
45
45
 
46
- base_url ||= $ITEST2_PROJECT_BASE_URL
46
+ base_url ||= $TESTWISE_PROJECT_BASE_URL
47
47
  base_url ||= $BASE_URL
48
48
  raise "base_url must be set" if base_url.nil?
49
49
 
@@ -56,9 +56,10 @@ module RWebSpec
56
56
 
57
57
  options = default_options.merge options
58
58
 
59
- if $ITEST2_BROWSER
60
- options[:browser] = $ITEST2_BROWSER.downcase
59
+ if $TESTWISE_BROWSER
60
+ options[:browser] = $TESTWISE_BROWSER.downcase
61
61
  end
62
+
62
63
  if options[:firefox] && options[:browser].nil? then
63
64
  options[:browser] = "firefox" # legacy
64
65
  end
@@ -71,9 +72,9 @@ module RWebSpec
71
72
  end
72
73
 
73
74
  if options[:start_new] || $celerity_loaded
74
- puts "[DEBUG] [SeleniumBrowser] creating a new browser"
75
+ # puts "[DEBUG] [SeleniumBrowser] creating a new browser"
75
76
  @web_browser = WebBrowser.new(uri_base, nil, options)
76
- puts "[DEBUG] [SeleniumBrowser] browser: #{@web_browser.inspect}"
77
+ # puts "[DEBUG] [SeleniumBrowser] browser: #{@web_browser.inspect}"
77
78
  else
78
79
  @web_browser = WebBrowser.reuse(uri_base, options) # Reuse existing browser
79
80
  end
@@ -113,7 +114,7 @@ module RWebSpec
113
114
  def close_browser
114
115
  if @web_browser
115
116
  # Old TestWise version
116
- # @web_browser.close_browser unless $ITEST2_LEAVE_BROWSER_OPEN_AFTER_RUN
117
+ # @web_browser.close_browser unless $TESTWISE_LEAVE_BROWSER_OPEN_AFTER_RUN
117
118
  @web_browser.close_browser
118
119
  else
119
120
  WebBrowser.close_all_browsers
@@ -150,7 +151,7 @@ module RWebSpec
150
151
  # Example:
151
152
  # begin_at("http://www.itest2.com")
152
153
  def begin_at(url)
153
- puts "[DEBUG] [SeleniumBrowser] begin_at #{url}"
154
+ # puts "[DEBUG] [SeleniumBrowser] begin_at #{url}"
154
155
  dump_caller_stack
155
156
  @web_browser.begin_at(url)
156
157
  end
@@ -384,14 +385,14 @@ module RWebSpec
384
385
  end
385
386
 
386
387
  def default_dump_dir
387
- if $ITEST2_RUNNING_SPEC_ID && $ITEST2_WORKING_DIR
388
+ if $TESTWISE_RUNNING_SPEC_ID && $TESTWISE_WORKING_DIR
388
389
 
389
- $ITEST2_DUMP_DIR = File.join($ITEST2_WORKING_DIR, "dump")
390
- FileUtils.mkdir($ITEST2_DUMP_DIR) unless File.exists?($ITEST2_DUMP_DIR)
390
+ $TESTWISE_DUMP_DIR = File.join($TESTWISE_WORKING_DIR, "dump")
391
+ FileUtils.mkdir($TESTWISE_DUMP_DIR) unless File.exists?($TESTWISE_DUMP_DIR)
391
392
 
392
- spec_run_id = $ITEST2_RUNNING_SPEC_ID
393
+ spec_run_id = $TESTWISE_RUNNING_SPEC_ID
393
394
  spec_run_dir_name = spec_run_id.to_s.rjust(4, "0") unless spec_run_id == "unknown"
394
- to_dir = File.join($ITEST2_DUMP_DIR, spec_run_dir_name)
395
+ to_dir = File.join($TESTWISE_DUMP_DIR, spec_run_dir_name)
395
396
  else
396
397
  to_dir = ENV['TEMP_DIR'] || (is_windows? ? "C:\\temp" : "/tmp")
397
398
  end
@@ -957,27 +958,6 @@ module RWebSpec
957
958
  end
958
959
  end
959
960
 
960
- # take_screenshot to save the current active window
961
- # TODO can't move mouse
962
- def take_screenshot_old
963
- if is_windows? && $ITEST2_DUMP_PAGE
964
- begin
965
- puts "[DEBUG] Capturing screenshots..."
966
- screenshot_image_filename = "rwebspec_" + Time.now.strftime("%m%d%H%M%S") + ".jpg"
967
- the_dump_dir = default_dump_dir
968
- FileUtils.mkdir_p(the_dump_dir) unless File.exists?(the_dump_dir)
969
- screenshot_image_filepath = File.join(the_dump_dir, screenshot_image_filename)
970
-
971
- screenshot_image_filepath.gsub!("/", "\\") if is_windows?
972
- screen_capture(screenshot_image_filepath, true)
973
-
974
- notify_screenshot_location(screenshot_image_filepath)
975
- rescue
976
- puts "error: #{Failed to capture screen}"
977
- end
978
- end
979
- end
980
-
981
961
 
982
962
  # use win32screenshot library to save curernt active window, which shall be IE
983
963
  #
@@ -84,7 +84,7 @@ module RWebSpec
84
84
 
85
85
  # When running
86
86
  def debugging?
87
- $ITEST2_DEBUGGING && $ITEST2_RUNNING_AS == "test_case"
87
+ $TESTWISE_DEBUGGING && $TESTWISE_RUNNING_AS == "test_case"
88
88
  end
89
89
 
90
90
  # RSpec Matchers
@@ -12,12 +12,12 @@ module RWebSpec
12
12
  # Support of iTest to ajust the intervals between keystroke/mouse operations
13
13
  def operation_delay
14
14
  begin
15
- if $ITEST2_OPERATION_DELAY && $ITEST2_OPERATION_DELAY > 0 &&
16
- $ITEST2_OPERATION_DELAY && $ITEST2_OPERATION_DELAY < 30000 then # max 30 seconds
17
- sleep($ITEST2_OPERATION_DELAY / 1000)
15
+ if $TESTWISE_OPERATION_DELAY && $TESTWISE_OPERATION_DELAY > 0 &&
16
+ $TESTWISE_OPERATION_DELAY && $TESTWISE_OPERATION_DELAY < 30000 then # max 30 seconds
17
+ sleep($TESTWISE_OPERATION_DELAY / 1000)
18
18
  end
19
19
 
20
- while $ITEST2_PAUSE
20
+ while $TESTWISE_PAUSE
21
21
  debug("Paused, waiting ...")
22
22
  sleep 1
23
23
  end
@@ -33,7 +33,7 @@ module RWebSpec
33
33
 
34
34
  # find out the line (and file) the execution is on, and notify iTest via Socket
35
35
  def dump_caller_stack
36
- return unless $ITEST2_TRACE_EXECUTION
36
+ return unless $TESTWISE_TRACE_EXECUTION
37
37
  begin
38
38
  trace_lines = []
39
39
  trace_file = nil
@@ -70,7 +70,7 @@ module RWebSpec
70
70
  if @last_message == the_message then # ignore the message same as preivous one
71
71
  return
72
72
  end
73
- itest_port = $ITEST2_TRACE_PORT || 7025
73
+ itest_port = $TESTWISE_TRACE_PORT || 7025
74
74
  itest_socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
75
75
  itest_socket.connect(Socket.pack_sockaddr_in(itest_port, '127.0.0.1'))
76
76
  itest_socket.puts(the_message)
@@ -87,9 +87,9 @@ module RWebSpec
87
87
  def initialize_ie_browser(existing_browser, options)
88
88
  if existing_browser then
89
89
  @browser = existing_browser
90
- if $ITEST2_EMULATE_TYPING && $ITEST2_TYPING_SPEED then
91
- @browser.set_slow_speed if $ITEST2_TYPING_SPEED == 'slow'
92
- @browser.set_fast_speed if $ITEST2_TYPING_SPEED == 'fast'
90
+ if $TESTWISE_EMULATE_TYPING && $TESTWISE_TYPING_SPEED then
91
+ @browser.set_slow_speed if $TESTWISE_TYPING_SPEED == 'slow'
92
+ @browser.set_fast_speed if $TESTWISE_TYPING_SPEED == 'fast'
93
93
  else
94
94
  @browser.speed = :zippy
95
95
  end
@@ -97,9 +97,9 @@ module RWebSpec
97
97
  end
98
98
 
99
99
  @browser = Selenium::WebDriver.for :ie
100
- # if $ITEST2_EMULATE_TYPING && $ITEST2_TYPING_SPEED then
101
- # @browser.set_slow_speed if $ITEST2_TYPING_SPEED == 'slow'
102
- # @browser.set_fast_speed if $ITEST2_TYPING_SPEED == 'fast'
100
+ # if $TESTWISE_EMULATE_TYPING && $TESTWISE_TYPING_SPEED then
101
+ # @browser.set_slow_speed if $TESTWISE_TYPING_SPEED == 'slow'
102
+ # @browser.set_fast_speed if $TESTWISE_TYPING_SPEED == 'fast'
103
103
  # else
104
104
  # @browser.speed = :zippy
105
105
  # end
@@ -115,7 +115,7 @@ module RWebSpec
115
115
 
116
116
  # TODO resuse not working yet
117
117
  def self.reuse(base_url, options)
118
- if self.is_windows? && $ITEST2_BROWSER != "Firefox"
118
+ if self.is_windows? && $TESTWISE_BROWSER != "Firefox"
119
119
  Watir::IE.each do |browser_window|
120
120
  return WebBrowser.new(base_url, browser_window, options)
121
121
  end
@@ -35,8 +35,8 @@ module RWebSpec
35
35
  @web_tester = the_browser
36
36
  @page_specific_text = page_specific_text
37
37
  begin
38
- snapshot if $ITEST2_DUMP_PAGE
39
- delay = $ITEST2_PAGE_DELAY
38
+ snapshot if $TESTWISE_DUMP_PAGE
39
+ delay = $TESTWISE_PAGE_DELAY
40
40
  sleep(delay)
41
41
  rescue => e
42
42
  end
@@ -17,7 +17,7 @@ require 'spec'
17
17
  require 'selenium-webdriver'
18
18
 
19
19
  unless defined? RWEBSPEC_VERSION
20
- RWEBSPEC_VERSION = "0.1.4"
20
+ RWEBSPEC_VERSION = "0.1.5"
21
21
  end
22
22
 
23
23
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 4
9
- version: 0.1.4
8
+ - 5
9
+ version: 0.1.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Zhimin Zhan
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-11-25 00:00:00 +10:00
17
+ date: 2011-11-30 00:00:00 +10:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency