Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added default override for page level waits - default_page_wait

  • Loading branch information...
commit 02489886870017e30a50dcf85c1455c663ced4c2 1 parent 8ab52a0
@cheezy cheezy authored
View
1  ChangeLog
@@ -2,6 +2,7 @@
* Enhancements
* Added flash method to Element to temporarily change the background color
* Added when_not_present method to Element
+ * Added default override for page level waits - PageObject.default_page_wait
* Updated to use watir-webdriver 0.5.7
* Fixes
* Improved logic around selecting options from select lists
View
16 lib/page-object.rb
@@ -65,6 +65,20 @@ def self.included(cls)
end
#
+ # Set the default timeout for page level waits
+ #
+ def self.default_page_wait=(timeout)
+ @page_wait = timeout
+ end
+
+ #
+ # Returns the default timeout for page lavel waits
+ #
+ def self.default_page_wait
+ @page_wait ||= 30
+ end
+
+ #
# Set the javascript framework to use when determining number of
# ajax requests. Valid frameworks are :jquery and :prototype
#
@@ -135,7 +149,7 @@ def title
# @param [String] the message to include with the error if we exceed the timeout duration.
# @param block the block to execute. It should return true when successful.
#
- def wait_until(timeout = 30, message = nil, &block)
+ def wait_until(timeout = PageObject.default_page_wait, message = nil, &block)
platform.wait_until(timeout, message, &block)
end
View
6 spec/page-object/page-object_spec.rb
@@ -110,6 +110,12 @@ def initialize_page
watir_page_object.wait_until(5, "too long")
end
+ it "should use the overriden timeout value when set" do
+ PageObject.default_page_wait = 10
+ watir_browser.should_receive(:wait_until).with(10, nil)
+ watir_page_object.wait_until
+ end
+
it "should wait until there are no pending ajax requests" do
PageObject::JavascriptFrameworkFacade.should_receive(:pending_requests).and_return('pending requests')
watir_browser.should_receive(:execute_script).with('pending requests').and_return(0)
Please sign in to comment.
Something went wrong with that request. Please try again.