私は理解して、私は、次のエラーを取得するテストを実行したときに、私はこのテストカピバラ:: ElementNotFound:XPathを見つけることができません「[@href '] //」
feature 'Edit post' do
let(:post) { build(:post) }
scenario 'can edit post' do
visit root_path
find(:xpath, "//a[@href='/posts/1']").click
click_link 'Edit'
fill_in 'Title', with: 'This is an updated post'
click_button 'Save'
expect(page).to have_content('Post was successfully updated')
expect(page).to have_content('This is an updated post')
end
end
を抱えています、カピバラはリンク
Failure/Error: find(:xpath, "//a[@href='/posts/1']").click
Capybara::ElementNotFound:
Unable to find xpath "//a[@href='/posts/1']"
を見つけることができないと言われ、私は、ブラウザ上でアプリを開く場合は、私はroot_path
(インデックス)からshow
リンクをクリックして、私はそこだと思わせるshowアクションにアクセスすることができますテストスクリプトでエラーが発生しました。これをどうすれば解決できますか?私がやった
UPDATE がpage.htmlを置く、これは、オブジェクトが遅延して構築されているlet
を使用しているとき、私は
<tbody>
<tr>
<td>Nihil neque corrupti atque qui eum omnis sapiente harum.</td>
<td>["Alias quas culpa expedita voluptatem vel. Eos aut autem tempora saepe odit iste. Iste ducimus dolorem a corrupti esse enim sint. Fugiat eum doloremque soluta ut voluptate sit. Nostrum unde in nobis quam ut adipisci quos cupiditate.", "Fugiat voluptatem qui totam fugit culpa et. Id omnis repellendus labore mollitia earum dignissimos ipsum. Eum rem qui excepturi culpa aut. Cum adipisci aspernatur nulla qui odio. Sequi minima doloremque iure ea possimus maiores alias."]</td>
<td><a href="/articles/1">Show</a></td>
<td><a href="/articles/1/edit">Edit</a></td>
<td><a data-confirm="Are you sure?" rel="nofollow" data-method="delete" href="/articles/1">Destroy</a></td>
</tr>
</tbody>
</table>
<br>
<a href="/articles/new">New Article</a>
</body>
に示したテキストに基づいてリンクをクリックしたほうが良いと思いますが、私は自分のコードを変更し – Lykos
を動作しませんでしたあなたのような 'find()...' idを今見つけられない 'xpathを見つけることができません// // [@href = '/ articles /']' ' – Lykos
も作成する必要があります。私のレビューで - それ以外の場合は保存されず、あなたのページに表示されません。あなたの例をあなたの現在のコードに更新してください。 –