Created
February 8, 2016 10:59
-
-
Save msp/cbf3537dc856fd7a3f80 to your computer and use it in GitHub Desktop.
This is hacked from the link on line 1 and not really tested but, breadcrumbs! Stick in env.rb (Cukes) or spec_helper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/ariya/phantomjs/issues/12234 | |
CAPYBARA_TIMEOUT_RETRIES = 3 | |
Around do |scenario, block| | |
CAPYBARA_TIMEOUT_RETRIES.times do |i| | |
begin | |
block.call | |
break | |
rescue => Capybara::Poltergeist::StatusFailError | |
puts("\nCapybara::Poltergeist::StatusFailError\n Restarting phantomjs and retrying...") | |
restart_phantomjs | |
end | |
end | |
end | |
# https://gist.github.com/afn/c04ccfe71d648763b306 | |
def restart_phantomjs | |
puts "-> Restarting phantomjs: iterating through capybara sessions..." | |
session_pool = Capybara.send('session_pool') | |
puts "session_pool length:#{session_pool.length}" | |
session_pool.each do |mode,session| | |
msg = " => #{mode} -- " | |
driver = session.driver | |
if driver.is_a?(Capybara::Poltergeist::Driver) | |
msg += "restarting" | |
driver.restart | |
else | |
msg += "not poltergeist: #{driver.class}" | |
end | |
puts msg | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment