class Capybara::Window
def wait_for_stable_size(seconds = session.config.default_max_wait_time)
def wait_for_stable_size(seconds = session.config.default_max_wait_time) res = yield if block_given? timer = Capybara::Helpers.timer(expire_in: seconds) loop do prev_size = size sleep 0.05 return res if prev_size == size break if timer.expired? end raise Capybara::WindowError, "Window size not stable within #{seconds} seconds." end