Last Updated: February 25, 2016
·
3.392K
· 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

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside