Rspec + Capybara : How to click on alert box

后端 未结 6 1293
梦谈多话
梦谈多话 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条回答
  •  醉酒成梦
    2020-12-29 19:34

    Try this line if you want to click on the ok button of the alert box:

    page.evaluate_script('window.confirm = function() { return true; }')
    

    Don't forget to mark your test with the javascript flag

    it "update user to trainer", js: true do
        ...
    end
    

    and enable Capybara.javascript_driver with :webkit or :selenium in your spec_helper file

提交回复
热议问题