Last Updated: February 25, 2016
· freegenie

Testing window.location with capybara

Capybara does not follow redirect if the page is changing due to a change in window.location. This is typical in backbone apps.

In capybara current_path only changes after an HTTP redirect.

As a workaround, you can test the content of the destination page.

For example, when writing cucumber steps, if the other page has a "browse" label, you can test it with:

Then I should see "browse"

Instead of:

Then I should be on the browse page
Say Thanks