1
我想寫一個窗體的嵌套屬性使用Cocoon和rails 4的測試。問題是我找不到要設置的窗體元素。水貂繭形式值設置
我曾嘗試以下注釋掉的變化,但得到未找到要素:
click_link('Add Owner') # should display the fields
#fill_in 'First Name', with: "sean"
#find("input#horse_owner_attributes_fname").set('sean')
#find(:xpath, '//input[@id="horse_owner_attributes_lname"]').set("sean")
我不知道如果我的問題是繭「link_to_add_association」或動態性質只是我不知道如何使用查找或其他原因。
我的主要形式是:
#owner
#owner_from_list
= f.collection_select(:owner_id, @owners, :id, :fname, { :prompt => "Existing Owner" }, {:class => 'form-control'}) # shows drop down of existing records
= link_to_add_association 'Add Owner', f, :owner, :class => "btn btn-default btn-sm", :data => {"association-insertion-method" => "after" } # to add a new record
和我的老闆加分:
= f.inputs do
.nested-fields
= f.input :fname, :as => :string, label: "First Name", hint: "Owner's first name REQUIRED", :required => true
= f.input :lname, :as => :string, label: "Last Name", hint: "Last name REQUIRED", :required => true
感謝您指點我在正確的方向! – 2014-09-27 09:36:30