Perhaps this isn't actually the issue I'm experiencing, but it seems that when I "click_link" a link with target="_blank", the session keeps the focus on the current window.
So I either want to be able to switch to the new window, or to ignore the _blank attribute - essentially, I just want it to actually go to the page indicated by the link so I can make sure it's the right page.
I use the webkit and selenium drivers.
I submitted my findings thus far below. A more thorough answer is much appreciated.
Also, this only works with selenium - the equivalent for the webkit driver (or pointing out where I could discover it myself) would be much appreciated.
As of May 2014 the following code works on capybara-webkit
To explicitly change window, you use switch_to_window
An after that method browser will work in the new page, instead of wrap everything in a within_window block
Capybara provides some methods to ease finding and switching windows:
More details here: Capybara documentation
I know this is old post, but for what its worth in capybara 2.4.4
The best idea is to update capybara to the latests version (2.4.1) and just use
windows.last
becausepage.driver.browser.window_handles
is deprecated.This works for me in capybara-webkit:
(I'm using capybara 2.4.1 and capybara-webkit 1.3.0)