I am trying to run the integration testing in Ruby on rails using capybara but when i run the test i am getting a java script error

219 views Asked by At

HTML code for Issue Slip

<%= simple_nested_form_for @issue_slip do |f| %>
  <%= f.error_messages %>

  <p>
  <%= f.hidden_field :user_id, :value => current_user.id %>
  <b>From Store:</b></br>

<%= f.label :store_location_id %>
   <% if !current_user.store_location_id? %>
    <%= f.collection_select :store_location_id, StoreLocation.all,:id,:name, {:prompt => "Select Store"}, :style => 'width:205px;' %><br />
    <% else %>
    <%= f.collection_select :store_location_id, StoreLocation.all,:id,:name, :value => current_user.store_location_id %><br/>
    <% end %>

   <b>Delivery To:</b></br>

<% if @count == nil %> 
<div class = "shop_floors">
<%= f.label :shop_floor_id %>
<%= f.collection_select :shop_floor_id, ShopFloor.all,:id,:name, {:prompt => "-Select a Shopfloor"}, :style=>'width:150px;'%></div><br/>
<% else %>
<strong><%= f.label :shop_floor_id %>:<%= @issue_slip.shop_floor.name %></strong><br /><% end %>

<div class ="date">
 <%= f.label :date, "Date" %>
 <%= f.datepicker :date, :dateFormat => 'dd MM, yy',  :showOn => "both", :buttonImage => "/assets/calendar.gif", :buttonImageOnly => true, :changeMonth => true, :changeYear => true , :size =>20 %><br/></div>

<%= f.label :project_id %>
<%= f.text_field :project_id , :size => 20 %><br />

<%= f.label :employee_id, "Issued. By" %>
   <% if !current_user.employee_id? %>
    <%= f.collection_select :employee_id, Employee.all,:id,:name, {:prompt => "Select Employee"}, :style => 'width:205px;' %><br />
    <% else %>
    <%= f.collection_select :employee_id, Employee.find_all_by_user_id(current_user.id), :id, :name %><br/>
    <% end %>

 <%= f.input :remarks, :label => 'Remarks', :input_html => { :size => 20} %><br/>

 <%= f.label :bom_quantity %>
 <%= f.text_field :bom_quantity, :size=> 20, :value => number_with_precision(f.object.bom_quantity , :precision => 3) %><br />

 <div class = "cust_order">
<%= f.label :customer_order_id %>
<%= f.collection_select :customer_order_id , CustomerPendingOrder.all, :id,:id, :prompt => "Select Customer Order" %></div> <br />

<div class = "bom">
<%= f.label :bill_of_material_id %>
<%= f.collection_select :bill_of_material_id, BillOfMaterial.all, :id, :title , :prompt => "Select a BOM", :style => 'width:205px;' %></div>
<div class="load_bom"><%= f.submit "Load BOM" %></div> <br/>  

 <hr>
    <%= f.fields_for :issue_slip_line_items do |builder| %>
    <%= render 'issue_slip_line_item_fields', :f => builder %>
     <%end%>

 <p><%= f.link_to_add "Add Product", :issue_slip_line_items %> </p>   

 <p><%= f.submit data: {:disable_with=>@submit_tag_label}%><div class="load_preview_issue_slip"><%= f.submit "preview", :style => 'width:130px;', data: {:disable_with=>"loading preview..."} %></div></p>
  <% end %> 

</p>

Issue Slip Line Item

<%= f.link_to_remove "Remove Product"%><br/>
<div class ="product">

    <%= f.association :product, :prompt =>"Select Product",  input_html: {data:{prices: prices}}, :collection => Product.in_stock %> </div>
        <%= image_tag :image , :class => "prodimage"%>
<div class = "productid">
    <%= f.hidden_field :product_id, :class=>"productid" %></div>
<br/>


<div class ="price"><%= f.label :price %><%= f.text_field :price, :size=>20, :value => number_with_precision(f.object.price, :precision => 2)%> </div><br/>

<div class = "qty">  
    <%= f.label :quantity, "Quantity"%>
    <%= f.text_field :quantity, :size=>20 , :value => number_with_precision(f.object.quantity, :precision => 3)%></div><br/>

    <%= f.label :amount %>
    <%= f.text_field :amount, :size=>20,:class =>"amt", :value => number_with_precision(f.object.amount, :precision => 2) %><br/>


    <!--%= f.label :customs_duty, "Custom Duty"%-->
    <!--%= f.text_field :customs_duty, :size=>20 %-->


</div>
 <hr/> 

creating test case issue_slips_spec.rb

  it "issue slips test", :js => true do
    click_link 'New Issue Slip'
    select('Inuit HAL', :from => 'Store location')
    expect{ page.should have_content 'New Issue Slip'}
    expect{ page.should have_content 'From Store'}
    expect{ page.should have_content 'Delivery To'}
    select('sample shopfloor', :from => 'Shop floor')
    expect{ page.should have_content 'Shop floor '}
    fill_in "Date", :with => "06 October, 2014"
    fill_in "Project", :with => "1993"
    select('Sample Employee', :from => 'Issued. By')
    fill_in "Remarks", :with => "There is no remarks to mention"
    fill_in "Bom quantity", :with => "2"
    expect{ page.should have_link 'Add Product'}
    click_link 'Add Product'
    select('Nike', :from => 'Product')
    fill_in "Price", :with => "1000"
    fill_in "Quantity", :with => "1"
    fill_in "Amount", :with => "1000"
    expect{ page.should have_link 'Back to List'}
    click_button 'Create Issue slip'


end
end

Error Message:

    Failures:

      1) Sign in issue slips test
          Failure/Error: select('Nike', :from => 'Product')
         Webrat::NotFoundError:
           Could not find field: "Product"

         # ./spec/requests/issue_slips_spec.rb:36:in `block (2 levels) in <top (required)>'

    Finished in 47.31 seconds
    1 example, 1 failure

    Failed examples:

    rspec ./spec/requests/issue_slips_spec.rb:15 # Sign in issue slips test

In the above code the Add product link is the issue when i click the that link it should load up another form called as issue_slip_line_item there i have Product, Price, Amount, Quantity field in my case the test is not able to recognize the product field it is giving me the error unable to find the product, Actually when i click the add product link it should open the issue slip line item form, there i have field in which test case is failing to open the link please help

0

There are 0 answers