8
我正在寫一個使用水豚的規格來測試我的網站上的搜索欄的功能。下面就如何模擬按下Rspec的/水豚Enter鍵在此page的指示後,我收到以下錯誤,當我運行我的測試:水豚:NotSupportedByDriverError當試圖模擬按<ENTER>
Failure/Error: page.driver.execute_script(keypress)
Capybara::NotSupportedByDriverError:
Capybara::Driver::Base#execute_script
難道我做錯了什麼?這裏是我的規格文件的內容:
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 gem! – Thalatta
如果任何人在使用Poltergeis作爲水豚司機時有這個答案,我會感激它:) –
我在我的gemfile中有寶石,我做了'捆綁',但它也不起作用 – Charlon