safariwatir 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/safariwatir.rb CHANGED
@@ -133,9 +133,19 @@ module Watir
133
133
  end
134
134
  end
135
135
 
136
- class Button < InputElement
136
+ class Image < HtmlElement
137
+ def tag; "IMG"; end
138
+
139
+ protected
140
+
141
+ def operate_by_src(&block)
142
+ @scripter.operate_by(self, 'src', &block)
143
+ end
137
144
  end
138
145
 
146
+ class Button < InputElement
147
+ end
148
+
139
149
  class Checkbox < InputElement
140
150
  def_init :scripter, :how, :what, :value
141
151
  def by_value
@@ -154,7 +164,7 @@ module Watir
154
164
  protected
155
165
 
156
166
  def operate_by_text(&block)
157
- @scripter.operate_on_label(self, &block)
167
+ @scripter.operate_by(self, 'innerText', &block)
158
168
  end
159
169
  end
160
170
 
@@ -339,7 +349,7 @@ module Watir
339
349
  end
340
350
 
341
351
  def image(how, what)
342
- Button.new(scripter, how, what)
352
+ Image.new(scripter, how, what)
343
353
  end
344
354
 
345
355
  def label(how, what)
@@ -301,8 +301,8 @@ for (var i = 0; i < document.links.length; i++) {
301
301
  end
302
302
  private :find_link
303
303
 
304
- def handle_match(element)
305
- how = {:text => "text", :url => "href"}[element.how]
304
+ def handle_match(element, how = nil)
305
+ how = {:text => "text", :url => "href"}[element.how] unless how
306
306
  case element.what
307
307
  when Regexp:
308
308
  %|#{how}.match(/#{element.what.source}/#{element.what.casefold? ? "i":nil})|
@@ -357,11 +357,11 @@ for (var i = 0; i < elements.length; i++) {
357
357
  js.operate(%|var element = document.getElementsByTagName('#{element.tag}')[#{element.what-1}];|, yield)
358
358
  end
359
359
 
360
- def operate_on_label(element)
361
- js.operate(%|var elements = document.getElementsByTagName('LABEL');
360
+ def operate_by(element, attribute)
361
+ js.operate(%|var elements = document.getElementsByTagName('#{element.tag}');
362
362
  var element = undefined;
363
363
  for (var i = 0; i < elements.length; i++) {
364
- if (elements[i].innerText == '#{element.what}') {
364
+ if (elements[i].#{handle_match(element, attribute)}) {
365
365
  element = elements[i];
366
366
  break;
367
367
  }
@@ -42,10 +42,10 @@ end
42
42
  def safari.amazon
43
43
  goto("http://amazon.com")
44
44
  select_list(:name, "url").select("VHS")
45
- select_list(:name, "url").select_value("search-alias=software")
46
- text_field(:name, "field-keywords").set("Orion")
47
- image(:name, "Go").click
48
- puts "FAILURE amazon" unless contains_text("Master of Orion")
45
+ select_list(:name, "url").select_value("search-alias=stripbooks")
46
+ text_field(:name, "field-keywords").set("potter")
47
+ button(:name, "Go").click
48
+ puts "FAILURE amazon" unless contains_text("Deathly Hallows")
49
49
  end
50
50
 
51
51
  def safari.google_advanced
@@ -127,6 +127,12 @@ def safari.onchange
127
127
  select_list(:name, "model").select_value("Z4 ROADSTER")
128
128
  end
129
129
 
130
+ def safari.ruby_sponsor_images
131
+ goto("http://mtnwestruby.org/")
132
+ puts "FAILURE image obtiva" unless image(:src, "http://mtnwestruby.org/images/sponsors/obtiva_logo.png").exists?
133
+ puts "FAILURE image thoughtworks" unless image(:src, /thoughtworks/).exists?
134
+ end
135
+
130
136
  begin
131
137
  safari.google_to_prag
132
138
  safari.ala
@@ -138,6 +144,7 @@ begin
138
144
  safari.weinberg
139
145
  safari.tables
140
146
  safari.onchange
147
+ safari.ruby_sponsor_images
141
148
  ensure
142
149
  safari.close
143
150
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: safariwatir
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.2
7
- date: 2007-01-20 00:00:00 -06:00
6
+ version: 0.2.3
7
+ date: 2007-03-26 00:00:00 -05:00
8
8
  summary: Automated testing tool for web applications.
9
9
  require_paths:
10
10
  - .
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - Dave Hoover
30
31
  files: