2012-02-08 8 views
0

すべて!カピバラキュウリの成分の収集方法

可能な私が持っているテーブル

<tabel> 
    <tr><td><input type=text/></td><td><input type=text/></td></tr> 
    <tr><td><input type=text/></td><td><input type=text/></td></tr> 
    <tr><td><input type=text/></td><td><input type=text/></td></tr> 
    <tr><td><input type=text/></td><td><input type=text/></td></tr> 
</table> 

私は「XPathを見つけることができません@取得この

table.hashes.each do |hash| 
     within(:xpath,"//div[@id='cycle_form']/table/tr#{table.hashes.index(hash)}") do 
     fill_in("schedule_of_working_new_cycle_attributes__day", :with => hash['day']) 
     fill_in("schedule_of_working_new_cycle_attributes__hour", :with => hash['hour']) 
     fill_in("schedule_of_working_new_cycle_attributes__hour_night", :with => hash['hour_night']) 
     end 
    end 

のようなキュウリのステップ定義でサイクルでそれらを埋めたい// divの[ID @ = 'cycle_form']/table/tr [0] "@

カピバラで要素のコレクションを取得するにはどうすればよいですか?これは動作します

<div id="cycle_form"> 
    <table> 
     <tr><td><input type="text"/></td><td><input type="text"/></td></tr> 
     <tr><td><input type="text"/></td><td><input type="text"/></td></tr> 
     <tr><td><input type="text"/></td><td><input type="text"/></td></tr> 
     <tr><td><input type="text"/></td><td><input type="text"/></td></tr> 
    </table> 
</div> 

//div[@id='cycle_form']/table/tr[1] 

他の事は、XPathインデックス作成が始まる、ということである

+0

htmlのid = "cycleform"でdivの名前を付けてみましたか? – uday

+1

もあなたの実際のコードで間違っていますか、ここに投稿したときに間違って入力しましたか?それはあなたの問題かもしれないから。 – IanW

+0

私はこのfind(:xpath、 "// div [@ id = 'cycle_form']/table")のような別のsetipを持っているので、私のdivのid attrの名前を変更しようとしません。have have_css( "tr td input [ @ type = 'text'] ")はパスです。それは動作します – dilshod

答えて

0

それは、XMLと問題になる可能性がありますので、このように見えることを意図している前提1は0ではないため、元のクエリはどのようにも機能しませんでした。 入力XMLを再度チェックし、反復の開始値を修正すれば正常に動作します。

+0

すべてを確認して修正しました。私のコードは[ここ](http://copytaste.com/d831)ですが、私は気にします。@@ xpathを見つけることができません "//div [@ id = 'cycleform']/table/tr [1]"(Capybara :: elementNotFound) (eval):2: 'find ' ./features/step_definitions/fill_schedule_of_working_steps.rb:72:in'ブロック(2レベル) '..... @@ – dilshod

関連する問題