水豚:尝试模拟按< ENTER>时出现NotSupportedByDriverError。 [英] Capybara: NotSupportedByDriverError when trying to simulate pressing <ENTER>

查看:71
本文介绍了水豚:尝试模拟按< 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!

这篇关于水豚:尝试模拟按< ENTER>时出现NotSupportedByDriverError。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆