Ruby on Rails: Cucumber: how to check if a link opens in a new window / tab?

I have a preview link in my application, and it opens in a new window, so that you will not lose unsaved changes ... how to divert cucumber attention to a new window?

+3
source share
1 answer

When I have links that open a new window / tab, I usually configure it to open in the same window for the test environment. I created this method for my application helper:

def link_target
  %[target="#{Rails.env.test? ? "_self" : "_blank"}"]
end

And inside my markup:

<a href="/path" <%= link_target %>>Click here</a>
-1
source

Source: https://habr.com/ru/post/1751824/


All Articles