Search code examples
rubyselenium-webdriverphantomjscapybarasite-prism

Need to Restart PhantomjS when it hangs


I want to restart my Phantomjs Driver when it hangs. I have an example of restarting poltergiest as below:

if driver.is_a?(Capybara::Poltergeist::Driver)
driver.restart
end

I am not using Poltergeist driver. I am using phantomjs driver object like this below:

Capybara::Selenium::Driver.new(app, :browser => :phantomjs)

I need to know how to restart phantomjs driver. I need something like this:

Capybara.page.driver.restart. 

Solution

  • page.driver.quit should quit the selenium::webdriver instance which should then automatically start a new one the next time the session is used.