mpeychich-safariwatir 0.3.6
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/README.rdoc +49 -0
- data/Rakefile +13 -0
- data/lib/safariwatir.rb +541 -0
- data/lib/safariwatir/core_ext.rb +31 -0
- data/lib/safariwatir/scripter.rb +587 -0
- data/lib/watir/exceptions.rb +42 -0
- data/safariwatir.gemspec +31 -0
- data/safariwatir_example.rb +151 -0
- metadata +75 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
module Watir
|
2
|
+
module Exception
|
3
|
+
|
4
|
+
# Root class for all Watir Exceptions
|
5
|
+
class WatirException < RuntimeError
|
6
|
+
def initialize(message="")
|
7
|
+
super(message)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# This exception is thrown if an attempt is made to access an object that doesn't exist
|
12
|
+
class UnknownObjectException < WatirException; end
|
13
|
+
# This exception is thrown if an attempt is made to access an object that is in a disabled state
|
14
|
+
class ObjectDisabledException < WatirException; end
|
15
|
+
# This exception is thrown if an attempt is made to access a frame that cannot be found
|
16
|
+
class UnknownFrameException< WatirException; end
|
17
|
+
# This exception is thrown if an attempt is made to access a form that cannot be found
|
18
|
+
class UnknownFormException< WatirException; end
|
19
|
+
# This exception is thrown if an attempt is made to access an object that is in a read only state
|
20
|
+
class ObjectReadOnlyException < WatirException; end
|
21
|
+
# This exception is thrown if an attempt is made to access an object when the specified value cannot be found
|
22
|
+
class NoValueFoundException < WatirException; end
|
23
|
+
# This exception gets raised if part of finding an object is missing
|
24
|
+
class MissingWayOfFindingObjectException < WatirException; end
|
25
|
+
# this exception is raised if an attempt is made to access a table cell that doesnt exist
|
26
|
+
class UnknownCellException < WatirException; end
|
27
|
+
# This exception is thrown if the window cannot be found
|
28
|
+
class NoMatchingWindowFoundException < WatirException; end
|
29
|
+
# This exception is thrown if an attemp is made to acces the status bar of the browser when it doesnt exist
|
30
|
+
class NoStatusBarException < WatirException; end
|
31
|
+
# This exception is thrown if an http error, such as a 404, 500 etc is encountered while navigating
|
32
|
+
class NavigationException < WatirException; end
|
33
|
+
# This exception is raised if a timeout is exceeded
|
34
|
+
class TimeOutException < WatirException
|
35
|
+
def initialize(duration, timeout)
|
36
|
+
@duration, @timeout = duration, timeout
|
37
|
+
end
|
38
|
+
attr_reader :duration, :timeout
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
data/safariwatir.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{safariwatir}
|
3
|
+
s.version = "0.3.6"
|
4
|
+
|
5
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
6
|
+
s.authors = ["Matthew Peychich", "Dave Hoover"]
|
7
|
+
s.date = %q{2009-05-01}
|
8
|
+
s.description = %q{WATIR stands for "Web Application Testing in Ruby". See WATIR project for more information. This is a Safari-version of the original IE-only WATIR.}
|
9
|
+
s.email = %q{mpeychich@mac.com dave@obtiva.com}
|
10
|
+
s.files = ["README.rdoc", "Rakefile", "lib/safariwatir/core_ext.rb", "lib/safariwatir/scripter.rb", "lib/safariwatir.rb", "lib/watir/exceptions.rb", "safariwatir.gemspec", "safariwatir_example.rb"]
|
11
|
+
s.has_rdoc = true
|
12
|
+
s.homepage = %q{http://safariwatir.rubyforge.org/}
|
13
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Safariwatir", "--main", "README.rdoc"]
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
s.rubyforge_project = %q{safariwatir}
|
16
|
+
s.rubygems_version = %q{1.3.1}
|
17
|
+
s.summary = %q{Automated testing tool for web applications.}
|
18
|
+
|
19
|
+
if s.respond_to? :specification_version then
|
20
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
21
|
+
s.specification_version = 2
|
22
|
+
|
23
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
24
|
+
s.add_development_dependency(%q<rb-appscript>, [">= 0"])
|
25
|
+
else
|
26
|
+
s.add_dependency(%q<rb-appscript>, [">= 0"])
|
27
|
+
end
|
28
|
+
else
|
29
|
+
s.add_dependency(%q<rb-appscript>, [">= 0"])
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'safariwatir'
|
3
|
+
|
4
|
+
# TODO
|
5
|
+
#
|
6
|
+
# Looking up textareas, or any input element for that matter, by index
|
7
|
+
#
|
8
|
+
# Be more attached to the Safari window.
|
9
|
+
# Currently, if a different window is selected, the AppleScript executes against it.
|
10
|
+
# Verify onclick is working for buttons and links
|
11
|
+
# TextFields should not respond to button method, etc.
|
12
|
+
|
13
|
+
# Unsupported Elements: Test that P/Div/Span/TD handle link, button, etc.,
|
14
|
+
# Javascript confirm [OK/CANCEL], Javascript prompt, Javascript popup windows
|
15
|
+
|
16
|
+
# Need to find a better way to distinguish between a submit button and a checkbox, re: page_load
|
17
|
+
|
18
|
+
# SAFARI ISSUES
|
19
|
+
# Labels are not clickable
|
20
|
+
# No known way to programatically click a <button>
|
21
|
+
# Links with href="javascript:foo()"
|
22
|
+
|
23
|
+
safari = Watir::Safari.new
|
24
|
+
|
25
|
+
def safari.google_to_prag
|
26
|
+
goto("http://google.com")
|
27
|
+
text_field(:name, "q").set("pickaxe")
|
28
|
+
button(:name, "btnG").click
|
29
|
+
link(:text, /Programming Ruby/).click
|
30
|
+
link(:url, "http://www.pragprog.com/titles/ruby/source_code").click
|
31
|
+
link(:text, "All Categories").click
|
32
|
+
link(:text, "All Titles").click
|
33
|
+
link(:url, /retrospectives/).click
|
34
|
+
puts "FAILURE prag" unless contains_text("Dave Hoover")
|
35
|
+
end
|
36
|
+
|
37
|
+
def safari.ala
|
38
|
+
goto("http://alistapart.com/")
|
39
|
+
text_field(:id, "search").set("grail")
|
40
|
+
checkbox(:id, "incdisc").set
|
41
|
+
button(:id, "submit").click
|
42
|
+
puts "FAILURE ala" unless contains_text('Search Results for “grail”')
|
43
|
+
end
|
44
|
+
|
45
|
+
def safari.amazon
|
46
|
+
goto("http://amazon.com")
|
47
|
+
select_list(:name, "url").select("VHS")
|
48
|
+
select_list(:name, "url").select_value("search-alias=stripbooks")
|
49
|
+
text_field(:name, "field-keywords").set("potter")
|
50
|
+
button(:name, "Go").click
|
51
|
+
puts "FAILURE amazon" unless contains_text("Deathly Hallows")
|
52
|
+
end
|
53
|
+
|
54
|
+
def safari.google_advanced
|
55
|
+
goto("http://www.google.com/advanced_search")
|
56
|
+
radio(:name, "safe", "active").set
|
57
|
+
radio(:name, "safe", "images").set
|
58
|
+
# Safari doesn't support label clicking ... perhaps I should raise an Exception
|
59
|
+
label(:text, "No filtering").click
|
60
|
+
radio(:id, "ss").set
|
61
|
+
text_field(:name, "as_q").set("obtiva")
|
62
|
+
button(:name, "btnG").click
|
63
|
+
puts "FAILURE google" unless contains_text("Training, Coaching, and Software Development")
|
64
|
+
end
|
65
|
+
|
66
|
+
def safari.reddit
|
67
|
+
goto("http://reddit.com/")
|
68
|
+
text_field(:name, "user").set("foo")
|
69
|
+
password(:name, "passwd").set("bar")
|
70
|
+
form(:index, 2).submit
|
71
|
+
puts "FAILURE reddit" unless contains_text("foo") and contains_text("logout")
|
72
|
+
end
|
73
|
+
|
74
|
+
def safari.colbert
|
75
|
+
goto("http://www.colbertnation.com/cn/contact.php")
|
76
|
+
text_field(:name, "formmessage").set("Beware the Bear")
|
77
|
+
button(:value, "Send Email").click
|
78
|
+
puts "FAILURE colbert" unless text_field(:name, "formmessage").verify_contains(/Enter message/)
|
79
|
+
end
|
80
|
+
|
81
|
+
def safari.redsquirrel
|
82
|
+
goto("http://redsquirrel.com/")
|
83
|
+
begin
|
84
|
+
text_field(:id, "not_there").set("imaginary")
|
85
|
+
puts "FAILURE squirrel text no e"
|
86
|
+
rescue Watir::UnknownObjectException => e
|
87
|
+
puts "FAILURE squirrel text bad e" unless e.message =~ /not_there/
|
88
|
+
end
|
89
|
+
begin
|
90
|
+
link(:text, "no_where").click
|
91
|
+
puts "FAILURE squirrel link no e"
|
92
|
+
rescue Watir::UnknownObjectException => e
|
93
|
+
puts "FAILURE squirrel link bad e" unless e.message =~ /no_where/
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def safari.weinberg
|
98
|
+
goto("http://www.geraldmweinberg.com/")
|
99
|
+
puts "FAILURE weinberg menu" unless frame("menu").contains_text("Jerry Weinberg's Site")
|
100
|
+
frame("menu").link(:text, "Books").click
|
101
|
+
frame("menu").link(:text, /psychology/i).click
|
102
|
+
puts "FAILURE weinberg content" unless frame("content").contains_text("Silver Anniversary")
|
103
|
+
end
|
104
|
+
|
105
|
+
def safari.tables
|
106
|
+
# Site Redesign, need to update test
|
107
|
+
# goto("http://basecamphq.com/")
|
108
|
+
# puts "FAILURE basecamp content" unless table(:index, 1)[1][2].text =~ /What is Basecamp\?/
|
109
|
+
|
110
|
+
goto("http://www.jimthatcher.com/webcourse9.htm")
|
111
|
+
puts "FAILURE thatcher" unless cell(:id, "c5").text == "subtotals"
|
112
|
+
|
113
|
+
goto("http://amazon.com/")
|
114
|
+
if contains_text("If you're not")
|
115
|
+
link(:text, "click here").click
|
116
|
+
end
|
117
|
+
|
118
|
+
puts "FAILURE amazon tr" unless row(:id, "twotabtop")[2].text =~ /Your\s+Amazon\.com/
|
119
|
+
row(:id, "twotabtop")[2].link(:index, 1).click
|
120
|
+
puts "FAILURE amazon link" unless contains_text("personalized recommendations")
|
121
|
+
|
122
|
+
goto("http://www.dreamweaverresources.com/tutorials/tableborder.htm")
|
123
|
+
puts "FAILURE dreamweaver" unless table(:id, "titletable")[1][1].text =~ /CSS/
|
124
|
+
end
|
125
|
+
|
126
|
+
def safari.onchange
|
127
|
+
goto("http://www.gr8cardeal.co.uk/?s=1")
|
128
|
+
select_list(:name, "manufacturer").select_value("BMW")
|
129
|
+
sleep 0.3 # There's an Ajax call here
|
130
|
+
select_list(:name, "model").select_value("Z4 ROADSTER")
|
131
|
+
end
|
132
|
+
|
133
|
+
def safari.ruby_sponsor_images
|
134
|
+
goto("http://mtnwestruby.org/")
|
135
|
+
puts "FAILURE image obtiva" unless image(:src, "http://mtnwestruby.org/images/sponsors/obtiva_logo.png").exists?
|
136
|
+
puts "FAILURE image thoughtworks" unless image(:src, /thoughtworks/).exists?
|
137
|
+
end
|
138
|
+
|
139
|
+
begin
|
140
|
+
safari.google_to_prag
|
141
|
+
safari.ala
|
142
|
+
safari.amazon
|
143
|
+
safari.google_advanced
|
144
|
+
safari.reddit
|
145
|
+
safari.colbert
|
146
|
+
safari.redsquirrel
|
147
|
+
safari.weinberg
|
148
|
+
safari.tables
|
149
|
+
safari.onchange
|
150
|
+
safari.ruby_sponsor_images
|
151
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mpeychich-safariwatir
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matthew Peychich
|
8
|
+
- Dave Hoover
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-05-01 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rb-appscript
|
18
|
+
type: :development
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
version:
|
26
|
+
description: WATIR stands for "Web Application Testing in Ruby". See WATIR project for more information. This is a Safari-version of the original IE-only WATIR.
|
27
|
+
email: mpeychich@mac.com dave@obtiva.com
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files: []
|
33
|
+
|
34
|
+
files:
|
35
|
+
- README.rdoc
|
36
|
+
- Rakefile
|
37
|
+
- lib/safariwatir/core_ext.rb
|
38
|
+
- lib/safariwatir/scripter.rb
|
39
|
+
- lib/safariwatir.rb
|
40
|
+
- lib/watir/exceptions.rb
|
41
|
+
- safariwatir.gemspec
|
42
|
+
- safariwatir_example.rb
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: http://safariwatir.rubyforge.org/
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --line-numbers
|
48
|
+
- --inline-source
|
49
|
+
- --title
|
50
|
+
- Safariwatir
|
51
|
+
- --main
|
52
|
+
- README.rdoc
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
version:
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "1.2"
|
66
|
+
version:
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project: safariwatir
|
70
|
+
rubygems_version: 1.2.0
|
71
|
+
signing_key:
|
72
|
+
specification_version: 2
|
73
|
+
summary: Automated testing tool for web applications.
|
74
|
+
test_files: []
|
75
|
+
|