With Capybara, how do I switch to the new window for links with “_blank” targets?

0
0

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.

  • You must to post comments
0
0

Capybara >= 2.3 includes the new window management API. It can be used like:

new_window = window_opened_by { click_link 'Something' }
within_window new_window
do
# code
end
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website