watirsplash 1.4.3 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.rspec +2 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +88 -0
- data/README.rdoc +87 -63
- data/Rakefile +3 -41
- data/lib/watirsplash.rb +2 -2
- data/lib/watirsplash/browser.rb +3 -1
- data/lib/watirsplash/cli.rb +22 -26
- data/lib/watirsplash/frameworks/firewatir.rb +1 -1
- data/lib/watirsplash/frameworks/helper.rb +2 -16
- data/lib/watirsplash/frameworks/watir-webdriver.rb +1 -1
- data/lib/watirsplash/frameworks/watir-webdriver/chrome.rb +3 -1
- data/lib/watirsplash/frameworks/watir-webdriver/firefox.rb +3 -1
- data/lib/watirsplash/frameworks/watir-webdriver/ie.rb +3 -1
- data/lib/watirsplash/frameworks/watir.rb +1 -3
- data/lib/watirsplash/generators/helper.rb +15 -0
- data/lib/watirsplash/generators/new_project.rb +14 -13
- data/lib/watirsplash/generators/page.rb +64 -0
- data/lib/watirsplash/generators/templates/new_project/.rspec +1 -1
- data/lib/watirsplash/generators/templates/new_project/config.rb.tt +3 -30
- data/lib/watirsplash/generators/templates/new_project/environment.rb.tt +12 -10
- data/lib/watirsplash/generators/templates/page/lib/%formatted_namespace%/page/%formatted_page_name%.rb.tt +8 -0
- data/lib/watirsplash/generators/templates/page/spec/%formatted_namespace%/page/%formatted_page_name%_spec.rb.tt +5 -0
- data/lib/watirsplash/html_formatter.rb +1 -1
- data/lib/watirsplash/page/base.rb +41 -0
- data/lib/watirsplash/rspec_patches.rb +5 -7
- data/lib/watirsplash/spec_helper.rb +5 -12
- data/lib/watirsplash/util.rb +3 -35
- data/lib/watirsplash/version.rb +10 -0
- data/spec/environment.rb +14 -0
- data/spec/spec_helper_spec.rb +3 -4
- data/spec/spec_match_array_spec.rb +2 -2
- data/watirsplash.gemspec +32 -0
- metadata +60 -45
- data/VERSION +0 -1
- data/environment.rb +0 -2
- data/lib/watirsplash/generators/migrate_project.rb +0 -25
- data/lib/watirsplash/generators/new_common_project.rb +0 -19
- data/lib/watirsplash/generators/templates/new_common_project/config.rb.tt +0 -34
- data/lib/watirsplash/generators/templates/new_common_project/environment.rb +0 -15
- data/lib/watirsplash/generators/templates/new_common_project/lib/common_application_helper.rb +0 -14
- data/lib/watirsplash/generators/templates/new_project/spec/%formatted_name%_helper.rb.tt +0 -18
- data/lib/watirsplash/generators/templates/new_project/spec/dummy_spec.rb.tt +0 -41
- data/spec/util_spec.rb +0 -48
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
# load WatirSplash and it's dependencies
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
platforms :mingw, :mswin do
|
7
|
+
gem "watir", WatirSplash::Version::WATIR
|
8
|
+
gem "win32screenshot", WatirSplash::Version::WIN32SCREENSHOT, :require => "win32/screenshot"
|
9
|
+
end
|
10
|
+
|
11
|
+
gem "watir-webdriver", WatirSplash::Version::WATIR_WEBDRIVER
|
12
|
+
gem "firewatir", WatirSplash::Version::WATIR
|
13
|
+
gem "rspec", "~>2.6.0"
|
14
|
+
|
15
|
+
# add your project specific dependencies here:
|
16
|
+
# gem "ruby-debug", "0.10.3"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
watirsplash (1.5.0)
|
5
|
+
bundler (~> 1.0)
|
6
|
+
rake (= 0.8.7)
|
7
|
+
require_all
|
8
|
+
rspec (~> 2.6)
|
9
|
+
syntax
|
10
|
+
thor (~> 0)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: http://rubygems.org/
|
14
|
+
specs:
|
15
|
+
builder (3.0.0)
|
16
|
+
childprocess (0.1.9)
|
17
|
+
ffi (~> 1.0.6)
|
18
|
+
commonwatir (1.9.0)
|
19
|
+
user-choices
|
20
|
+
diff-lcs (1.1.2)
|
21
|
+
ffi (1.0.9-x86-mingw32)
|
22
|
+
firewatir (1.9.0)
|
23
|
+
commonwatir (= 1.9.0)
|
24
|
+
hoe (2.9.4)
|
25
|
+
rake (>= 0.8.7)
|
26
|
+
json_pure (1.5.3)
|
27
|
+
mini_magick (3.2.1)
|
28
|
+
subexec (~> 0.0.4)
|
29
|
+
nokogiri (1.4.5-x86-mingw32)
|
30
|
+
rake (0.8.7)
|
31
|
+
rautomation (0.5.1)
|
32
|
+
require_all (1.2.0)
|
33
|
+
rspec (2.6.0)
|
34
|
+
rspec-core (~> 2.6.0)
|
35
|
+
rspec-expectations (~> 2.6.0)
|
36
|
+
rspec-mocks (~> 2.6.0)
|
37
|
+
rspec-core (2.6.4)
|
38
|
+
rspec-expectations (2.6.0)
|
39
|
+
diff-lcs (~> 1.1.2)
|
40
|
+
rspec-mocks (2.6.0)
|
41
|
+
rubyzip (0.9.4)
|
42
|
+
s4t-utils (1.0.4)
|
43
|
+
hoe (>= 1.3.0)
|
44
|
+
selenium-webdriver (0.2.2)
|
45
|
+
childprocess (>= 0.1.9)
|
46
|
+
ffi (>= 1.0.7)
|
47
|
+
json_pure
|
48
|
+
rubyzip
|
49
|
+
subexec (0.0.4)
|
50
|
+
syntax (1.0.0)
|
51
|
+
thor (0.14.6)
|
52
|
+
user-choices (1.1.6.1)
|
53
|
+
builder (>= 2.1.2)
|
54
|
+
s4t-utils (>= 1.0.3)
|
55
|
+
xml-simple (>= 1.0.11)
|
56
|
+
watir (1.9.0)
|
57
|
+
commonwatir (= 1.9.0)
|
58
|
+
ffi (~> 1.0)
|
59
|
+
firewatir (= 1.9.0)
|
60
|
+
nokogiri
|
61
|
+
rautomation (~> 0.5)
|
62
|
+
win32-process (>= 0.5.5)
|
63
|
+
windows-pr (>= 0.6.6)
|
64
|
+
watir-webdriver (0.2.5)
|
65
|
+
selenium-webdriver (>= 0.2.2)
|
66
|
+
win32-api (1.4.8-x86-mingw32)
|
67
|
+
win32-process (0.6.5)
|
68
|
+
windows-pr (>= 1.1.2)
|
69
|
+
win32screenshot (1.0.4)
|
70
|
+
ffi (~> 1.0)
|
71
|
+
mini_magick (~> 3.2.0)
|
72
|
+
rautomation (~> 0.5)
|
73
|
+
windows-api (0.4.0)
|
74
|
+
win32-api (>= 1.4.5)
|
75
|
+
windows-pr (1.2.0)
|
76
|
+
win32-api (>= 1.4.5)
|
77
|
+
windows-api (>= 0.3.0)
|
78
|
+
xml-simple (1.0.16)
|
79
|
+
|
80
|
+
PLATFORMS
|
81
|
+
x86-mingw32
|
82
|
+
|
83
|
+
DEPENDENCIES
|
84
|
+
firewatir (= 1.9.0)
|
85
|
+
watir (= 1.9.0)
|
86
|
+
watir-webdriver (~> 0.2.5)
|
87
|
+
watirsplash!
|
88
|
+
win32screenshot (~> 1.0.4)
|
data/README.rdoc
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
== DESCRIPTION
|
7
7
|
|
8
8
|
WatirSplash makes browser-based web page testing in Ruby splashin' easy.
|
9
|
-
It combines Watir
|
10
|
-
RSpec
|
9
|
+
It combines Watir, FireWatir or Watir-WebDriver for controlling the browser and
|
10
|
+
RSpec 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.
|
13
13
|
|
@@ -15,78 +15,100 @@ WatirSplash makes it easier to use best features of both of these tools together
|
|
15
15
|
you won't have to spend time on thinking how to do that yourself - you can start
|
16
16
|
testing right away!
|
17
17
|
|
18
|
-
==
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
== GETTING STARTED
|
19
|
+
|
20
|
+
1) Install Ruby (version 1.8.7 is recommended)
|
21
|
+
|
22
|
+
2) Install WatirSplash
|
23
|
+
C:\my_project>gem install watirsplash
|
24
|
+
|
25
|
+
3) Create a new project
|
26
|
+
C:\my_project>watirsplash new
|
27
|
+
create ui-test
|
28
|
+
...
|
29
|
+
|
30
|
+
C:\my_project>cd ui-test
|
31
|
+
|
32
|
+
4) Install all possible runtime dependencies
|
33
|
+
C:\my_project\ui-test>bundle install
|
34
|
+
Fetching source index for http://rubygems.org/
|
35
|
+
...
|
36
|
+
Using watirsplash
|
37
|
+
...
|
38
|
+
|
39
|
+
5) Create a "search" page class and a spec skeleton for it
|
40
|
+
C:\my_project\ui-test>watirsplash page search --url http://bing.com
|
41
|
+
create lib
|
42
|
+
create lib/app/page/search.rb
|
43
|
+
create spec
|
44
|
+
create spec/app/page/search_spec.rb
|
45
|
+
|
46
|
+
6) Create a "results" page class without spec
|
47
|
+
C:\Users\jarmo\Desktop\minu\projects\Ruby\my_project\ui-test>watirsplash page results --no-spec
|
48
|
+
exist lib
|
49
|
+
create lib/app/page/results.rb
|
50
|
+
|
51
|
+
7) Modify the created files
|
52
|
+
# lib\app\page\search.rb
|
53
|
+
module App
|
54
|
+
module Page
|
55
|
+
class Search < WatirSplash::Page::Base
|
56
|
+
url "http://bing.com"
|
57
|
+
|
58
|
+
def search_field
|
59
|
+
text_field(:name => "q")
|
60
|
+
end
|
61
|
+
|
62
|
+
def search_button
|
63
|
+
return_for button(:name => "go"),
|
64
|
+
# clicking the search button results a page transition to "results" page
|
65
|
+
:click => lambda {Results.new @browser}
|
66
|
+
end
|
30
67
|
end
|
68
|
+
end
|
69
|
+
end
|
31
70
|
|
32
|
-
it "has search field" do
|
33
|
-
text_field = @browser.text_field(:name => "q")
|
34
|
-
text_field.should exist
|
35
|
-
text_field.should be_visible
|
36
|
-
end
|
37
71
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
72
|
+
# lib\app\page\results.rb
|
73
|
+
module App
|
74
|
+
module Page
|
75
|
+
class Results < WatirSplash::Page::Base
|
76
|
+
|
77
|
+
def result index
|
78
|
+
div(:id => "results").
|
79
|
+
ul(:class => "sb_results").
|
80
|
+
li(:class => /sa_wr/, :index => index).
|
81
|
+
text
|
82
|
+
end
|
43
83
|
|
44
|
-
after :all do
|
45
|
-
@browser.close
|
46
84
|
end
|
85
|
+
end
|
47
86
|
end
|
48
87
|
|
49
88
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
it "has search field" do
|
59
|
-
text_field = text_field(:name => "q")
|
60
|
-
text_field.should exist
|
61
|
-
text_field.should be_visible
|
62
|
-
end
|
63
|
-
|
64
|
-
it "performs search" do
|
65
|
-
text_field(:name => "q").set "Bing"
|
66
|
-
button(:name => "btnG").click
|
67
|
-
text.should include("Bing")
|
68
|
-
end
|
89
|
+
# spec\app\page\search_spec.rb
|
90
|
+
describe App::Page::Search do
|
91
|
+
it "has something on the search page" do
|
92
|
+
search_page = App::Page::Search.new
|
93
|
+
search_page.search_field.set "watirsplash"
|
94
|
+
results_page = search_page.search_button.click
|
95
|
+
results_page.result(1).should =~ /watirsplash/i
|
96
|
+
end
|
69
97
|
end
|
70
|
-
|
71
|
-
C:\project\ui-test>rspec spec\google_spec.rb
|
72
|
-
Results will be saved into the directory C:/project/ui-test/results
|
73
|
-
Google
|
74
|
-
has search field
|
75
|
-
performs search
|
76
98
|
|
77
|
-
|
99
|
+
8) Execute all specs
|
100
|
+
C:\my_project\ui-test>rspec spec
|
101
|
+
Results will be saved into the directory C:/my_project/ui-test/results
|
78
102
|
|
79
|
-
|
103
|
+
App::Page::Search @ app/page/search_spec.rb:1 (30.06.2011)
|
104
|
+
has something on the search page:2 (09:34:30)
|
80
105
|
|
81
|
-
|
106
|
+
Finished in 4.48 seconds
|
107
|
+
1 example, 0 failures
|
82
108
|
|
83
|
-
|
84
|
-
|
85
|
-
2) install WatirSplash:
|
86
|
-
gem install watirsplash
|
109
|
+
9) Check out the html report at results/index.html
|
87
110
|
|
88
|
-
|
89
|
-
watirsplash new
|
111
|
+
10) Repeat & profit!
|
90
112
|
|
91
113
|
== SUPPORTED PLATFORMS & BROWSERS
|
92
114
|
|
@@ -99,15 +121,17 @@ Each framework drives a specific browser:
|
|
99
121
|
* Watir - IE
|
100
122
|
* Watir-WebDriver - Chrome, IE and Firefox
|
101
123
|
|
102
|
-
It is possible to specify what framework to use in
|
124
|
+
It is possible to specify what framework to use in config.rb file:
|
103
125
|
WatirSplash::Util.framework = "watir-webdriver/firefox"
|
104
126
|
|
105
|
-
|
127
|
+
It is also possible to specify used framework by using environment variable WATIRSPLASH_FRAMEWORK.
|
128
|
+
|
129
|
+
If framework is not specified manually then the default framework will be used for the current platform.
|
106
130
|
|
107
131
|
PS! Please note that all frameworks are not 100% compatible with each other. If you find any concrete incompatibilities then
|
108
132
|
it would be great if you'd contribute fixes or information to the authors of the frameworks.
|
109
133
|
|
110
|
-
==
|
134
|
+
== MORE INFORMATION?
|
111
135
|
|
112
136
|
You can read more information about the usage and features from the wiki at http://github.com/jarmo/WatirSplash/wiki
|
113
137
|
|
data/Rakefile
CHANGED
@@ -1,42 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require '
|
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.files << "lib/watirsplash/generators/templates/new_project/.rspec"
|
23
|
-
gem.post_install_message = %Q{#{"*"*25}
|
24
|
-
|
25
|
-
Thank you for installing WatirSplash #{version}! Don't forget to take a look at the README and History files!
|
26
|
-
|
27
|
-
Execute `watirsplash new` under your project's directory to generate a default project structure.
|
28
|
-
|
29
|
-
#{"*"*25}}
|
30
|
-
|
31
|
-
gem.add_dependency("rspec", "~>2.6")
|
32
|
-
gem.add_dependency("thor", "~>0")
|
33
|
-
gem.add_dependency("require_all")
|
34
|
-
gem.add_dependency("syntax")
|
35
|
-
end
|
36
|
-
Jeweler::GemcutterTasks.new
|
37
|
-
rescue LoadError
|
38
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
39
|
-
end
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
40
4
|
|
41
5
|
require 'rspec/core/rake_task'
|
42
6
|
RSpec::Core::RakeTask.new(:spec)
|
@@ -49,10 +13,8 @@ task :default => :spec
|
|
49
13
|
|
50
14
|
require 'rake/rdoctask'
|
51
15
|
Rake::RDocTask.new do |rdoc|
|
52
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
53
|
-
|
54
16
|
rdoc.rdoc_dir = 'rdoc'
|
55
|
-
rdoc.title = "WatirSplash #{
|
17
|
+
rdoc.title = "WatirSplash #{WatirSplash::Version::WATIRSPLASH}"
|
56
18
|
rdoc.rdoc_files.include('README*')
|
57
19
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
58
20
|
end
|
data/lib/watirsplash.rb
CHANGED
@@ -2,6 +2,7 @@ require "rubygems"
|
|
2
2
|
require "require_all"
|
3
3
|
require "rspec"
|
4
4
|
require "pathname"
|
5
|
+
require_rel "watirsplash/version" unless defined? WatirSplash::Version
|
5
6
|
require_rel "watirsplash/browser"
|
6
7
|
require_rel "watirsplash/file_helper"
|
7
8
|
require_rel "watirsplash/spec_helper"
|
@@ -9,7 +10,6 @@ require_rel "watirsplash/rspec_patches"
|
|
9
10
|
require_rel "watirsplash/util"
|
10
11
|
require_rel "watirsplash/html_formatter"
|
11
12
|
require_rel "watirsplash/frameworks/helper"
|
13
|
+
require_rel "watirsplash/page/base"
|
12
14
|
WatirSplash::Util.configure_rspec_formatters
|
13
|
-
WatirSplash::Util.load_environment
|
14
|
-
WatirSplash::Util.load_framework
|
15
15
|
|
data/lib/watirsplash/browser.rb
CHANGED
data/lib/watirsplash/cli.rb
CHANGED
@@ -1,39 +1,35 @@
|
|
1
1
|
require "thor"
|
2
2
|
require "thor/group"
|
3
|
+
require "watirsplash/generators/helper"
|
3
4
|
require "watirsplash/generators/new_project"
|
4
|
-
require "watirsplash/generators/
|
5
|
-
require "watirsplash/generators/migrate_project"
|
5
|
+
require "watirsplash/generators/page"
|
6
6
|
require "watirsplash/util"
|
7
7
|
|
8
8
|
module WatirSplash
|
9
9
|
class CLI < Thor
|
10
|
-
|
11
|
-
method_option :framework, :default => WatirSplash::Util.send(:default_framework).to_s, :aliases => "-f",
|
12
|
-
:desc => "Framework to use. Possible values are watir, firewatir, watir-webdriver/ie, watir-webdriver/firefox, watir-webdriver/chrome."
|
13
|
-
end
|
14
|
-
|
15
|
-
desc "new [APPLICATION_NAME]", "Create a new WatirSplash project."
|
16
|
-
method_option :load_common, :type => :boolean, :default => false, :aliases => "-l",
|
17
|
-
:desc => "Load WatirSplash common project automatically."
|
18
|
-
method_option :url, :default => "about:blank", :aliases => "-u",
|
19
|
-
:desc => "URL to open in the browser before each test. May be relative if WatirSplash common project is loaded."
|
20
|
-
framework_option.call
|
21
|
-
def new(name = "Application")
|
22
|
-
WatirSplash::Generators::NewProject.start([Thor::Util.camel_case(name), options[:url], options[:framework], options.load_common?])
|
23
|
-
end
|
10
|
+
extend Generators::Helper
|
24
11
|
|
25
|
-
|
26
|
-
|
27
|
-
:
|
28
|
-
|
29
|
-
|
30
|
-
|
12
|
+
unless Dir.entries(Dir.pwd).include? ".rspec"
|
13
|
+
desc "new [DIRECTORY_NAME]", "Create a new WatirSplash project."
|
14
|
+
method_option :url, :default => "about:blank", :aliases => "-u",
|
15
|
+
:desc => "URL for the application under test."
|
16
|
+
method_option :framework, :default => "default", :aliases => "-f",
|
17
|
+
:desc => "Framework to use. Possible values are #{supported_frameworks.join(", ")}."
|
18
|
+
def new(name = "ui-test")
|
19
|
+
WatirSplash::Generators::NewProject.start([name, options[:url], options[:framework]])
|
20
|
+
end
|
31
21
|
end
|
32
22
|
|
33
|
-
if
|
34
|
-
desc "
|
35
|
-
|
36
|
-
|
23
|
+
if Dir.entries(Dir.pwd).include? ".rspec"
|
24
|
+
desc "page PAGE_NAME [element_name:element_type:locator_name:locator_value]", "Create a new WatirSplash page."
|
25
|
+
method_option :spec, :default => true, :aliases => "-s", :type => :boolean,
|
26
|
+
:desc => "Create spec file for page."
|
27
|
+
method_option :url, :default => nil, :aliases => "-u",
|
28
|
+
:desc => "URL for the page if directly accessible."
|
29
|
+
method_option :module, :default => "App", :aliases => "-m",
|
30
|
+
:desc => "Namespace module for the page."
|
31
|
+
def page(page_name = "Main", *elements)
|
32
|
+
WatirSplash::Generators::Page.start([page_name.gsub("-", "_"), elements, options[:module].gsub("-", "_"), options[:spec], options[:url]])
|
37
33
|
end
|
38
34
|
end
|
39
35
|
|