来自 Capybara 的弃用警告 [英] Deprecation warning from Capybara
问题描述
我正在从 rails 3.2.19 升级到 rails 4.1.5,使用 rspec-rails 2.14.0.rc1 和 capybara 2.4.1.所有测试都通过了,我只剩下一个弃用警告:
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.
导致这种情况的代码行是
The line of code that is causing this is
page.driver.accept_js_confirms!
如何更改此行以消除弃用警告?
How do I change this line in order to eliminate the deprecation warning?
推荐答案
鉴于异常说:
请改用 Capybara::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
这篇关于来自 Capybara 的弃用警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!