我将从Poltergeist切换到Capybara的Cuprite驱动程序。
我有Javascript代码,它设置了确认模式的消息,我想在我的功能规格中检查。
javascript是confirm("....")。
有了Poltergiest,我可以做page.driver.browser.modal_message。
这是不被Cuprite支持的,它有另一种方式吗?
发布于 2019-09-16 23:38:34
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发布于 2019-09-16 23:32:42
看看Cuprite在幕后使用的ferrum驱动程序,我可以看到,可以为出现的对话框注册一个钩子。
message = nil
page.driver.browser.on(:dialog) do |dialog|
message = dialog.message
end
accept_confirm do
click_on progress_tab.name
expect(message).to eq text('...')
end这不是很漂亮。
https://stackoverflow.com/questions/57959819
复制相似问题