Class: Cornucopia::Capybara::PageDiagnostics::WindowIterator
- Inherits:
-
Object
- Object
- Cornucopia::Capybara::PageDiagnostics::WindowIterator
- Defined in:
- lib/cornucopia/capybara/page_diagnostics/window_iterator.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(window_handles, current_window, diagnostics) ⇒ WindowIterator
constructor
A new instance of WindowIterator.
Constructor Details
#initialize(window_handles, current_window, diagnostics) ⇒ WindowIterator
Returns a new instance of WindowIterator.
12 13 14 15 16 |
# File 'lib/cornucopia/capybara/page_diagnostics/window_iterator.rb', line 12 def initialize(window_handles, current_window, diagnostics) @window_handles = window_handles @current_window = current_window @diagnostics = diagnostics end |
Instance Method Details
#each(&block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cornucopia/capybara/page_diagnostics/window_iterator.rb', line 18 def each(&block) begin @diagnostics.allow_other_windows = false if @window_handles.length > 1 @window_handles.each do |window_handle| unless @current_window && @current_window == window_handle switched = @diagnostics.execute_driver_function(:switch_to_window, "could not switch windows", window_handle) if switched != "could not switch windows" block.yield @diagnostics end end end end ensure @diagnostics.allow_other_windows = true @diagnostics.execute_driver_function(:switch_to_window, "could not switch windows", @current_window) end end |