def window_opened_by(**options)
      old_handles = driver.window_handles
      yield

      synchronize_windows(options) do
        opened_handles = (driver.window_handles - old_handles)
        if opened_handles.size != 1
          raise Capybara::WindowError, 'block passed to #window_opened_by '\
                                       "opened #{opened_handles.size} windows instead of 1"
        end
        Window.new(self, opened_handles.first)
      end
    end
def window_opened_by(**options)
      old_handles = driver.window_handles
      yield

      synchronize_windows(options) do
        opened_handles = (driver.window_handles - old_handles)
        if opened_handles.size != 1
          raise Capybara::WindowError, 'block passed to #window_opened_by '\
                                       "opened #{opened_handles.size} windows instead of 1"
        end
        Window.new(self, opened_handles.first)
      end
    end
Get the window that has been opened by the passed block.
 It will wait for it to be opened (in the same way as other Capybara methods wait).
 It's better to use this method than `windows.last`
 {https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html#h_note_10 as order of windows isn't defined in some drivers}

 @overload window_opened_by(**options, &block)
   @param options [Hash]
   @option options [Numeric] :wait (Capybara.default_max_wait_time) maximum wait time
   @return [Capybara::Window]       the window that has been opened within a block
   @raise [Capybara::WindowError]   if block passed to window hasn't opened window
     or opened more than one window