我无法让Capybara在这里找到一个元素;
<div class="block__body">
<div class="programme-list">
<div class="programme-item">
<div class="programme-item__header">
<svg class="icon icon--type">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icons-flexi"></use>
</svg>
<h3 class="programme-item__title">Flexi programmes</h3>
</div>
<div class="programme-item__body">
<ul class="list-style-none">
<div class="progress">
<div class="progress__status">
<div class="progress__total">
<span class="progress__label">
Total <strong>£265000</strong>
</span>
</div>
<a class="action action--link action--understate" href="/sponsors/1/programmes/sport-fit-scheme-1">
<span class="action__label">Sport Fit Scheme</span>
<!--<svg class="icon icon--arrow">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icons-chevron-right"></use>
</svg>-->
</a>
这是我的rspec文件中的代码。
scenario 'Update programme' do
programme = create(
:programme,
id: 2,
name: 'Acme Two Programme',
description: 'The description for the Acme Two Programme',
account: create(:account)
)
sign_in_as(admin)
click_link 'Programmes'
within(:css, '.programme-list') do
within(:css, '.programme-item') do # this does not work...
end
end
我得到的错误是;
Capybara::ElementNotFound: Unable to find css ".programme-item"
为什么找不到元素?是因为我在理论上有几个同名的元素吗?如果是这样,我怎么能只指定一个?