Aug 31, 2011

Capybara and the problem with window.opener

I have encountered a really strange problem. When Capybara opens a new window with <a href=".." target="..">.

The new window cannot call window.opener in its Javascript code.

The problem occurs because Capybara starts the first browser with http://127.0.0.1:57214. But my <a href> points to http://localhost:57214.

They points to different domain names. That's why Firefox does not allow reference between windows.

It is amazing how the problem is not really relevant to Capybara.

Anyway, the way to solve it is to change default domain name of Capybara.



Put the above lines somewhere in spec_helper.rb