safariwatir 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -4,8 +4,8 @@ http://twitter.com/swombat/status/1280692921
4
4
  = SafariWatir
5
5
 
6
6
  * http://github.com/redsquirrel/safariwatir
7
- * http://safariwatir.rubyforge.org
8
- * http://rubyforge.org/mailman/listinfo/safariwatir-general
7
+ * http://groups.google.com/group/watir-general
8
+ * http://wiki.openqa.org/display/WTR/SafariWatir
9
9
  * http://twitter.com/SafariWatir
10
10
 
11
11
  == DESCRIPTION:
@@ -18,7 +18,6 @@ This project aims at adding Watir support for Safari on the Mac.
18
18
 
19
19
  Mac OS X running Safari. Some features require you to turn on "Enable access for assistive devices" in System Preferences > Universal Access.
20
20
 
21
-
22
21
  == SYNOPSIS:
23
22
 
24
23
  require 'rubygems'
@@ -38,13 +37,19 @@ Mac OS X running Safari. Some features require you to turn on "Enable access for
38
37
 
39
38
  git clone git://github.com/redsquirrel/safariwatir.git
40
39
  cd safariwatir
40
+ git submodule update --init
41
41
  rake install
42
42
 
43
- == RUNNING SAFARIWATIR AGAINST WATIR'S CORE TESTS
43
+ == RUNNING SAFARIWATIR AGAINST WATIRSPEC
44
+
45
+ git clone git://github.com/redsquirrel/safariwatir.git
46
+ cd safariwatir
47
+ git submodule update --init
48
+ spec spec
49
+
50
+ == CONTRIBUTING:
44
51
 
45
- # First, install the SafariWatir gem (see above)
46
- svn checkout https://svn.openqa.org/svn/watir/trunk
47
- cd trunk/watir
48
- cp unittests/options.yml.example unittests/options.yml
49
- # Edit unittests/options.yml and set browser: safari
50
- ruby unittests/core_tests.rb
52
+ WatirSpec is the emergent standard for the Watir API.
53
+ We do not currently support all of the functionality described by WatirSpec.
54
+ A good way to contribute would be to fix a few failing specs as defined by WatirSpec.
55
+ See "Running SafairWatir Against WatirSpec" to get started.
data/Rakefile CHANGED
@@ -2,10 +2,10 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('safariwatir', '0.3.5') do | config |
5
+ Echoe.new('safariwatir', '0.3.7') do | config |
6
6
  config.summary = %q{Automated testing tool for web applications.}
7
7
  config.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.}
8
- config.url = 'http://safariwatir.rubyforge.org/'
8
+ config.url = 'http://wiki.openqa.org/display/WTR/SafariWatir'
9
9
  config.author = 'Dave Hoover'
10
10
  config.email = 'dave@obtiva.com'
11
11
  config.ignore_pattern = ['tmp/*', 'script/*']
data/lib/safariwatir.rb CHANGED
@@ -102,12 +102,12 @@ module Watir
102
102
 
103
103
  # overridden in derivitives
104
104
  def tag
105
- raise RuntimeError, "tag not provided for #{name}"
105
+ raise RuntimeError, "tag not provided for #{element_name}"
106
106
  end
107
107
 
108
108
  # overridden in derivitives
109
109
  def speak
110
- @scripter.speak("#{name}'s don't know how to speak.")
110
+ @scripter.speak("#{element_name}'s don't know how to speak.")
111
111
  end
112
112
 
113
113
  def exists?
@@ -115,7 +115,7 @@ module Watir
115
115
  end
116
116
  alias :exist? :exists?
117
117
 
118
- def name
118
+ def element_name
119
119
  self.class.name.split("::").last
120
120
  end
121
121
 
@@ -126,10 +126,10 @@ module Watir
126
126
  def operate(&block)
127
127
  scripter_suffix = OPERATIONS[how]
128
128
  if scripter_suffix.kind_of? Hash
129
- scripter_suffix = scripter_suffix[name]
129
+ scripter_suffix = scripter_suffix[element_name]
130
130
  end
131
131
  if scripter_suffix.nil?
132
- raise "SafariWatir does not currently support finding by #{how}"
132
+ raise Watir::Exception::MissingWayOfFindingObjectException, "SafariWatir does not currently support finding by #{how}"
133
133
  end
134
134
  @scripter.send("operate_#{scripter_suffix}", self, &block)
135
135
  end
@@ -148,6 +148,7 @@ module Watir
148
148
  :value => "by_input_value",
149
149
  :caption => "by_input_value",
150
150
  :src => "by_src",
151
+ :title => "by_title",
151
152
  :xpath => "by_xpath",
152
153
  }
153
154
  end
@@ -172,6 +173,10 @@ module Watir
172
173
  def enabled?
173
174
  !@scripter.element_disabled?(self)
174
175
  end
176
+
177
+ def disabled?
178
+ @scripter.element_disabled?(self)
179
+ end
175
180
 
176
181
  def tag; "INPUT"; end
177
182
 
@@ -249,6 +254,31 @@ module Watir
249
254
  end
250
255
  end
251
256
 
257
+ def href
258
+ attr('href') || ''
259
+ end
260
+ alias :url :href
261
+
262
+ def id
263
+ attr('id') || ''
264
+ end
265
+
266
+ def title
267
+ attr('title') || ''
268
+ end
269
+
270
+ def class_name
271
+ attr('class') || ''
272
+ end
273
+
274
+ def style
275
+ attr('style') || ''
276
+ end
277
+
278
+ def name
279
+ attr('name') || ''
280
+ end
281
+
252
282
  def tag; "A"; end
253
283
  end
254
284
 
@@ -324,6 +354,10 @@ module Watir
324
354
  def tag; "SPAN"; end
325
355
  end
326
356
 
357
+ class Map < InputElement
358
+ def tag; "MAP"; end
359
+ end
360
+
327
361
  class Table
328
362
  def_init :scripter, :how, :what
329
363
  attr_reader :how, :what
@@ -418,6 +452,9 @@ module Watir
418
452
  end
419
453
  end
420
454
  end
455
+
456
+ class TextArea < TextField
457
+ end
421
458
 
422
459
  class Password < TextField
423
460
  end
@@ -430,7 +467,15 @@ module Watir
430
467
  def tag; "LI"; end
431
468
  end
432
469
 
470
+ class Area < InputElement
471
+ def tag; "AREA"; end
472
+ end
473
+
433
474
  # Elements
475
+
476
+ def area(how, what)
477
+ Area.new(scripter, how, what)
478
+ end
434
479
 
435
480
  def button(how, what)
436
481
  Button.new(scripter, how, what)
@@ -476,6 +521,10 @@ module Watir
476
521
  Link.new(scripter, how, what)
477
522
  end
478
523
 
524
+ def map(how, what)
525
+ Map.new(scripter, how, what)
526
+ end
527
+
479
528
  def password(how, what)
480
529
  Password.new(scripter, how, what)
481
530
  end
@@ -503,6 +552,10 @@ module Watir
503
552
  def text_field(how, what)
504
553
  TextField.new(scripter, how, what)
505
554
  end
555
+
556
+ def text_area(how, what)
557
+ TextArea.new(scripter, how, what)
558
+ end
506
559
 
507
560
  def ul(how, what)
508
561
  Ul.new(scripter, how, what)
@@ -71,8 +71,8 @@ if (element) {
71
71
 
72
72
  def wrap(script)
73
73
  # add in frame name when referencing parent or document
74
- script.gsub! "parent", "parent.#{@page_container}"
75
- script.gsub! "document", "#{@page_container}.document"
74
+ script.gsub! /\bparent\b/, "parent.#{@page_container}"
75
+ script.gsub! /\bdocument\b/, "#{@page_container}.document"
76
76
  super(script)
77
77
  end
78
78
  end
@@ -364,14 +364,14 @@ for (var i = 0; i < document.links.length; i++) {
364
364
  private :find_link
365
365
 
366
366
  def handle_match(element, how = nil)
367
- how = {:text => "text", :url => "href"}[element.how] unless how
367
+ how = {:text => "text", :url => "href", :id => "id"}[element.how] unless how
368
368
  case element.what
369
369
  when Regexp
370
370
  %|#{how}.match(/#{element.what.source}/#{element.what.casefold? ? "i":nil})|
371
371
  when String
372
372
  %|#{how} == '#{element.what}'|
373
373
  else
374
- raise RuntimeError, "Unable to locate #{element.name} with #{element.how}"
374
+ raise RuntimeError, "Unable to locate #{element.element_name} with #{element.how}"
375
375
  end
376
376
  end
377
377
  private :handle_match
@@ -417,7 +417,7 @@ var element = elements[0];|, yield)
417
417
  # Checkboxes/Radios have the same name, different values
418
418
  def handle_form_element_name_match(element)
419
419
  element_capture = %|element = elements[i];break;|
420
- if element.by_value
420
+ if element.respond_to?(:by_value) and element.by_value
421
421
  %|if (elements[i].value == '#{element.by_value}') {
422
422
  #{element_capture}
423
423
  }|
@@ -443,6 +443,10 @@ var element = elements[0];|, yield)
443
443
  operate_by(element, 'alt', &block)
444
444
  end
445
445
 
446
+ def operate_by_title(element, &block)
447
+ operate_by(element, 'title', &block)
448
+ end
449
+
446
450
  def operate_by_action(element, &block)
447
451
  operate_by(element, 'action', &block)
448
452
  end
@@ -452,8 +456,9 @@ var element = elements[0];|, yield)
452
456
  end
453
457
 
454
458
  def operate_by_xpath(element)
459
+ xpath = element.what.gsub(/"/, "\'")
455
460
  js.operate(%|
456
- var result = document.evaluate('#{element.what}', document.documentElement, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
461
+ var result = document.evaluate("#{xpath}", document.documentElement, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
457
462
  var element = result ? result.singleNodeValue : null;
458
463
  |, yield)
459
464
  end
@@ -502,13 +507,13 @@ end tell|, true)
502
507
  AppleScripter.new(TableJavaScripter.new(element))
503
508
  end
504
509
 
505
- def for_frame(element)
510
+ def for_frame(frame)
506
511
  # verify the frame exists
507
512
  execute(
508
- %|if (parent.#{element.name} == undefined) {
513
+ %|if (parent.#{frame.name} == undefined) {
509
514
  return '#{FRAME_NOT_FOUND}';
510
- }|, element)
511
- AppleScripter.new(FrameJavaScripter.new(element))
515
+ }|, frame)
516
+ AppleScripter.new(FrameJavaScripter.new(frame))
512
517
  end
513
518
 
514
519
  def speak_value_of(element = @element)
@@ -548,11 +553,11 @@ SCRIPT`
548
553
  when NO_RESPONSE
549
554
  nil
550
555
  when ELEMENT_NOT_FOUND
551
- raise UnknownObjectException, "Unable to locate #{element.name} element with #{element.how} of #{element.what}"
556
+ raise UnknownObjectException, "Unable to locate #{element.element_name} element with #{element.how} of #{element.what}"
552
557
  when TABLE_CELL_NOT_FOUND
553
558
  raise UnknownCellException, "Unable to locate a table cell with #{element.how} of #{element.what}"
554
559
  when FRAME_NOT_FOUND
555
- raise UnknownFrameException, "Unable to locate a frame with name #{element.name}"
560
+ raise UnknownFrameException, "Unable to locate a frame with name #{element.element_name}"
556
561
  else
557
562
  response
558
563
  end
data/safariwatir.gemspec CHANGED
@@ -1,11 +1,13 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- Gem::Specification.new do |s|
3
+ require 'rubygems'
4
+
5
+ spec = Gem::Specification.new do |s|
4
6
  s.name = %q{safariwatir}
5
- s.version = "0.3.7"
7
+ s.version = "0.3.8"
6
8
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
7
9
  s.authors = ["Dave Hoover", "Tom Copeland"]
8
- s.date = %q{2009-10-20}
10
+ s.date = Time.now.strftime("%Y-%m-%d")
9
11
  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.}
10
12
  s.email = %q{dave@obtiva.com}
11
13
  s.extra_rdoc_files = ["lib/safariwatir/core_ext.rb", "lib/safariwatir/scripter.rb", "lib/safariwatir.rb", "lib/watir/exceptions.rb", "README.rdoc"]
@@ -29,3 +31,5 @@ Gem::Specification.new do |s|
29
31
  s.add_dependency(%q<rb-appscript>, [">= 0"])
30
32
  end
31
33
  end
34
+
35
+ Gem::Builder.new(spec).build if $0 == __FILE__
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safariwatir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 8
9
+ version: 0.3.8
5
10
  platform: ruby
6
11
  authors:
7
12
  - Dave Hoover
@@ -10,19 +15,21 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2009-10-20 00:00:00 -04:00
18
+ date: 2010-08-02 00:00:00 -04:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
17
22
  name: rb-appscript
18
- type: :development
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
24
30
  version: "0"
25
- version:
31
+ type: :development
32
+ version_requirements: *id001
26
33
  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
34
  email: dave@obtiva.com
28
35
  executables: []
@@ -62,18 +69,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
69
  requirements:
63
70
  - - ">="
64
71
  - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
65
74
  version: "0"
66
- version:
67
75
  required_rubygems_version: !ruby/object:Gem::Requirement
68
76
  requirements:
69
77
  - - ">="
70
78
  - !ruby/object:Gem::Version
79
+ segments:
80
+ - 1
81
+ - 2
71
82
  version: "1.2"
72
- version:
73
83
  requirements: []
74
84
 
75
85
  rubyforge_project: safariwatir
76
- rubygems_version: 1.3.4
86
+ rubygems_version: 1.3.6
77
87
  signing_key:
78
88
  specification_version: 2
79
89
  summary: Automated testing tool for web applications.