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 +3 -0
- data/Rakefile +1 -1
- data/lib/rwebspec-webdriver/driver.rb +14 -34
- data/lib/rwebspec-webdriver/rspec_helper.rb +1 -1
- data/lib/rwebspec-webdriver/testwise_plugin.rb +6 -6
- data/lib/rwebspec-webdriver/web_browser.rb +7 -7
- data/lib/rwebspec-webdriver/web_page.rb +2 -2
- data/lib/rwebspec-webdriver.rb +1 -1
- metadata +3 -3
data/CHANGELOG
CHANGED
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.
|
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 ||= $
|
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 $
|
60
|
-
options[:browser] = $
|
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 $
|
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 $
|
388
|
+
if $TESTWISE_RUNNING_SPEC_ID && $TESTWISE_WORKING_DIR
|
388
389
|
|
389
|
-
$
|
390
|
-
FileUtils.mkdir($
|
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 = $
|
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($
|
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
|
#
|
@@ -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 $
|
16
|
-
$
|
17
|
-
sleep($
|
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 $
|
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 $
|
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 = $
|
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 $
|
91
|
-
@browser.set_slow_speed if $
|
92
|
-
@browser.set_fast_speed if $
|
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 $
|
101
|
-
# @browser.set_slow_speed if $
|
102
|
-
# @browser.set_fast_speed if $
|
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? && $
|
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 $
|
39
|
-
delay = $
|
38
|
+
snapshot if $TESTWISE_DUMP_PAGE
|
39
|
+
delay = $TESTWISE_PAGE_DELAY
|
40
40
|
sleep(delay)
|
41
41
|
rescue => e
|
42
42
|
end
|
data/lib/rwebspec-webdriver.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
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-
|
17
|
+
date: 2011-11-30 00:00:00 +10:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|