rwebspec 1.7.1 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +10 -0
- data/Rakefile +3 -3
- data/lib/rwebspec/assert.rb +1 -1
- data/lib/rwebspec/driver.rb +53 -15
- data/lib/rwebspec/popup.rb +1 -1
- data/lib/rwebspec/test_utils.rb +5 -0
- data/lib/rwebspec/web_browser.rb +8 -7
- data/lib/rwebspec/web_page.rb +4 -0
- data/lib/rwebspec.rb +10 -1
- data/lib/watir_extensions.rb +1 -1
- metadata +8 -8
data/CHANGELOG
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
=========
|
3
|
+
1.8.1
|
4
|
+
[Upgrade] new take screenshot library
|
5
|
+
[Fix] only take screenshot on failed assertions if $task_screenshot is set
|
6
|
+
[Enhancement] add close_all for firefox browser (pass by argument)
|
7
|
+
[Enhancement] refactored driver.close_all_browsers
|
8
|
+
[New] background_visit now works new http-client version
|
9
|
+
[New] element_by_id() for firefox
|
10
|
+
[New] web_page.url
|
11
|
+
[Fix] More correctly detect platform: mswin or mingw
|
12
|
+
[New] add Array.sum methods
|
3
13
|
|
4
14
|
1.7.1
|
5
15
|
[New] New version scheme, matching Watir versioning, appending minor number
|
data/Rakefile
CHANGED
@@ -70,12 +70,12 @@ end
|
|
70
70
|
spec = Gem::Specification.new do |s|
|
71
71
|
s.platform= Gem::Platform::RUBY
|
72
72
|
s.name = "rwebspec"
|
73
|
-
s.version = "1.
|
73
|
+
s.version = "1.8.1"
|
74
74
|
s.summary = "Executable functional specification for web applications in RSpec syntax and Watir"
|
75
75
|
# s.description = ""
|
76
76
|
|
77
77
|
s.author = "Zhimin Zhan"
|
78
|
-
s.email = "zhimin@agileway.
|
78
|
+
s.email = "zhimin@agileway.com.au"
|
79
79
|
s.homepage= "http://github.com/zhimin/rwebspec/tree/master"
|
80
80
|
s.rubyforge_project = "rwebspec"
|
81
81
|
|
@@ -91,7 +91,7 @@ spec = Gem::Specification.new do |s|
|
|
91
91
|
s.files = s.files + Dir.glob( "docs/**/*" )
|
92
92
|
s.add_dependency(%q<rspec>, ["= 1.1.12"])
|
93
93
|
|
94
|
-
s.add_dependency("commonwatir", ">= 1.8.
|
94
|
+
s.add_dependency("commonwatir", ">= 1.8.1")
|
95
95
|
end
|
96
96
|
|
97
97
|
Rake::GemPackageTask.new(spec) do |pkg|
|
data/lib/rwebspec/assert.rb
CHANGED
data/lib/rwebspec/driver.rb
CHANGED
@@ -95,21 +95,25 @@ module RWebSpec
|
|
95
95
|
# @web_browser.close_browser unless $ITEST2_LEAVE_BROWSER_OPEN_AFTER_RUN
|
96
96
|
@web_browser.close_browser
|
97
97
|
else
|
98
|
-
|
98
|
+
close_all_browsers
|
99
99
|
end
|
100
100
|
end
|
101
|
-
|
102
101
|
alias close_ie close_browser
|
103
102
|
|
104
103
|
|
105
104
|
# Close all opening browser windows
|
106
105
|
#
|
107
106
|
def close_all_browsers
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
107
|
+
if @web_browser
|
108
|
+
if is_firefox?
|
109
|
+
FireWatir::Firefox.close_all
|
110
|
+
else
|
111
|
+
Watir::IE.close_all
|
112
|
+
end
|
113
|
+
else
|
114
|
+
browser_type = $ITEST2_BROWSER ? $ITEST2_BROWSER.downcase.to_sym : :ie
|
115
|
+
WebBrowser.close_all_browsers(browser_type)
|
116
|
+
end
|
113
117
|
end
|
114
118
|
|
115
119
|
# Verify the next page following an operation.
|
@@ -168,7 +172,6 @@ module RWebSpec
|
|
168
172
|
@web_browser.goto_page(page) if @web_browser
|
169
173
|
}
|
170
174
|
end
|
171
|
-
|
172
175
|
alias visit goto_page
|
173
176
|
|
174
177
|
|
@@ -181,29 +184,32 @@ module RWebSpec
|
|
181
184
|
end
|
182
185
|
|
183
186
|
# Go to specific url in background (i.e not via browwser, different from goto_url)
|
184
|
-
# This won't share the session with what's currenlty in browser
|
187
|
+
# This won't share the session with what's currenlty in browser, proxy setting
|
185
188
|
#
|
186
189
|
# One use example: resetting database
|
187
190
|
# background_visit("/reset")
|
188
191
|
#
|
189
|
-
def background_visit(url)
|
192
|
+
def background_visit(url, opts = {})
|
190
193
|
require 'httpclient'
|
191
194
|
begin
|
192
195
|
client = HTTPClient.new
|
193
196
|
if url && url =~ /^http/
|
194
|
-
http_response = client.get(url).body
|
197
|
+
http_response = client.get(url).body
|
195
198
|
else
|
196
199
|
base_url = $ITEST2_PROJECT_BASE_URL || $BASE_URL
|
197
|
-
http_response = client.get("#{base_url}#{url}").body
|
200
|
+
http_response = client.get("#{base_url}#{url}").body
|
198
201
|
end
|
202
|
+
|
203
|
+
http_response = http_response.content if http_response.respond_to?("content")
|
199
204
|
rescue => e
|
200
205
|
raise e
|
201
206
|
end
|
202
207
|
end
|
203
208
|
|
204
|
-
# Attach to
|
209
|
+
# Attach to existing browser window
|
205
210
|
#
|
206
|
-
# attach_browser(:title,
|
211
|
+
# attach_browser(:title, "Page" )
|
212
|
+
# attach_browser(:url, "http://wwww..." )
|
207
213
|
def attach_browser(how, what, options = {})
|
208
214
|
options.merge!(:browser => is_firefox? ? "Firefox" : "IE") unless options[:browser]
|
209
215
|
begin
|
@@ -941,7 +947,7 @@ module RWebSpec
|
|
941
947
|
|
942
948
|
# take_screenshot to save the current active window
|
943
949
|
# TODO can't move mouse
|
944
|
-
def
|
950
|
+
def take_screenshot_old
|
945
951
|
if is_windows? && $ITEST2_DUMP_PAGE
|
946
952
|
begin
|
947
953
|
puts "[DEBUG] Capturing screenshots..."
|
@@ -961,6 +967,38 @@ module RWebSpec
|
|
961
967
|
end
|
962
968
|
|
963
969
|
|
970
|
+
|
971
|
+
# use win32screenshot library to save curernt active window, which shall be IE
|
972
|
+
#
|
973
|
+
def take_screenshot
|
974
|
+
# puts "calling new take screenshot"
|
975
|
+
if $testwise_screenshot_supported && is_windows?
|
976
|
+
# puts "testwise supported: #{$testwise_screenshot_supported}"
|
977
|
+
begin
|
978
|
+
screenshot_image_filename = "screenshot_" + Time.now.strftime("%m%d%H%M%S") + ".jpg"
|
979
|
+
the_dump_dir = default_dump_dir
|
980
|
+
FileUtils.mkdir_p(the_dump_dir) unless File.exists?(the_dump_dir)
|
981
|
+
screenshot_image_filepath = File.join(the_dump_dir, screenshot_image_filename)
|
982
|
+
screenshot_image_filepath.gsub!("/", "\\") if is_windows?
|
983
|
+
|
984
|
+
FileUtils.rm_f(screenshot_image_filepath) if File.exist?(screenshot_image_filepath)
|
985
|
+
|
986
|
+
if is_firefox? then
|
987
|
+
Win32::Screenshot::Take.of(:window, :title => /mozilla\sfirefox/i).write(screenshot_image_filepath)
|
988
|
+
elsif ie
|
989
|
+
Win32::Screenshot::Take.of(:window, :title => /internet\sexplorer/i).write(screenshot_image_filepath)
|
990
|
+
else
|
991
|
+
Win32::Screenshot::Take.of(:foreground).write(screenshot_image_filepath)
|
992
|
+
end
|
993
|
+
notify_screenshot_location(screenshot_image_filepath)
|
994
|
+
rescue => e
|
995
|
+
puts "error on taking screenshot: #{e}"
|
996
|
+
end
|
997
|
+
end
|
998
|
+
end
|
999
|
+
|
1000
|
+
# end of methods
|
1001
|
+
|
964
1002
|
end
|
965
1003
|
|
966
1004
|
end
|
data/lib/rwebspec/popup.rb
CHANGED
@@ -112,7 +112,7 @@ module RWebSpec
|
|
112
112
|
def prepare_to_click_button_in_popup(button = "OK", wait_time = 3)
|
113
113
|
# !@web_browser.is_firefox?
|
114
114
|
# TODO: firefox is OK
|
115
|
-
if RUBY_PLATFORM =~ /mswin/ then
|
115
|
+
if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/ then
|
116
116
|
start_checking_js_dialog(button, wait_time)
|
117
117
|
else
|
118
118
|
raise "this only support on Windows and on IE"
|
data/lib/rwebspec/test_utils.rb
CHANGED
data/lib/rwebspec/web_browser.rb
CHANGED
@@ -326,15 +326,14 @@ module RWebSpec
|
|
326
326
|
end
|
327
327
|
sleep 2
|
328
328
|
end
|
329
|
-
|
330
329
|
alias close close_browser
|
331
330
|
|
332
|
-
|
333
|
-
|
334
|
-
if RUBY_PLATFORM.downcase.include?("mswin")
|
331
|
+
def self.close_all_browsers(browser_type = :ie)
|
332
|
+
if browser_type == :ie
|
335
333
|
Watir::IE.close_all
|
336
|
-
|
334
|
+
elsif browser_type == :firefox
|
337
335
|
# raise "not supported in FireFox yet."
|
336
|
+
FireWatir::Firefox.new.close_all
|
338
337
|
end
|
339
338
|
end
|
340
339
|
|
@@ -553,7 +552,9 @@ module RWebSpec
|
|
553
552
|
def element_by_id(elem_id)
|
554
553
|
if is_firefox?
|
555
554
|
# elem = @browser.document.getElementById(elem_id)
|
556
|
-
elem = div(:id, elem_id) || label(:id, elem_id) || button(:id, elem_id) ||
|
555
|
+
# elem = div(:id, elem_id) || label(:id, elem_id) || button(:id, elem_id) ||
|
556
|
+
# span(:id, elem_id) || hidden(:id, elem_id) || link(:id, elem_id) || radio(:id, elem_id)
|
557
|
+
elem = browser.element_by_xpath("//*[@id='#{elem_id}']")
|
557
558
|
else
|
558
559
|
elem = @browser.document.getElementById(elem_id)
|
559
560
|
end
|
@@ -576,7 +577,7 @@ module RWebSpec
|
|
576
577
|
end
|
577
578
|
|
578
579
|
def select_file_for_upload(file_field, file_path)
|
579
|
-
normalized_file_path = RUBY_PLATFORM.downcase.include?("
|
580
|
+
normalized_file_path = RUBY_PLATFORM.downcase.include?("mingw") ? file_path.gsub("/", "\\") : file_path
|
580
581
|
file_field(:name, file_field).set(normalized_file_path)
|
581
582
|
end
|
582
583
|
|
data/lib/rwebspec/web_page.rb
CHANGED
data/lib/rwebspec.rb
CHANGED
@@ -24,7 +24,16 @@ require 'active_support/core_ext'
|
|
24
24
|
require 'spec'
|
25
25
|
|
26
26
|
unless defined? RWEBSPEC_VERSION
|
27
|
-
RWEBSPEC_VERSION = RWEBUNIT_VERSION = "1.
|
27
|
+
RWEBSPEC_VERSION = RWEBUNIT_VERSION = "1.8.1"
|
28
|
+
end
|
29
|
+
|
30
|
+
if RUBY_PLATFORM =~ /mswin/ or RUBY_PLATFORM =~ /mingw/
|
31
|
+
$testwise_screenshot_supported = false
|
32
|
+
begin
|
33
|
+
require 'win32/screenshot'
|
34
|
+
$testwise_screenshot_supported = true
|
35
|
+
rescue LoadError => no_screen_library_error
|
36
|
+
end
|
28
37
|
end
|
29
38
|
|
30
39
|
# Extra full path to load libraries
|
data/lib/watir_extensions.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rwebspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 53
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 8
|
9
9
|
- 1
|
10
|
-
version: 1.
|
10
|
+
version: 1.8.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Zhimin Zhan
|
@@ -15,7 +15,7 @@ autorequire: rwebspec
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-05-28 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 53
|
46
46
|
segments:
|
47
47
|
- 1
|
48
48
|
- 8
|
49
|
-
-
|
50
|
-
version: 1.8.
|
49
|
+
- 1
|
50
|
+
version: 1.8.1
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
53
|
description:
|
54
|
-
email: zhimin@agileway.
|
54
|
+
email: zhimin@agileway.com.au
|
55
55
|
executables: []
|
56
56
|
|
57
57
|
extensions: []
|