Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open link in a new window with Capybara

Tags:

capybara

In Capybara, is it possible to open a link in a new window, rather than the current one?

like image 585
EyalB Avatar asked Mar 27 '12 14:03

EyalB


1 Answers

If this element is a link you can just get its href and open it in a new window:

url = find('.some_link')[:href]
within_window open_new_window do
  # do something
end

open_new_window has been added in Capybara 2.3

like image 200
Andrei Botalov Avatar answered Sep 28 '22 12:09

Andrei Botalov