Capybara:尝试模拟按 <ENTER> 时出现 NotSupportedByDriverError [英] Capybara: NotSupportedByDriverError when trying to simulate pressing <ENTER>
本文介绍了Capybara:尝试模拟按 <ENTER> 时出现 NotSupportedByDriverError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Capybara 编写规范,以测试我网站上搜索栏的功能.按照此页面上的说明操作后,了解如何模拟按 Enter键入 Rspec/Capybara,运行测试时出现以下错误:
I am writing a spec using Capybara to test the functionality of a search bar on my website. After following the instructions on this page on how to simulate pressing the Enter Key in Rspec/Capybara, I get the following error when I run my tests:
Failure/Error: page.driver.execute_script(keypress)
Capybara::NotSupportedByDriverError:
Capybara::Driver::Base#execute_script
我做错了吗?这是我的规范文件的内容:
Am I doing something wrong? Here are the contents of my spec file:
require 'spec_helper'
describe 'Search' do
it 'displays no results when non-existent things are looked up' do
visit root_path
page.first(".search-icon-small").click
fill_in "search", with: "NonExistent"
#simulate pressing Enter
keypress ="var e = $.Event('keydown', { keyCode: 13 }); $('body').trigger(e);"
page.driver.execute_script(keypress)
page.should have_content('No Results')
end
it 'displays content that exists' do
#Clients
client = Client.new
client.name = 'Gerard Leskovar'
client.save!
visit root_path
page.first(".search-icon-small").click
fill_in "search", with: "Leskovar"
keypress ="var e = $.Event('keydown', { keyCode: 13 }); $('body').trigger(e);"
page.driver.execute_script(keypress)
page.should have_content('Gerard Leskovar')
end
end
感谢您的帮助!
推荐答案
好的,所以我没有安装 capybara-webkit
,因此我得到了我所做的错误.谢谢!
Okay, so I didn't have the capybara-webkit
installed and therefore I got the error that I did. Thank you!
这篇关于Capybara:尝试模拟按 <ENTER> 时出现 NotSupportedByDriverError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文