redsquirrel-safariwatir 0.3.5 → 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 +3 -0
- data/lib/safariwatir.rb +17 -4
- data/lib/safariwatir/scripter.rb +22 -10
- data/safariwatir.gemspec +3 -3
- metadata +4 -4
data/README.rdoc
CHANGED
data/lib/safariwatir.rb
CHANGED
@@ -35,8 +35,8 @@ module Watir
|
|
35
35
|
|
36
36
|
def speed=(how_fast)
|
37
37
|
case how_fast
|
38
|
-
when :fast
|
39
|
-
when :slow
|
38
|
+
when :fast then set_fast_speed
|
39
|
+
when :slow then set_slow_speed
|
40
40
|
else
|
41
41
|
raise ArgumentError, "Invalid speed: #{how_fast}"
|
42
42
|
end
|
@@ -140,6 +140,7 @@ module Watir
|
|
140
140
|
:value => "by_input_value",
|
141
141
|
:caption => "by_input_value",
|
142
142
|
:src => "by_src",
|
143
|
+
:xpath => "by_xpath",
|
143
144
|
}
|
144
145
|
end
|
145
146
|
|
@@ -159,6 +160,10 @@ module Watir
|
|
159
160
|
def speak
|
160
161
|
@scripter.speak_value_of(self)
|
161
162
|
end
|
163
|
+
|
164
|
+
def enabled?
|
165
|
+
!@scripter.element_disabled?(self)
|
166
|
+
end
|
162
167
|
|
163
168
|
def tag; "INPUT"; end
|
164
169
|
|
@@ -214,6 +219,10 @@ module Watir
|
|
214
219
|
class Div < ContentElement
|
215
220
|
def tag; "DIV"; end
|
216
221
|
end
|
222
|
+
|
223
|
+
class P < ContentElement
|
224
|
+
def tag; "P"; end
|
225
|
+
end
|
217
226
|
|
218
227
|
class Label < ContentElement
|
219
228
|
def tag; "LABEL"; end
|
@@ -417,6 +426,10 @@ module Watir
|
|
417
426
|
def div(how, what)
|
418
427
|
Div.new(scripter, how, what)
|
419
428
|
end
|
429
|
+
|
430
|
+
def p(how, what)
|
431
|
+
P.new(scripter, how, what)
|
432
|
+
end
|
420
433
|
|
421
434
|
def form(how, what)
|
422
435
|
Form.new(scripter, how, what)
|
@@ -468,9 +481,9 @@ module Watir
|
|
468
481
|
|
469
482
|
def contains_text(what)
|
470
483
|
case what
|
471
|
-
when Regexp
|
484
|
+
when Regexp
|
472
485
|
text =~ what
|
473
|
-
when String
|
486
|
+
when String
|
474
487
|
text.index(what)
|
475
488
|
else
|
476
489
|
raise MissingWayOfFindingObjectException
|
data/lib/safariwatir/scripter.rb
CHANGED
@@ -45,13 +45,13 @@ if (element) {
|
|
45
45
|
|
46
46
|
finder =
|
47
47
|
case cell.row.how
|
48
|
-
when :id
|
48
|
+
when :id
|
49
49
|
%|getElementById('#{cell.row.what}')|
|
50
|
-
when :index
|
50
|
+
when :index
|
51
51
|
case cell.row.table.how
|
52
52
|
when :id
|
53
53
|
%|getElementById('#{cell.row.table.what}').rows[#{cell.row.what-1}]|
|
54
|
-
when :index
|
54
|
+
when :index
|
55
55
|
%|getElementsByTagName('TABLE')[#{cell.row.table.what-1}].rows[#{cell.row.what-1}]|
|
56
56
|
else
|
57
57
|
raise MissingWayOfFindingObjectException, "Table element does not support #{cell.row.table.how}"
|
@@ -332,9 +332,10 @@ if (element.onclick) {
|
|
332
332
|
js.operate(find_link(element), yield)
|
333
333
|
end
|
334
334
|
|
335
|
+
# This needs to take XPath into account now?
|
335
336
|
def find_link(element)
|
336
337
|
case element.how
|
337
|
-
when :index
|
338
|
+
when :index
|
338
339
|
%|var element = document.getElementsByTagName('A')[#{element.what-1}];|
|
339
340
|
else
|
340
341
|
%|var element = undefined;
|
@@ -351,9 +352,9 @@ for (var i = 0; i < document.links.length; i++) {
|
|
351
352
|
def handle_match(element, how = nil)
|
352
353
|
how = {:text => "text", :url => "href"}[element.how] unless how
|
353
354
|
case element.what
|
354
|
-
when Regexp
|
355
|
+
when Regexp
|
355
356
|
%|#{how}.match(/#{element.what.source}/#{element.what.casefold? ? "i":nil})|
|
356
|
-
when String
|
357
|
+
when String
|
357
358
|
%|#{how} == '#{element.what}'|
|
358
359
|
else
|
359
360
|
raise RuntimeError, "Unable to locate #{element.name} with #{element.how}"
|
@@ -365,6 +366,10 @@ for (var i = 0; i < document.links.length; i++) {
|
|
365
366
|
def checkbox_is_checked?(element = @element)
|
366
367
|
execute(element.operate { %|return element.checked;| }, element)
|
367
368
|
end
|
369
|
+
|
370
|
+
def element_disabled?(element = @element)
|
371
|
+
execute(element.operate { %|return element.disabled;| }, element)
|
372
|
+
end
|
368
373
|
|
369
374
|
def operate_by_input_value(element)
|
370
375
|
js.operate(%|
|
@@ -424,6 +429,13 @@ var element = elements[0];|, yield)
|
|
424
429
|
operate_by(element, 'innerText', &block)
|
425
430
|
end
|
426
431
|
|
432
|
+
def operate_by_xpath(element)
|
433
|
+
js.operate(%|
|
434
|
+
var result = document.evaluate('#{element.what}', document.documentElement, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
|
435
|
+
var element = result ? result.singleNodeValue : null;
|
436
|
+
|, yield)
|
437
|
+
end
|
438
|
+
|
427
439
|
def operate_by(element, attribute)
|
428
440
|
js.operate(%|var elements = document.getElementsByTagName('#{element.tag}');
|
429
441
|
var element = undefined;
|
@@ -511,13 +523,13 @@ SCRIPT`
|
|
511
523
|
def execute(script, element = nil)
|
512
524
|
response = eval_js(script)
|
513
525
|
case response
|
514
|
-
when NO_RESPONSE
|
526
|
+
when NO_RESPONSE
|
515
527
|
nil
|
516
|
-
when ELEMENT_NOT_FOUND
|
528
|
+
when ELEMENT_NOT_FOUND
|
517
529
|
raise UnknownObjectException, "Unable to locate #{element.name} element with #{element.how} of #{element.what}"
|
518
|
-
when TABLE_CELL_NOT_FOUND
|
530
|
+
when TABLE_CELL_NOT_FOUND
|
519
531
|
raise UnknownCellException, "Unable to locate a table cell with #{element.how} of #{element.what}"
|
520
|
-
when FRAME_NOT_FOUND
|
532
|
+
when FRAME_NOT_FOUND
|
521
533
|
raise UnknownFrameException, "Unable to locate a frame with name #{element.name}"
|
522
534
|
else
|
523
535
|
response
|
data/safariwatir.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{safariwatir}
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.6"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Dave Hoover"]
|
9
|
-
s.date = %q{2009-02
|
9
|
+
s.date = %q{2009-08-02}
|
10
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
11
|
s.email = %q{dave@obtiva.com}
|
12
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", "
|
13
|
+
s.files = ["lib/safariwatir/core_ext.rb", "lib/safariwatir/scripter.rb", "lib/safariwatir.rb", "lib/watir/exceptions.rb", "Rakefile", "README.rdoc", "safariwatir.gemspec", "safariwatir_example.rb"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{http://safariwatir.rubyforge.org/}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Safariwatir", "--main", "README.rdoc"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redsquirrel-safariwatir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Hoover
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02
|
12
|
+
date: 2009-08-02 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -39,13 +39,13 @@ files:
|
|
39
39
|
- lib/safariwatir/scripter.rb
|
40
40
|
- lib/safariwatir.rb
|
41
41
|
- lib/watir/exceptions.rb
|
42
|
-
- Manifest
|
43
42
|
- Rakefile
|
44
43
|
- README.rdoc
|
45
44
|
- safariwatir.gemspec
|
46
45
|
- safariwatir_example.rb
|
47
46
|
has_rdoc: true
|
48
47
|
homepage: http://safariwatir.rubyforge.org/
|
48
|
+
licenses:
|
49
49
|
post_install_message:
|
50
50
|
rdoc_options:
|
51
51
|
- --line-numbers
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements: []
|
72
72
|
|
73
73
|
rubyforge_project: safariwatir
|
74
|
-
rubygems_version: 1.
|
74
|
+
rubygems_version: 1.3.5
|
75
75
|
signing_key:
|
76
76
|
specification_version: 2
|
77
77
|
summary: Automated testing tool for web applications.
|