watirsplash 0.2.0 → 0.2.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/History.rdoc +7 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/watirsplash.rb +0 -2
- data/lib/watirsplash/autoit.rb +3 -3
- data/lib/watirsplash/html_formatter.rb +7 -6
- data/lib/watirsplash/spec_helper.rb +1 -1
- data/lib/watirsplash/waiter.rb +9 -9
- data/spec/spec_helper_spec.rb +7 -7
- metadata +8 -7
- data/lib/watirsplash/win32screenshot.rb +0 -52
data/History.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
=== Version 0.2.1 / 2010-05-27
|
2
|
+
|
3
|
+
* added compatibility with Win32::Screenshot 0.0.4
|
4
|
+
* wait_until behaves exactly the same as with Watir - throws Exception upon timeout
|
5
|
+
* removed wait_until! - use wait_until instead
|
6
|
+
* added wait_until? which returns true if condition was true and doesn't throw Exception upon timeout
|
7
|
+
|
1
8
|
=== Version 0.2.0 / 2010-05-03
|
2
9
|
|
3
10
|
PS! This version has some backwards incompatible changes!
|
data/Rakefile
CHANGED
@@ -34,7 +34,7 @@ Execute "watirsplash generate" under your project's directory to generate defaul
|
|
34
34
|
gem.add_dependency("rmagick")
|
35
35
|
gem.add_dependency("syntax")
|
36
36
|
gem.add_dependency("win32console")
|
37
|
-
gem.add_dependency("win32screenshot")
|
37
|
+
gem.add_dependency("win32screenshot", ">=0.0.4")
|
38
38
|
end
|
39
39
|
Jeweler::GemcutterTasks.new
|
40
40
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/watirsplash.rb
CHANGED
data/lib/watirsplash/autoit.rb
CHANGED
@@ -23,7 +23,7 @@ class AutoItHelper
|
|
23
23
|
# activates window automatically and makes sure that the field's
|
24
24
|
# value got changed
|
25
25
|
def set_field(window_title, field_name, field_value)
|
26
|
-
wait_until
|
26
|
+
wait_until do
|
27
27
|
activate_window(window_title) &&
|
28
28
|
@@autoit.ControlFocus(window_title, "", field_name) == 1 &&
|
29
29
|
@@autoit.ControlSetText(window_title, "", field_name, field_value) == 1 &&
|
@@ -35,11 +35,11 @@ class AutoItHelper
|
|
35
35
|
# activates window automatically and makes sure that the click
|
36
36
|
# was successful
|
37
37
|
def click_button(window_title, button_name)
|
38
|
-
wait_until
|
38
|
+
wait_until do
|
39
39
|
activate_window(window_title) &&
|
40
40
|
@@autoit.ControlFocus(window_title, "", button_name) == 1 &&
|
41
41
|
@@autoit.ControlClick(window_title, "", button_name) == 1 &&
|
42
|
-
wait_until(3) {@@autoit.WinExists(window_title) == 0}
|
42
|
+
wait_until?(3) {@@autoit.WinExists(window_title) == 0}
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'spec/runner/formatter/html_formatter'
|
2
|
-
require '
|
2
|
+
require 'win32/screenshot'
|
3
3
|
require 'rmagick'
|
4
4
|
require 'pathname'
|
5
5
|
require 'fileutils'
|
@@ -71,11 +71,12 @@ module WatirSplash
|
|
71
71
|
def save_screenshot(description="Screenshot", hwnd=@browser.hwnd) # :nodoc:
|
72
72
|
begin
|
73
73
|
@browser.bring_to_front
|
74
|
-
width, height, blob
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
Win32::Screenshot.hwnd(hwnd) do |width, height, blob|
|
75
|
+
file_name = file_path("screenshot.png", description)
|
76
|
+
img = Magick::ImageList.new
|
77
|
+
img.from_blob(blob)
|
78
|
+
img.write(file_name)
|
79
|
+
end
|
79
80
|
rescue => e
|
80
81
|
$stderr.puts "saving of screenshot failed: #{e.message}"
|
81
82
|
$stderr.puts e.backtrace
|
data/lib/watirsplash/waiter.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
module WatirSplash
|
2
2
|
module Waiter
|
3
|
-
# waits until
|
3
|
+
# waits until specified condition is true and
|
4
4
|
# throws Watir::Exception::TimeOutException upon timeout
|
5
5
|
#
|
6
6
|
# examples:
|
7
|
-
# wait_until
|
8
|
-
# wait_until
|
9
|
-
def wait_until
|
7
|
+
# wait_until {text_field(:name => 'x').exists?} # waits until text field exists
|
8
|
+
# wait_until(5) {...} # waits maximum of 5 seconds for the condition to be true
|
9
|
+
def wait_until *arg
|
10
10
|
Watir::Waiter.wait_until(*arg) {yield}
|
11
11
|
end
|
12
12
|
|
13
|
-
# waits until
|
13
|
+
# waits until specified condition is true and
|
14
14
|
# returns false if timeout occurred, true otherwise
|
15
15
|
#
|
16
16
|
# examples:
|
17
|
-
# wait_until {text_field(:name => 'x').exists?} # waits until text field exists
|
18
|
-
# wait_until(5) {...} # waits maximum of 5 seconds condition to be true
|
19
|
-
def wait_until *arg
|
17
|
+
# wait_until? {text_field(:name => 'x').exists?} # waits until text field exists
|
18
|
+
# wait_until?(5) {...} # waits maximum of 5 seconds for the condition to be true
|
19
|
+
def wait_until? *arg
|
20
20
|
begin
|
21
|
-
wait_until
|
21
|
+
wait_until(*arg) {yield}
|
22
22
|
rescue Watir::Exception::TimeOutException
|
23
23
|
return false
|
24
24
|
end
|
data/spec/spec_helper_spec.rb
CHANGED
@@ -18,18 +18,18 @@ describe WatirSplash::SpecHelper do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "has wait_until" do
|
21
|
-
|
21
|
+
lambda {wait_until(0.5) {sleep 0.1; true}}.should_not raise_exception
|
22
|
+
lambda {wait_until(0.5) {sleep 0.1; false}}.should raise_exception(Watir::Exception::TimeOutException)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has wait_until?" do
|
26
|
+
result = wait_until? {sleep 0.1; true}
|
22
27
|
result.should be_true
|
23
28
|
|
24
|
-
result = wait_until(0.5) {sleep 0.1; false}
|
29
|
+
result = wait_until?(0.5) {sleep 0.1; false}
|
25
30
|
result.should be_false
|
26
31
|
end
|
27
32
|
|
28
|
-
it "has wait_until!" do
|
29
|
-
lambda {wait_until!(0.5) {sleep 0.1; true}}.should_not raise_exception
|
30
|
-
lambda {wait_until!(0.5) {sleep 0.1; false}}.should raise_exception(Watir::Exception::TimeOutException)
|
31
|
-
end
|
32
|
-
|
33
33
|
it "has file_path methods formatter" do
|
34
34
|
file_name = "blah.temp"
|
35
35
|
ext = File.extname(file_name)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jarmo Pertman
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-27 00:00:00 +03:00
|
18
18
|
default_executable: watirsplash
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -114,7 +114,9 @@ dependencies:
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
segments:
|
116
116
|
- 0
|
117
|
-
|
117
|
+
- 0
|
118
|
+
- 4
|
119
|
+
version: 0.0.4
|
118
120
|
type: :runtime
|
119
121
|
version_requirements: *id008
|
120
122
|
description: WatirSplash makes testing of web applications splashin' easy by combining best features of Watir, RSpec and Ruby!
|
@@ -143,7 +145,6 @@ files:
|
|
143
145
|
- lib/watirsplash/util.rb
|
144
146
|
- lib/watirsplash/waiter.rb
|
145
147
|
- lib/watirsplash/watir.rb
|
146
|
-
- lib/watirsplash/win32screenshot.rb
|
147
148
|
- spec/spec.opts
|
148
149
|
- spec/spec_helper_spec.rb
|
149
150
|
- spec/spec_match_array_spec.rb
|
@@ -166,7 +167,7 @@ licenses: []
|
|
166
167
|
post_install_message: |-
|
167
168
|
*************************
|
168
169
|
|
169
|
-
Thank you for installing WatirSplash 0.2.
|
170
|
+
Thank you for installing WatirSplash 0.2.1! Don't forget to take a look at README and History files!
|
170
171
|
|
171
172
|
Execute "watirsplash generate" under your project's directory to generate default project structure.
|
172
173
|
|
@@ -201,7 +202,7 @@ rubyforge_project:
|
|
201
202
|
rubygems_version: 1.3.6
|
202
203
|
signing_key:
|
203
204
|
specification_version: 3
|
204
|
-
summary: watirsplash 0.2.
|
205
|
+
summary: watirsplash 0.2.1
|
205
206
|
test_files:
|
206
207
|
- spec/spec_helper_spec.rb
|
207
208
|
- spec/spec_match_array_spec.rb
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module Win32
|
2
|
-
module Screenshot
|
3
|
-
|
4
|
-
# added patches by Tony Popiel for fixing the problem
|
5
|
-
# of failing to take a screenshot of every size of the window
|
6
|
-
# http://rubyforge.org/tracker/index.php?func=detail&aid=26216&group_id=2683&atid=10359
|
7
|
-
module_function
|
8
|
-
|
9
|
-
def capture(hScreenDC, x1, y1, x2, y2)
|
10
|
-
w = x2-x1
|
11
|
-
h = y2-y1
|
12
|
-
|
13
|
-
# Reserve some memory
|
14
|
-
hmemDC = createCompatibleDC(hScreenDC)
|
15
|
-
hmemBM = createCompatibleBitmap(hScreenDC, w, h)
|
16
|
-
selectObject(hmemDC, hmemBM)
|
17
|
-
bitBlt(hmemDC, 0, 0, w, h, hScreenDC, 0, 0, SRCCOPY)
|
18
|
-
# changed line
|
19
|
-
# hpxldata = globalAlloc(GMEM_FIXED, w * h * 3)
|
20
|
-
hpxldata = globalAlloc(GMEM_FIXED, ((w*h*3)+(w%4)*h))
|
21
|
-
lpvpxldata = globalLock(hpxldata)
|
22
|
-
|
23
|
-
# Bitmap header
|
24
|
-
# http://www.fortunecity.com/skyscraper/windows/364/bmpffrmt.html
|
25
|
-
bmInfo = [40, w, h, 1, 24, 0, 0, 0, 0, 0, 0, 0].pack('LLLSSLLLLLL').to_ptr
|
26
|
-
|
27
|
-
getDIBits(hmemDC, hmemBM, 0, h, lpvpxldata, bmInfo, DIB_RGB_COLORS)
|
28
|
-
|
29
|
-
bmFileHeader = [
|
30
|
-
19778,
|
31
|
-
# changed line
|
32
|
-
# (w * h * 3) + 40 + 14,
|
33
|
-
(w * h * 3) + (w%4)*h + 40 + 14,
|
34
|
-
0,
|
35
|
-
0,
|
36
|
-
54
|
37
|
-
].pack('SLSSL').to_ptr
|
38
|
-
|
39
|
-
# changed line
|
40
|
-
# data = bmFileHeader.to_s(14) + bmInfo.to_s(40) + lpvpxldata.to_s(w * h * 3)
|
41
|
-
data = bmFileHeader.to_s(14) + bmInfo.to_s(40) + lpvpxldata.to_s((w*h*3)+(w%4)*h)
|
42
|
-
|
43
|
-
globalUnlock(hpxldata)
|
44
|
-
globalFree(hpxldata)
|
45
|
-
deleteObject(hmemBM)
|
46
|
-
deleteDC(hmemDC)
|
47
|
-
releaseDC(0, hScreenDC)
|
48
|
-
|
49
|
-
return [w, h, data]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|