내가이 문제를 해결하기 위해 노력하고있어 ElementNotFound,하지만 난 말 Cabybara에서 오류 메시지를 수신 :레일 : 카피 바라가 ::
`Failure/Error: fill_in 'Name', with: 'Vostro 2017'
Capybara::ElementNotFound: Unable to find visible field "Name" that is not disabled`
내 new.html.erb
입니다 :
<%= form_for @item, url: {action: "create"} do |f|%>
<%= f.label 'Name' %>
<%= f.text_field :name %>
<%= f.label 'Description' %>
<%= f.text_field :description %>
<%= f.label 'Features' %>
<%= f.text_field :features %>
<%= f.label 'Asset number' %>
<%= f.text_field :assetNumber %>
<%= f.submit%>
<% end %>
그리고 내 item_controller.rb
입니다 :
class ItemController < ApplicationController
def show
@items = Item.find(params[:id])
end
def new
@item = Item.new
end
def create
@item = Item.new(item_params)
@item.save
redirect_to @item
end
private
def item_params
params.require(:item).permit(:name, :description, :features, :assetNumber)
end
end
테스트를 수행하는 데 사용되는 RSpec에 파일은 다음과 같습니다
require 'rails_helper'
feature 'User creates a new inventory item' do
scenario 'successfully' do
visit new_item_path
fill_in 'Name', with: 'Vostro 2017'
fill_in 'Description', with: 'Dell Notebook'
fill_in 'Features', with: '16gb, 1Tb, 15.6"'
fill_in 'Asset number', with: '392 DLL'
click_button 'Create Item'
expect(page).to have_content 'Vostro 2017'
expect(page).to have_content 'Dell Notebook'
expect(page).to have_content '16gb, 1Tb, 15.6"'
expect(page).to have_content '392 DLL'
end
end
저는 ruby-2.3.5 및 rails 4.1.0을 사용하고 있습니다. 저는 Ruby/Rails에서 초보자이기 때문에 코드에 어떤 문제가 있는지 알 수 없습니다. 누군가 나를 해결할 수 있도록 도와 줄 수 있습니까? 미리 감사드립니다.
find("input[id$='name']").set "Vostro 2017"
나 :
이
모달과 함께 pls로 질문을 업데이트 할 수 있습니까? –
@Ziyan Junaideen 모달이란 무엇입니까? – viniCdaSilva