watirsplash 0.1.9 → 0.2.0
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 +11 -0
- data/README.rdoc +55 -23
- data/Rakefile +61 -11
- data/VERSION +1 -0
- data/bin/watirsplash +6 -6
- data/lib/watirsplash.rb +9 -6
- data/lib/watirsplash/generator.rb +55 -0
- data/lib/watirsplash/spec_helper.rb +0 -5
- data/lib/watirsplash/util.rb +11 -0
- data/lib/watirsplash/watir.rb +21 -8
- data/lib/watirsplash/win32screenshot.rb +52 -0
- data/spec/spec.opts +11 -0
- data/spec/spec_helper_spec.rb +4 -5
- data/spec/spec_match_array_spec.rb +1 -2
- data/spec/util_spec.rb +1 -2
- data/spec/watir_ie_spec.rb +13 -2
- data/spec/watir_table_row_spec.rb +3 -4
- data/spec/watir_table_spec.rb +4 -5
- data/templates/common/config.rb +2 -4
- data/templates/common/environment.rb +7 -9
- data/templates/common/lib/common_application_helper.rb +3 -3
- data/templates/project/config.rb +3 -1
- data/templates/project/environment.rb +10 -8
- data/templates/project/spec/dummy_spec.rb +4 -4
- data/templates/project/spec/spec.opts +11 -0
- metadata +28 -22
- data/lib/spec.opts +0 -5
- data/lib/watirsplash/runner.rb +0 -97
- data/lib/watirsplash/version.rb +0 -3
- data/templates/project/ide_runner.rb +0 -3
data/History.rdoc
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
=== Version 0.2.0 / 2010-05-03
|
2
|
+
|
3
|
+
PS! This version has some backwards incompatible changes!
|
4
|
+
|
5
|
+
* added max_depth parameter to Watir::Table#to_a and Watir::TableRow#to_a methods for avoiding too complex arrays if wanted
|
6
|
+
* watirsplash is not used to launch tests anymore - use regular RSpec's 'spec' command instead
|
7
|
+
* tests need to be inside of 'spec' directory, because spec.opts is responsible for loading every library
|
8
|
+
* you can launch tests with IDE by using -O spec.opts as a spec runner parameter
|
9
|
+
* Watir::Element#style returns current CSS style for element
|
10
|
+
* ui-test and ui-test-common project templates got changed
|
11
|
+
|
1
12
|
=== Version 0.1.9 / 2010-05-01
|
2
13
|
|
3
14
|
* Changed name of the library to WatirSplash due to name conflict
|
data/README.rdoc
CHANGED
@@ -5,8 +5,8 @@
|
|
5
5
|
|
6
6
|
== DESCRIPTION:
|
7
7
|
|
8
|
-
WatirSplash
|
9
|
-
It combines Watir (http://www.watir.com) for controlling the browser
|
8
|
+
WatirSplash makes browser-based testing in Ruby splashin' easy.
|
9
|
+
It combines Watir (http://www.watir.com) for controlling the browser and
|
10
10
|
RSpec (http://rspec.info) for testing framework. This powerful combination gives you
|
11
11
|
the ability to write easily well-maintained and easy-to-read specs (specifications in RSpec) so
|
12
12
|
you don't need to have any extra documentation for your applications.
|
@@ -17,23 +17,56 @@ testing right away!
|
|
17
17
|
|
18
18
|
== FEATURES:
|
19
19
|
|
20
|
-
* generate command for generating default project structure
|
21
|
-
* generate_common command for generating common
|
20
|
+
* generate command for generating default tests project structure
|
21
|
+
* generate_common command for generating a project structure for common functionality in your tests
|
22
22
|
* Browser will be opened and closed for each example group automatically
|
23
23
|
* You can use Watir method names directly without having to specify a browser object:
|
24
24
|
text_field(:name => "locator") # instead of @browser.text_field(:name => "locator")
|
25
25
|
* All needed libraries will be loaded and helper modules will be included automatically
|
26
|
-
* All JavaScript errors will be detected automatically
|
26
|
+
* All JavaScript errors will be detected and saved automatically
|
27
27
|
* Some additional methods to help using Watir (download_file, wait_until, wait_until! etc.)
|
28
|
+
* Some patches for different libraries which haven't made yet to the libraries themselves
|
28
29
|
|
29
30
|
* Custom html formatter for RSpec:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
- saves screenshot of the browser window
|
32
|
+
- saves html of the page
|
33
|
+
- saves all the files created/downloaded during the example and shows them on the report
|
34
|
+
- automatically archives test results for later reviewing
|
34
35
|
|
35
36
|
== SYNOPSIS:
|
36
37
|
|
38
|
+
Without WatirSplash:
|
39
|
+
require 'watir'
|
40
|
+
require 'spec'
|
41
|
+
|
42
|
+
describe "Google" do
|
43
|
+
before :all do
|
44
|
+
@browser = Watir::Browser.new
|
45
|
+
@browser.maximize
|
46
|
+
@browser.goto "http://google.com"
|
47
|
+
@browser.url.should =~ /google/
|
48
|
+
end
|
49
|
+
|
50
|
+
it "has search field" do
|
51
|
+
@browser.text_field = text_field(:name => "q")
|
52
|
+
@browser.text_field.should exist
|
53
|
+
@browser.text_field.should be_visible
|
54
|
+
end
|
55
|
+
|
56
|
+
it "performs search" do
|
57
|
+
@browser.text_field(:name => "q").set "Bing"
|
58
|
+
@browser.button(:name => "btnG").click
|
59
|
+
@browser.text.should include("Bing")
|
60
|
+
end
|
61
|
+
|
62
|
+
after :all do
|
63
|
+
@browser.close
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
With WatirSplash:
|
37
70
|
describe "Google" do
|
38
71
|
before :all do
|
39
72
|
goto "http://google.com"
|
@@ -53,7 +86,7 @@ testing right away!
|
|
53
86
|
end
|
54
87
|
end
|
55
88
|
|
56
|
-
C:\project\ui-test>
|
89
|
+
C:\project\ui-test>spec spec\google_spec.rb
|
57
90
|
Results will be saved into the directory C:/project/ui-test/results
|
58
91
|
Google
|
59
92
|
has search field
|
@@ -68,11 +101,8 @@ testing right away!
|
|
68
101
|
* install Ruby 1.8.6:
|
69
102
|
http://rubyinstaller.org/
|
70
103
|
|
71
|
-
* install ImageMagick with rmagick-win32 for
|
104
|
+
* install ImageMagick with rmagick-win32 for saving the screenshots in PNG format:
|
72
105
|
http://rubyforge.org/frs/?group_id=12&release_id=42049
|
73
|
-
|
74
|
-
* update RubyGems:
|
75
|
-
gem update --system
|
76
106
|
|
77
107
|
* install WatirSplash:
|
78
108
|
gem install watirsplash
|
@@ -105,17 +135,18 @@ The contents of that ui-test directory will be:
|
|
105
135
|
ui-test\application_helper.rb
|
106
136
|
ui-test\config.rb
|
107
137
|
ui-test\environment.rb
|
108
|
-
ui-test\ide_runner.rb
|
109
138
|
|
110
139
|
ui-test\spec
|
111
140
|
ui-test\spec\dummy_spec.rb
|
141
|
+
ui-test\spec\spec.opts
|
112
142
|
|
113
143
|
Just check out all the files to see some example code and comments in it and execute dummy_spec.rb
|
114
144
|
to verify that everything works correctly:
|
115
|
-
|
116
|
-
|
117
|
-
You
|
118
|
-
|
145
|
+
spec spec\dummy_spec.rb
|
146
|
+
|
147
|
+
You have to create your tests under spec directory so RSpec would load spec.opts automatically.
|
148
|
+
You can have whatever directory structure under this directory just make sure that
|
149
|
+
all test files have _spec.rb in the end of their filename (if using default RSpec options).
|
119
150
|
|
120
151
|
== USAGE FOR MULTIPLE PROJECTS:
|
121
152
|
|
@@ -138,7 +169,7 @@ to generate ui-test-common directory:
|
|
138
169
|
Done
|
139
170
|
|
140
171
|
It has a structure of:
|
141
|
-
C:\
|
172
|
+
C:\ui-test-common
|
142
173
|
└───lib
|
143
174
|
|
144
175
|
ui-test-common\config.rb
|
@@ -147,12 +178,12 @@ It has a structure of:
|
|
147
178
|
ui-test-common\lib\common_application_helper.rb
|
148
179
|
|
149
180
|
In environment.rb under project/ui-test you shall add common functionality to your project.
|
150
|
-
|
181
|
+
Uncomment the following line:
|
151
182
|
WatirSplash::Util.load_common
|
152
183
|
|
153
184
|
This gives you by default the access to every method in ui-test-common/lib/common_application_helper.rb
|
154
185
|
|
155
|
-
Now, in ui-test-common/config.rb change the URL to your hostname and in config.rb
|
186
|
+
Now, in ui-test-common/config.rb change the URL to your hostname and in project's config.rb:
|
156
187
|
URL = Config.full_url("/relative_path")
|
157
188
|
|
158
189
|
This gives you the ability to have host and port written only in one place.
|
@@ -168,4 +199,5 @@ If you see the following error message when running watirsplash:
|
|
168
199
|
R6034. An application has made an attempt to load the C runtime library incorrectly.
|
169
200
|
|
170
201
|
Solution:
|
171
|
-
|
202
|
+
This is caused by ImageMagick.
|
203
|
+
Install Microsoft Visual C++ 2008 SP1 Redistributable Package to solve the problem.
|
data/Rakefile
CHANGED
@@ -1,16 +1,66 @@
|
|
1
|
+
require 'rubygems'
|
1
2
|
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
version = File.read("VERSION").strip
|
8
|
+
gem.name = "watirsplash"
|
9
|
+
gem.summary = %Q{watirsplash #{version}}
|
10
|
+
gem.description = %q{WatirSplash makes testing of web applications splashin' easy by combining best features of Watir, RSpec and Ruby!}
|
11
|
+
gem.email = "jarmo.p@gmail.com"
|
12
|
+
gem.homepage = "http://github.com/jarmo/WatirSplash"
|
13
|
+
gem.authors = ["Jarmo Pertman"]
|
14
|
+
gem.executables = ["watirsplash"]
|
15
|
+
gem.extra_rdoc_files = ["README.rdoc", "History.rdoc", "License.txt"]
|
16
|
+
gem.rdoc_options << "--main" << "README.rdoc" <<
|
17
|
+
"--template" << "hanna" <<
|
18
|
+
"--inline-source" << "--format=html"
|
19
|
+
ignored_files = File.readlines(".gitignore").map {|l| l.strip.gsub("*", "")}
|
20
|
+
ignored_files << ".gitignore" << ".gemspec"
|
21
|
+
gem.files = Dir.glob("**/*").delete_if {|f| f =~ Regexp.union(*ignored_files)}
|
22
|
+
gem.post_install_message = %Q{#{"*"*25}
|
23
|
+
|
24
|
+
Thank you for installing WatirSplash #{version}! Don't forget to take a look at README and History files!
|
25
|
+
|
26
|
+
Execute "watirsplash generate" under your project's directory to generate default project structure.
|
27
|
+
|
28
|
+
#{"*"*25}}
|
29
|
+
|
30
|
+
gem.add_dependency("watir", ">=1.6.5")
|
31
|
+
gem.add_dependency("rspec", ">=1.3.0")
|
32
|
+
gem.add_dependency("diff-lcs")
|
33
|
+
gem.add_dependency("require_all")
|
34
|
+
gem.add_dependency("rmagick")
|
35
|
+
gem.add_dependency("syntax")
|
36
|
+
gem.add_dependency("win32console")
|
37
|
+
gem.add_dependency("win32screenshot")
|
38
|
+
end
|
39
|
+
Jeweler::GemcutterTasks.new
|
40
|
+
rescue LoadError
|
41
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
42
|
+
end
|
43
|
+
|
2
44
|
require 'spec/rake/spectask'
|
45
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
46
|
+
spec.libs << 'lib' << 'spec'
|
47
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
48
|
+
end
|
3
49
|
|
4
|
-
Spec::Rake::SpecTask.new(:rcov) do |
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
t.rcov_opts << '--sort coverage --text-summary --aggregate coverage.data'
|
50
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
51
|
+
spec.libs << 'lib' << 'spec'
|
52
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
53
|
+
spec.rcov = true
|
9
54
|
end
|
10
55
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
56
|
+
task :default => :spec
|
57
|
+
|
58
|
+
require 'rake/rdoctask'
|
59
|
+
Rake::RDocTask.new do |rdoc|
|
60
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
61
|
+
|
62
|
+
rdoc.rdoc_dir = 'rdoc'
|
63
|
+
rdoc.title = "my-testing-library #{version}"
|
64
|
+
rdoc.rdoc_files.include('README*')
|
65
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
66
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/bin/watirsplash
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
watirsplash_dir = File.expand_path(File.join(File.dirname(__FILE__), '
|
2
|
+
watirsplash_dir = File.expand_path(File.join(File.dirname(__FILE__), '../lib'))
|
3
3
|
$LOAD_PATH.unshift(watirsplash_dir) unless $LOAD_PATH.include?(watirsplash_dir)
|
4
|
-
require 'watirsplash/
|
4
|
+
require 'watirsplash/generator'
|
5
5
|
|
6
|
-
if ARGV.size == 1 && ::WatirSplash::
|
7
|
-
exit ::WatirSplash::
|
6
|
+
if ARGV.size == 1 && ::WatirSplash::Generator.respond_to?(ARGV[0])
|
7
|
+
exit ::WatirSplash::Generator.send(ARGV[0])
|
8
8
|
else
|
9
|
-
exit ::WatirSplash::
|
10
|
-
end
|
9
|
+
exit ::WatirSplash::Generator.help
|
10
|
+
end
|
data/lib/watirsplash.rb
CHANGED
@@ -2,10 +2,13 @@ require "rubygems"
|
|
2
2
|
require "require_all"
|
3
3
|
require "spec"
|
4
4
|
require "watir"
|
5
|
-
require "
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
require "win32screenshot"
|
6
|
+
require_rel "watirsplash/win32screenshot"
|
7
|
+
require_rel "watirsplash/waiter"
|
8
|
+
require_rel "watirsplash/spec_helper"
|
9
|
+
require_rel "watirsplash/spec"
|
10
|
+
require_rel "watirsplash/watir"
|
11
|
+
require_rel "watirsplash/autoit"
|
12
|
+
require_rel "watirsplash/util"
|
13
|
+
WatirSplash::Util.load_environment
|
11
14
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module WatirSplash
|
2
|
+
|
3
|
+
# WatirSplash Generator class is responsible for:
|
4
|
+
# * generating directory structures for projects
|
5
|
+
class Generator
|
6
|
+
@@template_directory = File.join(File.dirname(__FILE__), "../../templates/")
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
# Generates ui-test directory structure for project
|
11
|
+
def generate
|
12
|
+
ui_test_dir = File.join(Dir.pwd, "ui-test")
|
13
|
+
puts "Creating WatirSplash directory structure to #{ui_test_dir}..."
|
14
|
+
require "fileutils"
|
15
|
+
FileUtils.cp_r File.join(@@template_directory, "project/."), ui_test_dir
|
16
|
+
puts "Done"
|
17
|
+
return 0
|
18
|
+
rescue => e
|
19
|
+
puts "Failed:"
|
20
|
+
puts e.message
|
21
|
+
return -1
|
22
|
+
end
|
23
|
+
|
24
|
+
# Generates ui-test-common directory structure
|
25
|
+
def generate_common
|
26
|
+
common_dir = File.join(Dir.pwd, "ui-test-common")
|
27
|
+
puts "Creating WatirSplash ui-test-common directory structure to #{common_dir}..."
|
28
|
+
require "fileutils"
|
29
|
+
FileUtils.cp_r File.join(@@template_directory, "common/."), common_dir
|
30
|
+
puts "Done"
|
31
|
+
return 0
|
32
|
+
rescue => e
|
33
|
+
puts "Failed:"
|
34
|
+
puts e.message
|
35
|
+
return -1
|
36
|
+
end
|
37
|
+
|
38
|
+
# Shows help
|
39
|
+
def help
|
40
|
+
puts %Q{WatirSplash:
|
41
|
+
Usage: watirsplash (COMMAND|FILE(:LINE)?|DIRECTORY|GLOB)+ [options]
|
42
|
+
Commands:
|
43
|
+
* generate - generate default directory structure for new project
|
44
|
+
* generate_common - generate common project directory structure
|
45
|
+
* help - show this help
|
46
|
+
* --help - show RSpec's help
|
47
|
+
|
48
|
+
All other commands/options will be passed to RSpec directly.}
|
49
|
+
|
50
|
+
return 1
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -46,11 +46,6 @@ module WatirSplash
|
|
46
46
|
# be shown on the report upon test failure.
|
47
47
|
def file_path(file_name, description=nil)
|
48
48
|
formatter.file_path(file_name, description)
|
49
|
-
rescue
|
50
|
-
extension = File.extname(file_name)
|
51
|
-
basename = File.basename(file_name, extension)
|
52
|
-
file_path = File.join(Dir.pwd, "#{basename}_#{Time.now.strftime("%H%M%S")}#{extension}")
|
53
|
-
file_path
|
54
49
|
end
|
55
50
|
|
56
51
|
# returns native file path
|
data/lib/watirsplash/util.rb
CHANGED
@@ -15,6 +15,17 @@ module WatirSplash
|
|
15
15
|
require File.join(dir, "environment.rb")
|
16
16
|
end
|
17
17
|
|
18
|
+
def load_environment
|
19
|
+
env_file = File.join(Dir.pwd, "environment.rb")
|
20
|
+
if File.exists?(env_file)
|
21
|
+
require env_file
|
22
|
+
else
|
23
|
+
Dir.chdir("..") do
|
24
|
+
load_environment if Dir.entries(Dir.pwd).include?("..")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
18
29
|
private
|
19
30
|
|
20
31
|
def common_dir
|
data/lib/watirsplash/watir.rb
CHANGED
@@ -82,6 +82,16 @@ module Watir
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
class Element #:nodoc:all
|
86
|
+
def_wrap_guard :currentstyle
|
87
|
+
|
88
|
+
# returns current style instead of inline style
|
89
|
+
# http://msdn.microsoft.com/en-us/library/ms535231(VS.85).aspx
|
90
|
+
def style
|
91
|
+
currentstyle
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
85
95
|
module PageContainer #:nodoc:all
|
86
96
|
# patch for .click_no_wait
|
87
97
|
def eval_in_spawned_process(command)
|
@@ -97,14 +107,15 @@ module Watir
|
|
97
107
|
|
98
108
|
class Table < Element
|
99
109
|
|
100
|
-
# This method returns multi-dimensional array of the
|
110
|
+
# This method returns multi-dimensional array of the cell texts in table.
|
101
111
|
#
|
102
|
-
#
|
103
|
-
|
112
|
+
# Works with tr, th, td elements, colspan, rowspan and nested tables.
|
113
|
+
# Takes an optional parameter *max_depth*, which is by default 1
|
114
|
+
def to_a(max_depth=1)
|
104
115
|
assert_exists
|
105
116
|
y = []
|
106
117
|
@o.rows.each do |row|
|
107
|
-
y << TableRow.new(@container, :ole_object, row).to_a
|
118
|
+
y << TableRow.new(@container, :ole_object, row).to_a(max_depth)
|
108
119
|
end
|
109
120
|
y
|
110
121
|
end
|
@@ -112,10 +123,11 @@ module Watir
|
|
112
123
|
|
113
124
|
class TableRow < Element
|
114
125
|
|
115
|
-
# This method returns (multi-dimensional) array of the
|
126
|
+
# This method returns (multi-dimensional) array of the cell texts in table's row.
|
116
127
|
#
|
117
|
-
#
|
118
|
-
|
128
|
+
# Works with th, td elements, colspan, rowspan and nested tables.
|
129
|
+
# Takes an optional parameter *max_depth*, which is by default 1
|
130
|
+
def to_a(max_depth=1)
|
119
131
|
assert_exists
|
120
132
|
y = []
|
121
133
|
@o.cells.each do |cell|
|
@@ -123,7 +135,8 @@ module Watir
|
|
123
135
|
inner_tables.each do |inner_table|
|
124
136
|
# make sure that the inner table is directly child for this cell
|
125
137
|
if inner_table?(cell, inner_table)
|
126
|
-
|
138
|
+
max_depth -= 1
|
139
|
+
y << Table.new(@container, :ole_object, inner_table).to_a(max_depth) if max_depth >= 1
|
127
140
|
end
|
128
141
|
end
|
129
142
|
|
@@ -0,0 +1,52 @@
|
|
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
|
data/spec/spec.opts
ADDED
data/spec/spec_helper_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require "
|
2
|
-
require "spec/autorun"
|
1
|
+
require "spec"
|
3
2
|
|
4
3
|
describe WatirSplash::SpecHelper do
|
5
4
|
|
@@ -31,15 +30,15 @@ describe WatirSplash::SpecHelper do
|
|
31
30
|
lambda {wait_until!(0.5) {sleep 0.1; false}}.should raise_exception(Watir::Exception::TimeOutException)
|
32
31
|
end
|
33
32
|
|
34
|
-
it "has file_path methods
|
33
|
+
it "has file_path methods formatter" do
|
35
34
|
file_name = "blah.temp"
|
36
35
|
ext = File.extname(file_name)
|
37
36
|
base = File.basename(file_name, ext)
|
38
|
-
expected_path = File.join(Dir.pwd, "
|
37
|
+
expected_path = File.join(Dir.pwd, "results/files/#{base}_.*#{ext}")
|
39
38
|
|
40
39
|
file_path(file_name).should =~ Regexp.new(expected_path)
|
41
40
|
expected_path = expected_path.gsub("/", "\\")
|
42
|
-
native_file_path(file_path(file_name)).should =~ Regexp.new(Regexp.escape(expected_path).gsub("
|
41
|
+
native_file_path(file_path(file_name)).should =~ Regexp.new(Regexp.escape(expected_path).gsub("\\.\\*", ".*"))
|
43
42
|
end
|
44
43
|
|
45
44
|
it "has download_file method" do
|
data/spec/util_spec.rb
CHANGED
data/spec/watir_ie_spec.rb
CHANGED
@@ -1,8 +1,19 @@
|
|
1
|
-
require "
|
2
|
-
require "spec/autorun"
|
1
|
+
require "spec"
|
3
2
|
|
4
3
|
describe Watir::IE do
|
5
4
|
|
5
|
+
it "uses currentStyle method to show computed style" do
|
6
|
+
goto "http://dl.dropbox.com/u/2731643/misc/tables.html"
|
7
|
+
t = table(:id => "normal")
|
8
|
+
normal_cell = t[1][1]
|
9
|
+
normal_cell.text.should == "1"
|
10
|
+
normal_cell.style.color.should == "#000000"
|
11
|
+
|
12
|
+
red_cell = t.cell(:class => "reddish")
|
13
|
+
red_cell.text.should == "9"
|
14
|
+
red_cell.style.color.should == "red"
|
15
|
+
end
|
16
|
+
|
6
17
|
it "closes the browser even when Watir::IE#run_error_checks throws an exception" do
|
7
18
|
@browser.add_checker lambda {raise "let's fail IE#wait in IE#close"}
|
8
19
|
@browser.should exist
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require "
|
2
|
-
require "spec/autorun"
|
1
|
+
require "spec"
|
3
2
|
|
4
3
|
describe Watir::TableRow do
|
5
4
|
include WatirSplash::SpecHelper
|
@@ -20,12 +19,12 @@ describe Watir::TableRow do
|
|
20
19
|
|
21
20
|
it "#to_a works with nested tables" do
|
22
21
|
second_row = table(:id => "nested")[2]
|
23
|
-
second_row.to_a.should == [[["11", "12"], ["13","14"]], "3"]
|
22
|
+
second_row.to_a(2).should == [[["11", "12"], ["13","14"]], "3"]
|
24
23
|
end
|
25
24
|
|
26
25
|
it "#to_a works with deep-nested tables" do
|
27
26
|
second_row = table(:id => "deepnested")[2]
|
28
|
-
second_row.to_a.should == [[["11", "12"],
|
27
|
+
second_row.to_a(3).should == [[["11", "12"],
|
29
28
|
[[["404", "405"], ["406", "407"]], "14"]], "3"]
|
30
29
|
end
|
31
30
|
|
data/spec/watir_table_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require "
|
2
|
-
require "spec/autorun"
|
1
|
+
require "spec"
|
3
2
|
|
4
3
|
describe Watir::Table do
|
5
4
|
include WatirSplash::SpecHelper
|
@@ -33,7 +32,7 @@ describe Watir::Table do
|
|
33
32
|
[[["11", "12"],
|
34
33
|
["13", "14"]], "3"]
|
35
34
|
]
|
36
|
-
table(:id => "nested").to_a.should == expected_table
|
35
|
+
table(:id => "nested").to_a(2).should == expected_table
|
37
36
|
end
|
38
37
|
|
39
38
|
it "#to_a works with nested table with non-direct child" do
|
@@ -44,7 +43,7 @@ describe Watir::Table do
|
|
44
43
|
["13", "14"]], "3"]
|
45
44
|
]
|
46
45
|
|
47
|
-
table(:id => "nestednondirectchild").to_a.should == expected_table
|
46
|
+
table(:id => "nestednondirectchild").to_a(2).should == expected_table
|
48
47
|
end
|
49
48
|
|
50
49
|
it "#to_a works with deep-nested tables" do
|
@@ -55,7 +54,7 @@ describe Watir::Table do
|
|
55
54
|
[[["404", "405"],
|
56
55
|
["406", "407"]], "14"]], "3"]
|
57
56
|
]
|
58
|
-
table(:id => "deepnested").to_a.should == expected_table
|
57
|
+
table(:id => "deepnested").to_a(3).should == expected_table
|
59
58
|
end
|
60
59
|
|
61
60
|
it "#to_a works with colspan" do
|
data/templates/common/config.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
=begin
|
2
2
|
Global configuration constants
|
3
|
-
For example, you can use the URL constant below from your projects like this:
|
4
|
-
|
5
|
-
In your projects' config.rb:
|
3
|
+
For example, you can use the URL constant below from your projects' config.rb like this:
|
6
4
|
|
7
5
|
module Config
|
8
6
|
module Application
|
@@ -25,4 +23,4 @@ end
|
|
25
23
|
|
26
24
|
Spec::Runner.configure do |config|
|
27
25
|
config.include(CommonApplicationHelper)
|
28
|
-
end
|
26
|
+
end
|
@@ -1,17 +1,15 @@
|
|
1
1
|
=begin
|
2
|
-
|
3
|
-
|
2
|
+
You have to load this file from your projects' environment.rb, which
|
3
|
+
would like to use common functionality.
|
4
|
+
|
5
|
+
Use the following code to do it automatically:
|
4
6
|
WatirSplash::Util.load_common
|
5
7
|
|
6
|
-
|
8
|
+
Add all your require statements into this file to avoid unnecessary
|
7
9
|
code in your other projects' files
|
8
10
|
|
9
|
-
|
11
|
+
By default everything in lib directory will be loaded
|
10
12
|
=end
|
11
13
|
|
12
|
-
|
13
|
-
filtered_ruby_files = Dir.glob(local_dir).delete_if do |file|
|
14
|
-
File.directory?(file) || File.basename(file) =~ /(config|_spec)\.rb$/
|
15
|
-
end
|
16
|
-
require_all filtered_ruby_files
|
14
|
+
require_rel "lib/"
|
17
15
|
require_rel "config.rb"
|
@@ -1,9 +1,9 @@
|
|
1
|
-
#
|
2
|
-
# use within your specs in different projects
|
1
|
+
# You can create under this directory common libraries/helpers/methods which you would
|
2
|
+
# like to use within your specs in different projects
|
3
3
|
|
4
4
|
module CommonApplicationHelper
|
5
5
|
|
6
|
-
#
|
6
|
+
# You can use methods declared in this module inside of your it-blocks
|
7
7
|
# it "does something" do
|
8
8
|
# new_global_method.should == "it just works"
|
9
9
|
# end
|
data/templates/project/config.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
module Config
|
3
3
|
module Application
|
4
4
|
# URL, which will be opened by every test
|
5
|
-
#
|
5
|
+
#
|
6
|
+
# Replace it with the URL of your application under test
|
6
7
|
# or if ui-test-common is used then
|
7
8
|
# URL = Config.full_url("/relative/url/index.html")
|
8
9
|
URL = "about:blank"
|
@@ -12,6 +13,7 @@ end
|
|
12
13
|
# A global configuration for specs in this project, which will include by default
|
13
14
|
# a ApplicationHelper module and open Config::Application::URL with
|
14
15
|
# the browser.
|
16
|
+
#
|
15
17
|
# You can read more about RSpec-s before and after syntax from:
|
16
18
|
# http://rspec.info/documentation/before_and_after.html
|
17
19
|
Spec::Runner.configure do |config|
|
@@ -1,13 +1,15 @@
|
|
1
|
-
#
|
1
|
+
# Add all your require statements into this file to avoid unnecessary
|
2
2
|
# code in your spec files
|
3
3
|
|
4
|
-
#
|
4
|
+
# Uncomment following line to load functionality from ui-test-common
|
5
5
|
# WatirSplash::Util.load_common
|
6
6
|
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
# By default everything, which is not a spec file, will be loaded from spec directory
|
8
|
+
# and it's subdirectories
|
9
|
+
spec_dir = File.join(File.dirname(__FILE__), "spec/**/*.rb")
|
10
|
+
filtered_spec_files = Dir.glob(spec_dir).delete_if do |file|
|
11
|
+
File.directory?(file) || File.basename(file) =~ /.*spec\.rb$/
|
11
12
|
end
|
12
|
-
|
13
|
-
require_rel "config.rb"
|
13
|
+
require_rel filtered_spec_files
|
14
|
+
require_rel "config.rb"
|
15
|
+
require_rel "application_helper.rb"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# This is a fully working spec file which you can run to see if
|
2
2
|
# your configuration is correct and everything is working as expected
|
3
3
|
|
4
4
|
describe "WatirSplash" do
|
@@ -10,9 +10,9 @@ describe "WatirSplash" do
|
|
10
10
|
it "has easy access to ApplicationHelper methods" do
|
11
11
|
# ApplicationHelper#helper_method_one will be executed
|
12
12
|
helper_method_one.should == "one"
|
13
|
-
# ApplicationHelper#has_second_method? will be
|
13
|
+
# ApplicationHelper#has_second_method? will be executed
|
14
14
|
should have_second_method
|
15
|
-
# ApplicationHelper#correct? method will be
|
15
|
+
# ApplicationHelper#correct? method will be executed
|
16
16
|
should_not be_correct
|
17
17
|
end
|
18
18
|
|
@@ -34,7 +34,7 @@ describe "WatirSplash" do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
it "has
|
37
|
+
it "has access to global methods after generate_common command has been used" do
|
38
38
|
pending "it fails as long as there's not executed 'watirsplash generate_common' command
|
39
39
|
and ui-test-common is not loaded by this project" do
|
40
40
|
new_global_method.should == "it just works"
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jarmo Pertman
|
@@ -14,8 +14,8 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
18
|
-
default_executable:
|
17
|
+
date: 2010-05-04 00:00:00 +03:00
|
18
|
+
default_executable: watirsplash
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: watir
|
@@ -117,34 +117,34 @@ dependencies:
|
|
117
117
|
version: "0"
|
118
118
|
type: :runtime
|
119
119
|
version_requirements: *id008
|
120
|
-
description:
|
121
|
-
email:
|
122
|
-
- jarmo.p@gmail.com
|
120
|
+
description: WatirSplash makes testing of web applications splashin' easy by combining best features of Watir, RSpec and Ruby!
|
121
|
+
email: jarmo.p@gmail.com
|
123
122
|
executables:
|
124
123
|
- watirsplash
|
125
124
|
extensions: []
|
126
125
|
|
127
126
|
extra_rdoc_files:
|
128
|
-
- README.rdoc
|
129
127
|
- History.rdoc
|
130
128
|
- License.txt
|
129
|
+
- README.rdoc
|
131
130
|
files:
|
132
|
-
- bin/watirsplash
|
133
131
|
- History.rdoc
|
134
|
-
-
|
132
|
+
- License.txt
|
133
|
+
- README.rdoc
|
134
|
+
- Rakefile
|
135
|
+
- VERSION
|
136
|
+
- bin/watirsplash
|
137
|
+
- lib/watirsplash.rb
|
135
138
|
- lib/watirsplash/autoit.rb
|
139
|
+
- lib/watirsplash/generator.rb
|
136
140
|
- lib/watirsplash/html_formatter.rb
|
137
|
-
- lib/watirsplash/runner.rb
|
138
141
|
- lib/watirsplash/spec.rb
|
139
142
|
- lib/watirsplash/spec_helper.rb
|
140
143
|
- lib/watirsplash/util.rb
|
141
|
-
- lib/watirsplash/version.rb
|
142
144
|
- lib/watirsplash/waiter.rb
|
143
145
|
- lib/watirsplash/watir.rb
|
144
|
-
- lib/watirsplash.rb
|
145
|
-
-
|
146
|
-
- Rakefile
|
147
|
-
- README.rdoc
|
146
|
+
- lib/watirsplash/win32screenshot.rb
|
147
|
+
- spec/spec.opts
|
148
148
|
- spec/spec_helper_spec.rb
|
149
149
|
- spec/spec_match_array_spec.rb
|
150
150
|
- spec/util_spec.rb
|
@@ -157,8 +157,8 @@ files:
|
|
157
157
|
- templates/project/application_helper.rb
|
158
158
|
- templates/project/config.rb
|
159
159
|
- templates/project/environment.rb
|
160
|
-
- templates/project/ide_runner.rb
|
161
160
|
- templates/project/spec/dummy_spec.rb
|
161
|
+
- templates/project/spec/spec.opts
|
162
162
|
has_rdoc: true
|
163
163
|
homepage: http://github.com/jarmo/WatirSplash
|
164
164
|
licenses: []
|
@@ -166,12 +166,13 @@ licenses: []
|
|
166
166
|
post_install_message: |-
|
167
167
|
*************************
|
168
168
|
|
169
|
-
Thank you for installing WatirSplash 0.
|
169
|
+
Thank you for installing WatirSplash 0.2.0! Don't forget to take a look at README and History files!
|
170
170
|
|
171
171
|
Execute "watirsplash generate" under your project's directory to generate default project structure.
|
172
172
|
|
173
173
|
*************************
|
174
174
|
rdoc_options:
|
175
|
+
- --charset=UTF-8
|
175
176
|
- --main
|
176
177
|
- README.rdoc
|
177
178
|
- --template
|
@@ -200,6 +201,11 @@ rubyforge_project:
|
|
200
201
|
rubygems_version: 1.3.6
|
201
202
|
signing_key:
|
202
203
|
specification_version: 3
|
203
|
-
summary: watirsplash 0.
|
204
|
-
test_files:
|
205
|
-
|
204
|
+
summary: watirsplash 0.2.0
|
205
|
+
test_files:
|
206
|
+
- spec/spec_helper_spec.rb
|
207
|
+
- spec/spec_match_array_spec.rb
|
208
|
+
- spec/util_spec.rb
|
209
|
+
- spec/watir_ie_spec.rb
|
210
|
+
- spec/watir_table_row_spec.rb
|
211
|
+
- spec/watir_table_spec.rb
|
data/lib/watirsplash/runner.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
module WatirSplash
|
2
|
-
|
3
|
-
# WatirSplash runner class is responsible for:
|
4
|
-
# * generating directory structures for projects
|
5
|
-
# * starting RSpec with specified settings
|
6
|
-
class Runner
|
7
|
-
@@template_directory = File.join(File.dirname(__FILE__), "../../templates/")
|
8
|
-
|
9
|
-
class << self
|
10
|
-
|
11
|
-
# Run RSpec with custom settings
|
12
|
-
# * loads spec.opts from project's directory if exists
|
13
|
-
# * loads environment.rb from project's directory if exists
|
14
|
-
# * loads custom Formatter
|
15
|
-
def run
|
16
|
-
unless ARGV.empty?
|
17
|
-
require "watirsplash"
|
18
|
-
load_formatter
|
19
|
-
load_options
|
20
|
-
load_project_env
|
21
|
-
else
|
22
|
-
return help
|
23
|
-
end
|
24
|
-
|
25
|
-
::Spec::Runner::CommandLine.run
|
26
|
-
end
|
27
|
-
|
28
|
-
# Generates ui-test project structure for project
|
29
|
-
def generate
|
30
|
-
ui_test_dir = File.join(Dir.pwd, "ui-test")
|
31
|
-
puts "Creating WatirSplash project directory structure to #{ui_test_dir}..."
|
32
|
-
require "fileutils"
|
33
|
-
FileUtils.cp_r File.join(@@template_directory, "project/."), ui_test_dir
|
34
|
-
puts "Done"
|
35
|
-
return 0
|
36
|
-
rescue => e
|
37
|
-
puts "Failed:"
|
38
|
-
puts e.message
|
39
|
-
return -1
|
40
|
-
end
|
41
|
-
|
42
|
-
# Generates ui-test-common directory structure
|
43
|
-
def generate_common
|
44
|
-
common_dir = File.join(Dir.pwd, "ui-test-common")
|
45
|
-
puts "Creating WatirSplash common project directory structure to #{common_dir}..."
|
46
|
-
require "fileutils"
|
47
|
-
FileUtils.cp_r File.join(@@template_directory, "common/."), common_dir
|
48
|
-
puts "Done"
|
49
|
-
return 0
|
50
|
-
rescue => e
|
51
|
-
puts "Failed:"
|
52
|
-
puts e.message
|
53
|
-
return -1
|
54
|
-
end
|
55
|
-
|
56
|
-
# Shows help
|
57
|
-
def help
|
58
|
-
puts %Q{WatirSplash:
|
59
|
-
Usage: watirsplash (COMMAND|FILE(:LINE)?|DIRECTORY|GLOB)+ [options]
|
60
|
-
Commands:
|
61
|
-
* generate - generate default directory structure for new project
|
62
|
-
* generate_common - generate common project directory structure
|
63
|
-
* help - show this help
|
64
|
-
* --help - show RSpec's help
|
65
|
-
|
66
|
-
All other commands/options will be passed to RSpec directly.}
|
67
|
-
|
68
|
-
return 1
|
69
|
-
end
|
70
|
-
|
71
|
-
private
|
72
|
-
|
73
|
-
def load_formatter
|
74
|
-
ARGV << "--require" << "watirsplash/html_formatter.rb"
|
75
|
-
ARGV << "--format" << "WatirSplash::HtmlFormatter:#{File.join(Dir.pwd, "results/index.html")}"
|
76
|
-
end
|
77
|
-
|
78
|
-
def load_options
|
79
|
-
ARGV << "--options"
|
80
|
-
project_spec_opts = File.join(Dir.pwd, "spec.opts")
|
81
|
-
if File.exists?(project_spec_opts)
|
82
|
-
ARGV << project_spec_opts
|
83
|
-
else
|
84
|
-
ARGV << "#{File.join(File.dirname(__FILE__), "../spec.opts")}"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def load_project_env
|
89
|
-
project_env_file = File.join(Dir.pwd, "environment.rb")
|
90
|
-
if File.exists?(project_env_file)
|
91
|
-
ARGV << "--require" << project_env_file
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
data/lib/watirsplash/version.rb
DELETED