Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
window.location and current_path/current_url #220
scenario "reload the page selecting the city", :js => true do select('London', from: 'search_location') current_path.should == '/London' end
Using the Selenium driver the test passes but when I use Poltergeist, unless I put a sleep 0.1 statement between the select and the current_path test, it refuses to pass.
I'm not sure what can be done about this from Poltergeist's perspective. We do explicit synchronisation for
I think the best solution would be for Capybara to support a matcher like:
That imaginary matcher would cause Capybara to poll until either the timeout is reached or the path matches.
Maybe you could work on adding that to Capybara?
@jonleighton not to reopen a can of worms but just to let you know that this is not that a super uncommon problem.
We ran into the same thing while driving eBay's sign-in form, where submitting resorts to
As an aside, we had the same issue with CasperJS (we continually shop around for the best toolkit) so am assuming the behaviour originates in PhantomJS rather than Poltergeist.
For posterity, one of the many possible hacks to make Poltergeist roll on in a less inelegant way than simply sleeping is:
page.document.synchronize do raise Capybara::ElementNotFound if current_url.include?('signin') # a phrase that matches the final URL end
Of course, it would have been great if the page just redirected as expected.
@monsteronfire Shouldn't make any difference how you're triggering the page change, the have_current_path matcher will wait/retry until the "browser" tells Capybara it's on that page, or Capybara.default_max_wait_time seconds has expired (which will raise an error). The only difference when dealing with an external domain is that you might want to pass the