水豚在 Accept_Confirm 上失败
Capybara fails on Accept_Confirm
我正在尝试在 rails 的 "Link_to" 助手中设置验证测试,当它有 => 数据时:{确认:"Are you sure?"}
我已经尝试了 Accept_confirm 和 Accept_Alert,但是 none 成功了。错误显示:Capybara::NotSupportedByDriverError: Capybara::Driver::Base#accept_modal
describe 'delete' do
it 'y existe un enlace para borrar Post' do
@post = FactoryBot.create(:post)
visit posts_path
accept_confirm("Are you sure?") do
click_link("delete#{@post.id}")
end
expect(page.status_code).to eq(200)
end
end
<td>
<%= link_to 'Borrar', post_path(post), method: :delete, id: "delete#{post.id}", data: {confirm: "Are you sure?" }%>
</td>
完整的错误信息说:
1) navegate delete y existe un enlace para borrar Post
Failure/Error:
accept_confirm("Are you sure?") 做
click_link("delete#{@post.id}")
结束
Capybara::NotSupportedByDriverError:
Capybara::Driver::Base#accept_modal
# ./spec/features/post_spec.rb:45:in `block (3 levels) in <top (required)>'
您运行正在使用不支持 JS 的驱动程序(可能是默认的 rack_test
驱动程序)进行测试。因此 JS 驱动的模态框无法显示,并且不支持模态处理方法。如果您想使用页面的 JS 功能,您必须 运行 通过支持 JS 的驱动程序进行测试 - https://github.com/teamcapybara/capybara/blob/master/README.md#drivers.
您可以添加js: true
切换到Capybara.javascript_driver
describe 'delete', js: true do
it 'y existe un enlace para borrar Post' do
@post = FactoryBot.create(:post)
visit posts_path
accept_confirm("Are you sure?") do
click_link("delete#{@post.id}")
end
expect(page.status_code).to eq(200)
end
end
文档在这里:https://github.com/teamcapybara/capybara/blob/master/README.md#using-capybara-with-rspec
我正在尝试在 rails 的 "Link_to" 助手中设置验证测试,当它有 => 数据时:{确认:"Are you sure?"}
我已经尝试了 Accept_confirm 和 Accept_Alert,但是 none 成功了。错误显示:Capybara::NotSupportedByDriverError: Capybara::Driver::Base#accept_modal
describe 'delete' do
it 'y existe un enlace para borrar Post' do
@post = FactoryBot.create(:post)
visit posts_path
accept_confirm("Are you sure?") do
click_link("delete#{@post.id}")
end
expect(page.status_code).to eq(200)
end
end
<td>
<%= link_to 'Borrar', post_path(post), method: :delete, id: "delete#{post.id}", data: {confirm: "Are you sure?" }%>
</td>
完整的错误信息说: 1) navegate delete y existe un enlace para borrar Post Failure/Error: accept_confirm("Are you sure?") 做 click_link("delete#{@post.id}") 结束
Capybara::NotSupportedByDriverError:
Capybara::Driver::Base#accept_modal
# ./spec/features/post_spec.rb:45:in `block (3 levels) in <top (required)>'
您运行正在使用不支持 JS 的驱动程序(可能是默认的 rack_test
驱动程序)进行测试。因此 JS 驱动的模态框无法显示,并且不支持模态处理方法。如果您想使用页面的 JS 功能,您必须 运行 通过支持 JS 的驱动程序进行测试 - https://github.com/teamcapybara/capybara/blob/master/README.md#drivers.
您可以添加js: true
切换到Capybara.javascript_driver
describe 'delete', js: true do
it 'y existe un enlace para borrar Post' do
@post = FactoryBot.create(:post)
visit posts_path
accept_confirm("Are you sure?") do
click_link("delete#{@post.id}")
end
expect(page.status_code).to eq(200)
end
end
文档在这里:https://github.com/teamcapybara/capybara/blob/master/README.md#using-capybara-with-rspec