class Capybara::Selenium::Driver

def within_given_window(handle)

def within_given_window(handle)
  original_handle = current_window_handle
  if handle == original_handle
    yield
  else
    switch_to_window(handle)
    result = yield
    switch_to_window(original_handle)
    result
  end
end