Rspec + Capybara : How to click on alert box

后端 未结 6 1282
梦谈多话
梦谈多话 2020-12-29 19:15

I have gone through the post of capybara + click on alert box but nothing seems to be work. Following is my scenario:

Scenario: When I click update

6条回答
  •  Happy的楠姐
    2020-12-29 19:33

    Updated answer here, since the options above seem to have all been deprecated.

    Capybara::Session#accept_alert seems to be the best way to accomplish this now, where the action that will trigger the alert should be passed in a block. http://www.rubydoc.info/github/jnicklas/capybara/Capybara/Session:accept_alert

    e.g.:

    page.accept_alert 'Alert text here' do
        click_button('Search')
    end
    

提交回复
热议问题