jmonteiro-safariwatir 0.3.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jmonteiro-safariwatir
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.5.1
5
+ platform: ruby
6
+ authors:
7
+ - Dave Hoover
8
+ - Julio Monteiro
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-07-28 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:
28
+ - dave@obtiva.com
29
+ - julio@monteiro.eti.br
30
+ executables: []
31
+
32
+ extensions: []
33
+
34
+ extra_rdoc_files:
35
+ - lib/safariwatir/core_ext.rb
36
+ - lib/safariwatir/scripter.rb
37
+ - lib/safariwatir.rb
38
+ - lib/watir/exceptions.rb
39
+ - README.rdoc
40
+ files:
41
+ - README.rdoc
42
+ - Rakefile
43
+ - lib/safariwatir/core_ext.rb
44
+ - lib/safariwatir/scripter.rb
45
+ - lib/safariwatir.rb
46
+ - lib/watir/exceptions.rb
47
+ - safariwatir.gemspec
48
+ - safariwatir_example.rb
49
+ has_rdoc: true
50
+ homepage: http://safariwatir.rubyforge.org/
51
+ licenses:
52
+ post_install_message:
53
+ rdoc_options:
54
+ - --line-numbers
55
+ - --inline-source
56
+ - --title
57
+ - Safariwatir
58
+ - --main
59
+ - README.rdoc
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "1.2"
73
+ version:
74
+ requirements: []
75
+
76
+ rubyforge_project: safariwatir
77
+ rubygems_version: 1.3.5
78
+ signing_key:
79
+ specification_version: 2
80
+ summary: Automated testing tool for web applications.
81
+ test_files: []
82
+