capybara - 如何使用 Cuprite 检查模态文本?
问题描述
我正在从Poltergeist切换到Capybara的Cuprite驱动程序。
我有 Javascript 代码,它为我想检查我的功能规范的确认模式设置消息。
javascript 是confirm("....")
.
使用 Poltergiest 我可以做到page.driver.browser.modal_message
。
这是 Cuprite 不支持的,还有其他方法吗?
解决方案
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
推荐阅读
- javascript - Gatsby.js - 排版主题
- c# - 在 SWIGRegisterExceptionCallbacks_ 处遇到 SWIG 生成的代码挂起
- c# - C# - 允许继承但禁止直接使用构造函数
- verilog - 如何在系统verilog中进行位扩展?
- java - 代码格式化 - 规则被破坏时破坏构建
- javascript - 在 Linux 中将二进制文件的前 100 个字节打印为 uint8
- python - 安装新版本后无法重新加载sklearn
- npm - 如何修复 package.json 丢失的 server.js / "script":{"start": ""}
- python-3.x - 将模拟/迭代可视化为箱线图python中的置信区间?
- python - 我试图在函数中返回一个随机生成的数字,这样我就可以用它做一些数学运算