How to handle Modals in cucumber + Capybara + Selenium
===

So I am trying to click a forgot password link (which causes a modal pop up) and confirm the pop up link so I can perform a test on the sent out email.

My code looks like this:

       page.find(:css, '#launch-modal-link').click  # code fails on this line, after clicking the link

       page.driver.browser.switch_to.alert.accept  # does not get to this line of code.


What am I doing wrong exactly when trying to click the "Ok" button in the modal pop up?


Do I need to add a try catch block (or whatever it is called in Ruby) around the link 