Class: AePageObjects::MultipleWindows::CrossWindowLoaderStrategy
- Inherits:
-
Object
- Object
- AePageObjects::MultipleWindows::CrossWindowLoaderStrategy
- Defined in:
- lib/ae_page_objects/multiple_windows/cross_window_loader_strategy.rb
Instance Method Summary collapse
- #document_not_loaded_error_message(query) ⇒ Object
-
#initialize(window_list) ⇒ CrossWindowLoaderStrategy
constructor
A new instance of CrossWindowLoaderStrategy.
- #load_document_with_condition(condition) ⇒ Object
Constructor Details
#initialize(window_list) ⇒ CrossWindowLoaderStrategy
Returns a new instance of CrossWindowLoaderStrategy.
5 6 7 8 9 10 |
# File 'lib/ae_page_objects/multiple_windows/cross_window_loader_strategy.rb', line 5 def initialize(window_list) @window_list = window_list @original_window = window_list.current_window @current_window_loader = SingleWindow::SameWindowLoaderStrategy.new end |
Instance Method Details
#document_not_loaded_error_message(query) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/ae_page_objects/multiple_windows/cross_window_loader_strategy.rb', line 39 def (query) all_windows = @window_list.opened.map do |window| name = window.current_document && window.current_document.to_s || "<none>" {:window_handle => window.handle, :document => name } end "Couldn't find document with type in #{query.permitted_types_dump} in any of the open windows: #{all_windows.inspect}" end |
#load_document_with_condition(condition) ⇒ Object
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 |
# File 'lib/ae_page_objects/multiple_windows/cross_window_loader_strategy.rb', line 12 def load_document_with_condition(condition) # Look in the current window first unless told not to unless condition.document_conditions[:ignore_current] @original_window.switch_to if document = @current_window_loader.load_document_with_condition(condition) return document end end # Loop through all the windows and attempt to instantiate the Document. Continue to loop around # until finding a Document that can be instantiated or timing out. @window_list.opened.each do |window| next if window == @original_window window.switch_to if document = @current_window_loader.load_document_with_condition(condition) return document end end @original_window.switch_to nil end |