EyalB
EyalB

Reputation: 433

Open link in a new window with Capybara

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

Upvotes: 10

Views: 2849

Answers (1)

Andrei Botalov
Andrei Botalov

Reputation: 21096

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

Upvotes: 7

Related Questions