module Capybara::Lockstep::VisitWithWaiting
Public Instance Methods
visit(*args, &block)
click to toggle source
Calls superclass method
# File lib/capybara-lockstep/capybara_ext.rb, line 6 def visit(*args, &block) url = args[0] # Some of our apps have a Cucumber step that changes drivers mid-scenario. # It works by creating a new Capybara session and re-visits the URL from the # previous session. If this happens before a URL is ever loaded, # it re-visits the URL "data:", which will never "finish" initializing. # Also when opening a new tab via Capybara, the initial URL is about:blank. visiting_remote_url = !(url.start_with?('data:') || url.start_with?('about:')) if visiting_remote_url # We're about to leave this screen, killing all in-flight requests. # Give pending form submissions etc. a chance to finish before we tear down # the browser environment. # # We force a non-lazy synchronization so we pick up all client-side changes # that have not been caused by Capybara commands. Lockstep.synchronize(lazy: false) end super(*args, &block).tap do if visiting_remote_url # We haven't yet synchronized the new screen. Lockstep.synchronized = false end end end