Class: Cornucopia::Capybara::PageDiagnostics::WindowIterator
- Inherits:
-
Object
- Object
- Cornucopia::Capybara::PageDiagnostics::WindowIterator
- Defined in:
- lib/cornucopia/capybara/page_diagnostics.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.
108 109 110 111 112 |
# File 'lib/cornucopia/capybara/page_diagnostics.rb', line 108 def initialize(window_handles, current_window, diagnostics) @window_handles = window_handles @current_window = current_window @diagnostics = diagnostics end |
Instance Method Details
#each(&block) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/cornucopia/capybara/page_diagnostics.rb', line 114 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 |