- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚学习功能规范,但遇到了一个我不太明白的问题。 Capybara::ElementNotFound:
当我尝试运行测试时。这很奇怪,因为我逐字逐句地遵循模板,但我仍然收到此错误。我需要一些帮助!为了清楚起见,这是我的代码和错误。
测试
require "rails_helper"
RSpec.feature "Create a subscriber" do
scenario "Customer can sign up as a subscriber" do
visit "/subscribers/new"
user = User.create!(email: "user@example.com", password: "password")
fill_in "Email", with: "user@example.com"
fill_in "Password", with: "password"
click_button "Sign in"
fill_in "first_name", with:
fill_in "last_name", with:
fill_in "email", with:
fill_in "phone_number", with: "8269338"
expect(page).to have_content("Subscriber Has Been Successfully Created")
end
end
查看
<%= form_for @subscriber do |form| %>
<div class="form-group">
<p>
<%= form.label :first %>
<%= form.text_field :first_name %>
</p>
<p>
<%= form.label :last %>
<%= form.text_field :last_name %>
</p>
<p>
<%= form.label :email %>
<%= form.text_field :email %>
</p>
<p>
<%= form.label :phone %>
<%= form.text_field :phone_number %>
</p>
</div>
<%= form.submit "Sign Up", class: "btn btn-primary" %>
最佳答案
字段的 ID 都将以 subscriber_
为前缀 - 尝试将 fill_in "first_name", with: "Cam"
更改为 fill_in "subscriber_first_name", with : "Cam"
看看是否能解决问题。
关于ruby-on-rails - capybara ::ElementNotFound:找不到字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37550827/
我正在使用 Capybara(v2.0.1) 和 RSpec(v2.11.0),我的规范与 README 上的示例非常相似: require 'capybara/rspec' require 'cap
我在尝试使用此功能规范时难以隔离问题。 require 'spec_helper' feature 'Add Employee', type: :feature do scenario 'with
我收到以下错误: Capybara::ElementNotFound: Unable to find field "username" ./spec/controllers/sessions_cont
在终端中进行 Capybara 测试时收到以下错误: Failures: 1) Users User create new user Failure/Error: fill_in 'Us
我刚刚学习功能规范,但遇到了一个我不太明白的问题。 Capybara::ElementNotFound: 当我尝试运行测试时。这很奇怪,因为我逐字逐句地遵循模板,但我仍然收到此错误。我需要一些帮助!为
我正在尝试使用 Capybara 从下拉列表中选择一个元素。我使用不同的 CSS 框架已经做得很好了;现在我正在使用 Materialise。 我已经与开发人员交谈过,他提到 Materialise
我有一个简单的引导模式,当用户单击链接时,它会显示一个带有下拉菜单和提交按钮的表单。我尝试在 Rspec 功能测试中使用 Capybara 从下拉菜单中选择选项,但它没有找到下拉菜单。 功能规范: s
我已经尝试修复这个错误很长时间了,但我似乎无法弄清楚它是什么。在此先感谢您的帮助! 我正在为带有 capybara 和 rspec 的 Rails 应用程序编写测试,尝试单击导航栏中的元素,然后进行测
我查看了与此相关的其他帖子,并尝试了所有修复它的提示,但仍然遇到错误。有人可以看看我的代码并告诉我为什么我会继续收到此错误。 .html 代码看起来像 Log in Note: authentica
我遇到了以下问题,这是我第一次使用 capybara ,你知道我如何解决这个问题吗,谢谢 我使用 Rails 3.0.0 和以下 gem gem 'rails', '3.0.0' gem 'capyb
有人邀请我帮忙开发一个 Rails 应用程序。我正在经历一些失败的 rpsec 测试并让它们通过。我有一个我正在用头撞墙。我们使用的是 Rails 3.2.13 和 Ruby 2.0 注意:我对 rs
我对在大量集成测试中共享的方法有疑问。 问题是,我需要找到两个按钮之一,到目前为止,我只提出了以下笨拙的语法来避免 Capybara 的 ElementNotFound 错误: new_button
在我的 Rails 应用程序中,我有一个带有执行 javascript 函数的链接的页面: 在我的 cucumber 功能中我有: And I press "Add an address" 我收到的
我无法解决这个问题。请帮我。它给我找不到元素的错误。 spec/features/todos/create_spec.rb require 'spec_helper' describe "Creati
我正在测试文件上传,即 CSV。在我的代码和浏览器 HTML 中,我找到了文件字段,但在测试 capybara 时找不到文件字段。我努力尝试不同的方法,但无法解决问题。这里部分看起来像这样: #add
我正在尝试使用 capybara+rspec 并收到此错误:无法找到字段“名称”(Capybara::ElementNotFound) 这是我的表格: %h2 Sign up = simple_for
我正在使用 selenium、capybara 和 rspec 进行测试,我注意到所有测试都在本地通过,但在 travis 上所有测试都失败了,每个规范都出现了这个错误。 Capybara::Elem
我已经在网上阅读了很多文章,但仍未找到解决问题的方法。我正在使用 Selenium 网络驱动程序: Capybara.default_driver = :selenium Capyba
我正在编写 Capybara 测试,其中一个测试用例是“删除”帖子而且我不断收到此错误。有帮助吗? Failure/Error: within "#post_#{post.id}" do
我正在学习 http://ruby.railstutorial.org/chapters/static-pages 上的 Ruby on Rails 教程并遇到以下错误 StaticPages Ho
我是一名优秀的程序员,十分优秀!