Module: AePageObjects
- Defined in:
- lib/ae_page_objects.rb,
lib/ae_page_objects/node.rb,
lib/ae_page_objects/element.rb,
lib/ae_page_objects/version.rb,
lib/ae_page_objects/core/dsl.rb,
lib/ae_page_objects/document.rb,
lib/ae_page_objects/exceptions.rb,
lib/ae_page_objects/element_proxy.rb,
lib/ae_page_objects/elements/form.rb,
lib/ae_page_objects/document_proxy.rb,
lib/ae_page_objects/document_query.rb,
lib/ae_page_objects/document_loader.rb,
lib/ae_page_objects/elements/select.rb,
lib/ae_page_objects/core/basic_router.rb,
lib/ae_page_objects/elements/checkbox.rb,
lib/ae_page_objects/elements/collection.rb,
lib/ae_page_objects/single_window/window.rb,
lib/ae_page_objects/util/hash_symbolizer.rb,
lib/ae_page_objects/single_window/browser.rb,
lib/ae_page_objects/util/internal_helpers.rb,
lib/ae_page_objects/util/wait_time_manager.rb,
lib/ae_page_objects/multiple_windows/window.rb,
lib/ae_page_objects/multiple_windows/browser.rb,
lib/ae_page_objects/rails/application_router.rb,
lib/ae_page_objects/multiple_windows/window_list.rb,
lib/ae_page_objects/multiple_windows/window_handle_manager.rb,
lib/ae_page_objects/single_window/same_window_loader_strategy.rb,
lib/ae_page_objects/multiple_windows/cross_window_loader_strategy.rb
Defined Under Namespace
Modules: Dsl, InternalHelpers, MultipleWindows, SingleWindow Classes: ApplicationRouter, BasicRouter, CastError, Checkbox, Collection, Document, DocumentLoadError, DocumentLoader, DocumentProxy, DocumentQuery, Element, ElementNotAbsent, ElementNotHidden, ElementNotPresent, ElementNotVisible, ElementProxy, Error, Form, FrozenInTime, HashSymbolizer, LoadingElementFailed, LoadingPageFailed, Node, PathNotResolvable, Select, StalePageObject, WaitTimeManager, WaitTimeoutError, WindowNotFound
Constant Summary collapse
- VERSION =
'6.3.0'.freeze
Class Attribute Summary collapse
-
.default_router ⇒ Object
Returns the value of attribute default_router.
Class Method Summary collapse
Class Attribute Details
.default_router ⇒ Object
Returns the value of attribute default_router.
19 20 21 |
# File 'lib/ae_page_objects.rb', line 19 def default_router @default_router end |
Class Method Details
.browser ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ae_page_objects.rb', line 21 def browser @browser ||= begin driver = Capybara.current_session.driver case driver when Capybara::Selenium::Driver then require 'ae_page_objects/multiple_windows/browser' MultipleWindows::Browser.new else require 'ae_page_objects/single_window/browser' SingleWindow::Browser.new end end end |
.wait_until(seconds_to_wait = nil, error_message = nil, &block) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ae_page_objects.rb', line 36 def wait_until(seconds_to_wait = nil, = nil, &block) @wait_until ||= 0 @wait_until += 1 result = nil if @wait_until > 1 # We want to ensure that only the top-level wait_until does the waiting error handling, # which allows correct timing and best chance of recovering from an error. result = call_wait_until_block(, &block) else seconds_to_wait ||= default_max_wait_time start_time = Time.now # In an effort to avoid flakiness, Capybara waits, rescues errors, reloads nodes, and # retries. # # There are cases when Capybara will rescue an error and either nodes are not # reloadable or the DOM has changed in a such a way that no amount of reloading will # help (but perhaps a retry at the higher level may have a chance of success). This leads # to us needless waiting for a long time just to fail. # # There are also cases when Selenium will take such a long time to respond with an error # that Capybara's timeout will be exceeded and no reloading / retrying will occur. Instead, # Capabara will just raise the error. # # In order to combat the two cases, we start with a lower Capybara wait time and increase # it each iteration. This logic is encapsulated in a little utility class. time_manager = WaitTimeManager.new(1.0, seconds_to_wait) begin result = time_manager.using_wait_time { call_wait_until_block(, &block) } rescue => e errors = Capybara.current_session.driver.invalid_element_errors errors += [Capybara::ElementNotFound] errors += [DocumentLoadError, LoadingElementFailed, LoadingPageFailed] errors += [WaitTimeoutError] raise e unless errors.include?(e.class) delay = seconds_to_wait - (Time.now - start_time) if delay <= 0 # Raising the WaitTimeoutError in the rescue block ensures that Ruby attaches # the original exception as the cause for our WaitTimeoutError. raise WaitTimeoutError, e. end sleep(0.05) raise FrozenInTime, "Time appears to be frozen" if Time.now == start_time retry end end result ensure @wait_until -= 1 end |