My friend @pellegrino give me an awesome tip: to replace “Selenium” with “Poltergeist”. For those who don’t know, Poltergeist is a PhantomJS driver for Capybara. I’ve done it in some projects and it works so well!
So, let’s do it:
Include the gem to your Gemfile:
Update Capybara configuration:
Run the specs!
undefined method `switch_to'
While I was trying to fix it, I find out that Poltergeist always returns true from window.confirm. There’s no way (at the moment) to make it return false, but it should not prevent your test from running.
So, I just removed that line and it worked fine!
This is the improvement from the first project I’ve done it:
Before: Finished in 1 minute 35.45 seconds After: Finished in 41.03 seconds
Hope that can be useful for you!