Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added WaitHelper module for possible inclusion with methods like #wai…

…t_until and #wait_while

renamed Wait methods to .until and .while
  • Loading branch information...
commit 0043c71365f503e62b0419e6c5d9541f7f221f38 1 parent bb311ee
@jarmo jarmo authored
View
5 CHANGES
@@ -1,9 +1,9 @@
== Version 1.6.7 - 2010/XX/XX
-=== Common improvements
+=== General improvements
-* added new waiting methods on Watir::IE and Watir::Firefox: #wait_until and #wait_while (Jari Bakken and Jarmo Pertman)
* added new waiting methods on Watir::Element: #when_present, #wait_until_present and #wait_while_present (Jari Bakken and Jarmo Pertman)
+* added new waiting methods on Watir::IE and Watir::Firefox: #wait_until and #wait_while (Jari Bakken and Jarmo Pertman)
* added method #present? for Watir::Element (Jari Bakken and Jarmo Pertman)
* deprecated old waiting methods in Watir::Waiter - if you really need to use it then you'd have to require "watir/waiter",
but it's recommended to use Watir::Wait instead because Watir::Waiter will be removed completely in the future versions (Jarmo Pertman)
@@ -12,7 +12,6 @@
* removed Watir::Simple (Željko Filipin)
-
=== Firefox improvements
* get_attribute_value now works with attributes named something like "foo-bar" (Alan Shields)
View
1  commonwatir/lib/watir.rb
@@ -4,6 +4,7 @@
# implementations.
require 'watir/wait'
+require 'watir/wait_helper'
require 'watir/element_extensions'
require 'watir/exceptions'
require 'watir/matches'
View
8 commonwatir/lib/watir/element_extensions.rb
@@ -20,7 +20,7 @@ def method_missing(m, *args, &block)
raise NoMethodError, "undefined method `#{m}' for #{@element.inspect}:#{@element.class}"
end
- Watir::Wait.wait_until(@timeout) { @element.present? }
+ Watir::Wait.until(@timeout) { @element.present? }
@element.send(m, *args, &block)
end
end
@@ -47,7 +47,7 @@ def present?
def when_present(timeout = 60)
if block_given?
- Watir::Wait.wait_until(timeout) { self.present? }
+ Watir::Wait.until(timeout) { self.present? }
yield self
else
return WhenPresentDecorator.new(self, timeout)
@@ -55,11 +55,11 @@ def when_present(timeout = 60)
end
def wait_until_present(timeout = 60)
- Watir::Wait.wait_until(timeout) { self.present? }
+ Watir::Wait.until(timeout) { self.present? }
end
def wait_while_present(timeout = 60)
- Watir::Wait.wait_while(timeout) { self.present? }
+ Watir::Wait.while(timeout) { self.present? }
end
end # module ElementExtensions
View
4 commonwatir/lib/watir/wait.rb
@@ -11,7 +11,7 @@ class TimeoutError < StandardError
# Wait until the block evaluates to true or times out.
#
- def wait_until(timeout = 60, &block)
+ def until(timeout = 60, &block)
end_time = ::Time.now + timeout
until ::Time.now > end_time
@@ -26,7 +26,7 @@ def wait_until(timeout = 60, &block)
#
# Wait while the block evaluates to true or times out.
#
- def wait_while(timeout = 60, &block)
+ def while(timeout = 60, &block)
end_time = ::Time.now + timeout
until ::Time.now > end_time
View
12 commonwatir/lib/watir/wait_helper.rb
@@ -0,0 +1,12 @@
+# include this module if there's a need to have wait_until and wait_while methods in some different scope
+module Watir
+ module WaitHelper
+ def wait_until(*args, &blk)
+ Wait.until(*args, &blk)
+ end
+
+ def wait_while(*args, &blk)
+ Wait.while(*args, &blk)
+ end
+ end
+end
View
18 commonwatir/unittests/wait_test.rb
@@ -98,4 +98,22 @@ def test_wait_while_present
def test_wait_while_present_exception
assert_raises(Watir::Wait::TimeoutError) {browser.div(:id => "div1").wait_while_present(0.1)}
end
+
+ def test_wait_module_until
+ div = browser.div(:id => "div1")
+ assert div.visible?
+ browser.link(:id => "link1").click
+
+ Watir::Wait.until(2) {not div.visible?}
+ assert !div.visible?
+ end
+
+ def test_wait_module_while
+ div = browser.div(:id => "div1")
+ assert div.visible?
+ browser.link(:id => "link1").click
+
+ Watir::Wait.while(2) {div.visible?}
+ assert !div.visible?
+ end
end
View
2  firewatir/lib/firewatir/firefox.rb
@@ -3,7 +3,7 @@ module FireWatir
include Watir::Exception
class Firefox
- include Watir::Wait
+ include Watir::WaitHelper
include FireWatir::Container
# XPath Result type. Return only first node that matches the xpath expression.
View
2  watir/lib/watir/contrib/enabled_popup.rb
@@ -7,7 +7,7 @@ def enabled_popup(timeout=4)
# Use handle of our parent window to see if we have any currently
# enabled popup.
hwnd_modal = 0
- Wait.wait_until(timeout) do
+ Wait.until(timeout) do
hwnd_modal, arr = GetWindow.call(hwnd, GW_ENABLEDPOPUP)
hwnd_modal > 0
end
View
2  watir/lib/watir/ie-class.rb
@@ -1,6 +1,6 @@
module Watir
class IE
- include Wait
+ include WaitHelper
include Exception
include Container
include PageContainer
View
2  watir/lib/watir/ie-process.rb
@@ -17,7 +17,7 @@ def initialize process_id
attr_reader :process_id
def window
- Wait.wait_until do
+ Wait.until do
IE.each do | ie |
window = ie.ie
hwnd = ie.hwnd
View
2  watir/lib/watir/module.rb
@@ -7,7 +7,7 @@ module Watir
# Like regular Ruby "until", except that a TimeOutException is raised
# if the timeout is exceeded. Timeout is IE.attach_timeout.
def self.until_with_timeout # block
- Wait.wait_until(IE.attach_timeout) { yield }
+ Wait.until(IE.attach_timeout) { yield }
end
@@autoit = nil
View
3  watir/unittests/windows/frame_links_test.rb
@@ -4,7 +4,6 @@
require 'unittests/setup'
class TC_Frame_Links < Test::Unit::TestCase
- include Watir
def setup
goto_page "frame_links.html"
@@ -17,7 +16,7 @@ def test_click_in_a_frame
def test_click_no_wait_in_a_frame
browser.frame('linkFrame').link(:text, 'test1').click_no_wait
- wait_until(10){browser.frame('linkFrame').text.include?('Links2-Pass')}
+ Wait.until(10){browser.frame('linkFrame').text.include?('Links2-Pass')}
assert(browser.frame('linkFrame').text.include?('Links2-Pass'))
end
View
3  watir/unittests/windows/ie-each_test.rb
@@ -39,9 +39,8 @@ def test_return_type
Watir::IE.each {|ie| assert_equal(Watir::IE, ie.class)}
end
- include Watir
def teardown
@ie.each {|ie| ie.close }
- wait_until {Watir::IE.process_count == 0}
+ Wait.until {Watir::IE.process_count == 0}
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.