来自水豚的弃用警告 [英] Deprecation warning from Capybara

查看:76
本文介绍了来自水豚的弃用警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用rspec-rails 2.14.0.rc1和capybara 2.4.1从Rails 3.2.19升级到Rails 4.1.5。所有测试均通过,我只剩下一个弃用警告:

I am upgrading from rails 3.2.19 to rails 4.1.5, using rspec-rails 2.14.0.rc1 and capybara 2.4.1. All tests pass, and I only have one deprecation warning left:

[DEPRECATION] Capybara::Webkit::Driver#accept_js_confirms! is deprecated. Please use Capybara::Session#accept_confirm instead.

导致此问题的代码行是

page.driver.accept_js_confirms!

如何更改此行以消除过时警告?

How do I change this line in order to eliminate the deprecation warning?

推荐答案

鉴于该异常显示:


请使用水豚: :session#accept_confirm。

Please use Capybara::Session#accept_confirm instead.

您可能想要:

page.accept_confirm

请注意 accept_confirm 正在针对Capybara :: Session而不是驱动程序运行。

Note that accept_confirm is being run against the Capybara::Session instead of the driver.

此方法期望一个触发确认警报的块出现。例如:

This method expects a block that triggers the confirm alert to appear. For example:

page.accept_confirm do
  click_link('that_opens_confirm')
end

这篇关于来自水豚的弃用警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆