Clicked link and still on the same page (capybara)
When writing some automation i’ve tried to navigate to next page using a link…
click_on '6366'
…but saving and showing screenshot resulted in the same page being displayed. The reason was simple, link’s target was a new window (or tab). One way to handle this, is to switch context of window. It is as easy as
switch_to_window(window_opened_by { click_on '6366' })
but if you do not need/want to play around with multiple window contexts, consider following solution
visit find_link('6366')['href']
This way you will stay with current window context :)
Tweet