caius-safariwatir 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +46 -0
- data/Rakefile +13 -0
- data/lib/safariwatir.rb +541 -0
- data/lib/safariwatir/core_ext.rb +31 -0
- data/lib/safariwatir/scripter.rb +573 -0
- data/lib/watir/exceptions.rb +42 -0
- data/safariwatir.gemspec +34 -0
- data/safariwatir_example.rb +151 -0
- metadata +79 -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,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{safariwatir}
|
5
|
+
s.version = "0.3.4"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Dave Hoover"]
|
9
|
+
s.date = %q{2009-02-14}
|
10
|
+
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.}
|
11
|
+
s.email = %q{dave@obtiva.com}
|
12
|
+
s.extra_rdoc_files = ["lib/safariwatir/core_ext.rb", "lib/safariwatir/scripter.rb", "lib/safariwatir.rb", "lib/watir/exceptions.rb", "README.rdoc"]
|
13
|
+
s.files = ["lib/safariwatir/core_ext.rb", "lib/safariwatir/scripter.rb", "lib/safariwatir.rb", "lib/watir/exceptions.rb", "Manifest", "Rakefile", "README.rdoc", "safariwatir.gemspec", "safariwatir_example.rb"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://safariwatir.rubyforge.org/}
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Safariwatir", "--main", "README.rdoc"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{safariwatir}
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
20
|
+
s.summary = %q{Automated testing tool for web applications.}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 2
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_development_dependency(%q<rb-appscript>, [">= 0"])
|
28
|
+
else
|
29
|
+
s.add_dependency(%q<rb-appscript>, [">= 0"])
|
30
|
+
end
|
31
|
+
else
|
32
|
+
s.add_dependency(%q<rb-appscript>, [">= 0"])
|
33
|
+
end
|
34
|
+
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,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: caius-safariwatir
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dave Hoover
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-14 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rb-appscript
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
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.
|
26
|
+
email: dave@obtiva.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- lib/safariwatir/core_ext.rb
|
33
|
+
- lib/safariwatir/scripter.rb
|
34
|
+
- lib/safariwatir.rb
|
35
|
+
- lib/watir/exceptions.rb
|
36
|
+
- README.rdoc
|
37
|
+
files:
|
38
|
+
- lib/safariwatir/core_ext.rb
|
39
|
+
- lib/safariwatir/scripter.rb
|
40
|
+
- lib/safariwatir.rb
|
41
|
+
- lib/watir/exceptions.rb
|
42
|
+
- Manifest
|
43
|
+
- Rakefile
|
44
|
+
- README.rdoc
|
45
|
+
- safariwatir.gemspec
|
46
|
+
- safariwatir_example.rb
|
47
|
+
has_rdoc: true
|
48
|
+
homepage: http://safariwatir.rubyforge.org/
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options:
|
51
|
+
- --line-numbers
|
52
|
+
- --inline-source
|
53
|
+
- --title
|
54
|
+
- Safariwatir
|
55
|
+
- --main
|
56
|
+
- README.rdoc
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "1.2"
|
70
|
+
version:
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project: safariwatir
|
74
|
+
rubygems_version: 1.2.0
|
75
|
+
signing_key:
|
76
|
+
specification_version: 2
|
77
|
+
summary: Automated testing tool for web applications.
|
78
|
+
test_files: []
|
79
|
+
|