commonwatir 1.6.5 → 1.6.6.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +461 -0
- data/{README.txt → LICENSE} +22 -48
- data/Rakefile +13 -11
- data/VERSION +1 -0
- data/lib/commonwatir.rb +3 -3
- data/lib/watir.rb +7 -6
- data/lib/watir/assertions.rb +44 -44
- data/lib/watir/browser.rb +149 -149
- data/lib/watir/browsers.rb +13 -12
- data/lib/watir/exceptions.rb +47 -47
- data/lib/watir/matches.rb +17 -17
- data/lib/watir/options.rb +53 -52
- data/lib/watir/testcase.rb +97 -58
- data/lib/watir/waiter.rb +91 -91
- data/unittests/attach_to_existing_window_test.rb +71 -0
- data/unittests/browser_test.rb +18 -0
- data/unittests/buttons_test.rb +224 -0
- data/unittests/dd_test.rb +70 -0
- data/unittests/dl_test.rb +68 -0
- data/unittests/dt_test.rb +68 -0
- data/unittests/element_collections_test.rb +22 -0
- data/unittests/em_test.rb +67 -0
- data/unittests/form2_test.rb +22 -0
- data/unittests/html/blankpage.html +12 -0
- data/unittests/html/buttons1.html +41 -0
- data/unittests/html/buttons2.html +61 -0
- data/unittests/html/definition_lists.html +48 -0
- data/unittests/html/emphasis.html +12 -0
- data/unittests/html/entertainment_com.html +668 -0
- data/unittests/html/frame_buttons.html +4 -0
- data/unittests/html/images/button.jpg +0 -0
- data/unittests/html/pass.html +10 -0
- data/unittests/html/phrase_elements.html +15 -0
- data/unittests/html/select_lists.html +18 -0
- data/unittests/html/utf8.html +12 -0
- data/unittests/html/visibility.html +90 -0
- data/unittests/html/watir_unit_tests.css +64 -0
- data/unittests/html/whitespace.html +29 -0
- data/unittests/inspect_test.rb +29 -0
- data/unittests/options.yml.example +13 -0
- data/unittests/select_list_test.rb +19 -0
- data/unittests/setup.rb +17 -0
- data/unittests/setup/browser.rb +14 -0
- data/unittests/setup/capture_io_helper.rb +17 -0
- data/unittests/setup/filter.rb +24 -0
- data/unittests/setup/lib.rb +22 -0
- data/unittests/setup/options.rb +29 -0
- data/unittests/setup/testUnitAddons.rb +8 -0
- data/unittests/setup/watir-unittest.rb +74 -0
- data/unittests/strong_test.rb +32 -0
- data/unittests/utf8_test.rb +24 -0
- data/unittests/visibility_test.rb +47 -0
- data/unittests/whitespace_test.rb +40 -0
- metadata +121 -39
- data/History.txt +0 -5
- data/Manifest.txt +0 -14
data/lib/watir/browsers.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
#--
|
2
|
+
# watir/browsers
|
3
|
+
# Define browsers supported by Watir
|
4
|
+
|
5
|
+
Watir::Browser.support :name => 'ie', :class => 'Watir::IE',
|
6
|
+
:library => 'watir/ie', :gem => 'watir',
|
7
|
+
:options => [:speed, :visible]
|
8
|
+
|
9
|
+
Watir::Browser.support :name => 'firefox', :class => 'FireWatir::Firefox',
|
10
|
+
:library => 'firewatir'
|
11
|
+
|
12
|
+
Watir::Browser.support :name => 'safari', :class => 'Watir::Safari',
|
13
|
+
:library => 'safariwatir'
|
data/lib/watir/exceptions.rb
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
module Watir
|
2
|
-
module Exception
|
3
|
-
|
4
|
-
# Root class for all Watir Exceptions
|
5
|
-
class WatirException < RuntimeError
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
# This exception is
|
12
|
-
class UnknownObjectException < WatirException; end
|
13
|
-
# This exception is
|
14
|
-
class ObjectDisabledException < WatirException; end
|
15
|
-
# This exception is
|
16
|
-
class UnknownFrameException< WatirException; end
|
17
|
-
# This exception is
|
18
|
-
class UnknownFormException< WatirException; end
|
19
|
-
# This exception is
|
20
|
-
class ObjectReadOnlyException < WatirException; end
|
21
|
-
# This exception is
|
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
|
28
|
-
class NoMatchingWindowFoundException < WatirException; end
|
29
|
-
# This exception is
|
30
|
-
class NoStatusBarException < WatirException; end
|
31
|
-
# This exception is
|
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
|
-
# Return an error message for when unable to locate the element
|
42
|
-
def self.message_for_unable_to_locate(how, what)
|
43
|
-
result = "using #{how.inspect}"
|
44
|
-
result << ", #{what.inspect}" if what
|
45
|
-
"Unable to locate element, #{result}"
|
46
|
-
end
|
47
|
-
end
|
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 raised if an attempt is made to access an object that doesn't exist
|
12
|
+
class UnknownObjectException < WatirException; end
|
13
|
+
# This exception is raised if an attempt is made to access an object that is in a disabled state
|
14
|
+
class ObjectDisabledException < WatirException; end
|
15
|
+
# This exception is raised if an attempt is made to access a frame that cannot be found
|
16
|
+
class UnknownFrameException< WatirException; end
|
17
|
+
# This exception is raised if an attempt is made to access a form that cannot be found
|
18
|
+
class UnknownFormException< WatirException; end
|
19
|
+
# This exception is raised 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 raised 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 raised if the window cannot be found
|
28
|
+
class NoMatchingWindowFoundException < WatirException; end
|
29
|
+
# This exception is raised 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 raised 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
|
+
# Return an error message for when unable to locate the element
|
42
|
+
def self.message_for_unable_to_locate(how, what)
|
43
|
+
result = "using #{how.inspect}"
|
44
|
+
result << ", #{what.inspect}" if what
|
45
|
+
"Unable to locate element, #{result}"
|
46
|
+
end
|
47
|
+
end
|
48
48
|
end
|
data/lib/watir/matches.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
class String
|
2
|
-
def matches(x)
|
3
|
-
return self == x
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
class Regexp
|
8
|
-
def matches(x)
|
9
|
-
return self.match(x)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class Integer
|
14
|
-
def matches(x)
|
15
|
-
return self == x
|
16
|
-
end
|
17
|
-
end
|
1
|
+
class String
|
2
|
+
def matches(x)
|
3
|
+
return self == x
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class Regexp
|
8
|
+
def matches(x)
|
9
|
+
return self.match(x)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Integer
|
14
|
+
def matches(x)
|
15
|
+
return self == x
|
16
|
+
end
|
17
|
+
end
|
data/lib/watir/options.rb
CHANGED
@@ -1,52 +1,53 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@@
|
9
|
-
|
10
|
-
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# they
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
:
|
40
|
-
:
|
41
|
-
|
42
|
-
:
|
43
|
-
:
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
@user_choices
|
50
|
-
|
51
|
-
|
52
|
-
end
|
1
|
+
#--
|
2
|
+
# watir/options
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
require 'user-choices'
|
6
|
+
|
7
|
+
module Watir
|
8
|
+
@@options_file = nil
|
9
|
+
@@options = nil
|
10
|
+
class << self
|
11
|
+
# Specify the location of a yaml file containing Watir options. Must be
|
12
|
+
# specified before the options are parsed.
|
13
|
+
def options_file= file
|
14
|
+
@@options_file = file
|
15
|
+
end
|
16
|
+
def options_file
|
17
|
+
@@options_file
|
18
|
+
end
|
19
|
+
def options= x
|
20
|
+
@@options = x
|
21
|
+
end
|
22
|
+
# Return the Watir options, as a hash. If they haven't been parsed yet,
|
23
|
+
# they will be now.
|
24
|
+
def options
|
25
|
+
@@options ||= Watir::Options.new.execute
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Options < UserChoices::Command
|
30
|
+
include UserChoices
|
31
|
+
def add_sources builder
|
32
|
+
builder.add_source EnvironmentSource, :with_prefix, 'watir_'
|
33
|
+
if Watir.options_file
|
34
|
+
builder.add_source YamlConfigFileSource, :from_complete_path,
|
35
|
+
Watir.options_file
|
36
|
+
end
|
37
|
+
end
|
38
|
+
def add_choices builder
|
39
|
+
builder.add_choice :browser,
|
40
|
+
:type => Watir::Browser.browser_names,
|
41
|
+
:default => Watir::Browser.default
|
42
|
+
builder.add_choice :speed,
|
43
|
+
:type => ['slow', 'fast', 'zippy'],
|
44
|
+
:default => 'fast'
|
45
|
+
builder.add_choice :visible,
|
46
|
+
:type => :boolean
|
47
|
+
end
|
48
|
+
def execute
|
49
|
+
@user_choices[:speed] = @user_choices[:speed].to_sym
|
50
|
+
@user_choices
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/watir/testcase.rb
CHANGED
@@ -1,58 +1,97 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'watir/assertions'
|
3
|
-
|
4
|
-
module Watir
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
1
|
+
require 'test/unit'
|
2
|
+
require 'watir/assertions'
|
3
|
+
|
4
|
+
module Watir
|
5
|
+
|
6
|
+
# This is a 'test/unit' testcase customized to exeucte test methods sequentially by default
|
7
|
+
# and extra assertions
|
8
|
+
#
|
9
|
+
# Example Usage
|
10
|
+
#
|
11
|
+
# require 'watir/testcase'
|
12
|
+
#
|
13
|
+
# class MyTestCase < Watir::TestCase
|
14
|
+
#
|
15
|
+
# # some helpers
|
16
|
+
# @@browser = nil
|
17
|
+
# def browser
|
18
|
+
# @browser ||= Watir::IE.start(:url, 'http://watir.com/")
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# # TESTS
|
22
|
+
# def test_text
|
23
|
+
# browser.goto "http://watir.com/"
|
24
|
+
# verify_match "Web Application Testing in Ruby", browser.text
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# def test_title
|
28
|
+
# verify browser.title == 'Watir'
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# def test_link
|
32
|
+
# verify_match 'watir.com', browser.link(:text, 'Home').href
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# def test_navigate_to_examples
|
36
|
+
# browser.div(:id, 'nav').link(:text, 'Examples').click
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# def test_url
|
40
|
+
# verify_equal browser.url, 'http://watir.com/examples/'
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
class TestCase < Test::Unit::TestCase
|
46
|
+
include Watir::Assertions
|
47
|
+
@@order = :sequentially
|
48
|
+
def initialize name
|
49
|
+
throw :invalid_test if name == :default_test && self.class == Watir::TestCase
|
50
|
+
super
|
51
|
+
end
|
52
|
+
class << self
|
53
|
+
attr_accessor :test_methods, :order
|
54
|
+
def test_methods
|
55
|
+
@test_methods ||= []
|
56
|
+
end
|
57
|
+
def order
|
58
|
+
@order || @@order
|
59
|
+
end
|
60
|
+
def default_order= order
|
61
|
+
@@order = order
|
62
|
+
end
|
63
|
+
def sorted_test_methods
|
64
|
+
case order
|
65
|
+
when :alphabetically then test_methods.sort
|
66
|
+
when :sequentially then test_methods
|
67
|
+
when :reversed_sequentially then test_methods.reverse
|
68
|
+
when :reversed_alphabetically then test_methods.sort.reverse
|
69
|
+
else raise ArgumentError, "Execute option not supported: #{@order}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
def suite
|
73
|
+
suite = Test::Unit::TestSuite.new(name)
|
74
|
+
sorted_test_methods.each do |test|
|
75
|
+
catch :invalid_test do
|
76
|
+
suite << new(test)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
if (suite.empty?)
|
80
|
+
catch :invalid_test do
|
81
|
+
suite << new(:default_test)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
return suite
|
85
|
+
end
|
86
|
+
def method_added id
|
87
|
+
name = id.id2name
|
88
|
+
test_methods << name if name =~ /^test./
|
89
|
+
end
|
90
|
+
def execute order
|
91
|
+
@order = order
|
92
|
+
end
|
93
|
+
end
|
94
|
+
public :add_assertion
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
data/lib/watir/waiter.rb
CHANGED
@@ -1,92 +1,92 @@
|
|
1
|
-
require 'watir/exceptions'
|
2
|
-
|
3
|
-
module Watir
|
4
|
-
|
5
|
-
def wait_until(*args)
|
6
|
-
Waiter.wait_until(*args) {yield}
|
7
|
-
end
|
8
|
-
|
9
|
-
class TimeKeeper
|
10
|
-
attr_reader :sleep_time
|
11
|
-
def initialize
|
12
|
-
@sleep_time = 0.0
|
13
|
-
end
|
14
|
-
def sleep seconds
|
15
|
-
@sleep_time += Kernel.sleep seconds
|
16
|
-
end
|
17
|
-
def now
|
18
|
-
Time.now
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class Waiter
|
23
|
-
# This is an interface to a TimeKeeper which proxies
|
24
|
-
# calls to "sleep" and "Time.now".
|
25
|
-
# Useful for unit testing Waiter.
|
26
|
-
attr_accessor :timer
|
27
|
-
|
28
|
-
# How long to wait between each iteration through the wait_until
|
29
|
-
# loop. In seconds.
|
30
|
-
attr_accessor :polling_interval
|
31
|
-
|
32
|
-
# Timeout for wait_until.
|
33
|
-
attr_accessor :timeout
|
34
|
-
|
35
|
-
@@default_polling_interval = 0.5
|
36
|
-
@@default_timeout = 60.0
|
37
|
-
|
38
|
-
def initialize(timeout=@@default_timeout,
|
39
|
-
polling_interval=@@default_polling_interval)
|
40
|
-
@timeout = timeout
|
41
|
-
@polling_interval = polling_interval
|
42
|
-
@timer = TimeKeeper.new
|
43
|
-
end
|
44
|
-
|
45
|
-
# Execute the provided block until either (1) it returns true, or
|
46
|
-
# (2) the timeout (in seconds) has been reached. If the timeout is reached,
|
47
|
-
# a TimeOutException will be raised. The block will always
|
48
|
-
# execute at least once.
|
49
|
-
#
|
50
|
-
# waiter = Waiter.new(5)
|
51
|
-
# waiter.wait_until {puts 'hello'}
|
52
|
-
#
|
53
|
-
# This code will print out "hello" for five seconds, and then raise a
|
54
|
-
# Watir::TimeOutException.
|
55
|
-
def wait_until # block
|
56
|
-
start_time = now
|
57
|
-
until yield do
|
58
|
-
if (duration = now - start_time) > @timeout
|
59
|
-
raise Watir::Exception::TimeOutException.new(duration, @timeout),
|
60
|
-
"Timed out after #{duration} seconds."
|
61
|
-
end
|
62
|
-
sleep @polling_interval
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Execute the provided block until either (1) it returns true, or
|
67
|
-
# (2) the timeout (in seconds) has been reached. If the timeout is reached,
|
68
|
-
# a TimeOutException will be raised. The block will always
|
69
|
-
# execute at least once.
|
70
|
-
#
|
71
|
-
# Waiter.wait_until(5) {puts 'hello'}
|
72
|
-
#
|
73
|
-
# This code will print out "hello" for five seconds, and then raise a
|
74
|
-
# Watir::TimeOutException.
|
75
|
-
|
76
|
-
# IDEA: wait_until: remove defaults from Waiter.wait_until
|
77
|
-
def self.wait_until(timeout=@@default_timeout,
|
78
|
-
polling_interval=@@default_polling_interval)
|
79
|
-
waiter = new(timeout, polling_interval)
|
80
|
-
waiter.wait_until { yield }
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
def sleep seconds
|
85
|
-
@timer.sleep seconds
|
86
|
-
end
|
87
|
-
def now
|
88
|
-
@timer.now
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
1
|
+
require 'watir/exceptions'
|
2
|
+
|
3
|
+
module Watir
|
4
|
+
|
5
|
+
def wait_until(*args)
|
6
|
+
Waiter.wait_until(*args) {yield}
|
7
|
+
end
|
8
|
+
|
9
|
+
class TimeKeeper
|
10
|
+
attr_reader :sleep_time
|
11
|
+
def initialize
|
12
|
+
@sleep_time = 0.0
|
13
|
+
end
|
14
|
+
def sleep seconds
|
15
|
+
@sleep_time += Kernel.sleep seconds
|
16
|
+
end
|
17
|
+
def now
|
18
|
+
Time.now
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Waiter
|
23
|
+
# This is an interface to a TimeKeeper which proxies
|
24
|
+
# calls to "sleep" and "Time.now".
|
25
|
+
# Useful for unit testing Waiter.
|
26
|
+
attr_accessor :timer
|
27
|
+
|
28
|
+
# How long to wait between each iteration through the wait_until
|
29
|
+
# loop. In seconds.
|
30
|
+
attr_accessor :polling_interval
|
31
|
+
|
32
|
+
# Timeout for wait_until.
|
33
|
+
attr_accessor :timeout
|
34
|
+
|
35
|
+
@@default_polling_interval = 0.5
|
36
|
+
@@default_timeout = 60.0
|
37
|
+
|
38
|
+
def initialize(timeout=@@default_timeout,
|
39
|
+
polling_interval=@@default_polling_interval)
|
40
|
+
@timeout = timeout
|
41
|
+
@polling_interval = polling_interval
|
42
|
+
@timer = TimeKeeper.new
|
43
|
+
end
|
44
|
+
|
45
|
+
# Execute the provided block until either (1) it returns true, or
|
46
|
+
# (2) the timeout (in seconds) has been reached. If the timeout is reached,
|
47
|
+
# a TimeOutException will be raised. The block will always
|
48
|
+
# execute at least once.
|
49
|
+
#
|
50
|
+
# waiter = Waiter.new(5)
|
51
|
+
# waiter.wait_until {puts 'hello'}
|
52
|
+
#
|
53
|
+
# This code will print out "hello" for five seconds, and then raise a
|
54
|
+
# Watir::TimeOutException.
|
55
|
+
def wait_until # block
|
56
|
+
start_time = now
|
57
|
+
until yield do
|
58
|
+
if (duration = now - start_time) > @timeout
|
59
|
+
raise Watir::Exception::TimeOutException.new(duration, @timeout),
|
60
|
+
"Timed out after #{duration} seconds."
|
61
|
+
end
|
62
|
+
sleep @polling_interval
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Execute the provided block until either (1) it returns true, or
|
67
|
+
# (2) the timeout (in seconds) has been reached. If the timeout is reached,
|
68
|
+
# a TimeOutException will be raised. The block will always
|
69
|
+
# execute at least once.
|
70
|
+
#
|
71
|
+
# Waiter.wait_until(5) {puts 'hello'}
|
72
|
+
#
|
73
|
+
# This code will print out "hello" for five seconds, and then raise a
|
74
|
+
# Watir::TimeOutException.
|
75
|
+
|
76
|
+
# IDEA: wait_until: remove defaults from Waiter.wait_until
|
77
|
+
def self.wait_until(timeout=@@default_timeout,
|
78
|
+
polling_interval=@@default_polling_interval)
|
79
|
+
waiter = new(timeout, polling_interval)
|
80
|
+
waiter.wait_until { yield }
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
def sleep seconds
|
85
|
+
@timer.sleep seconds
|
86
|
+
end
|
87
|
+
def now
|
88
|
+
@timer.now
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
92
|
end # module
|