首页 > 解决方案 > 如何使用 Cuprite 检查模态文本?

问题描述

我正在从Poltergeist切换到Capybara的Cuprite驱动程序。

我有 Javascript 代码,它为我想检查我的功能规范的确认模式设置消息。

javascript 是confirm("....").

使用 Poltergiest 我可以做到page.driver.browser.modal_message

这是 Cuprite 不支持的,还有其他方法吗?

标签: capybaracuprite

解决方案


Capybaras accept_confirm (cuprite 支持)从系统模式返回字符串:

text = accept_confirm do
   # ... the actions that triggers the modal to appear
end

或者你可以传递一个字符串accept_confirm让它验证字符串:

accept_confirm('the text to check') do
   # ... the actions that triggers the modal to appear
end

推荐阅读