【发布时间】:2018-08-19 17:47:21
【问题描述】:
我有一组使用引导程序的单选按钮,并希望使用 Capybara 使用 id 或 value 来选择它们。对于我的 rspec 测试。由于某种原因,它没有看到单选按钮,我想知道是否有人可以看看并提出建议。
我得到的错误是
Capybara::ElementNotFound: 找不到未禁用的可见单选按钮“纸张” 水豚::ElementNotFound: 找不到未禁用的可见单选按钮“#paper”
HTML`
</label>
<label for="paper" id="paper" class="btn btn-primary choice col-lg-4 col-md-4">
<input type="radio" value = "paper" name="rps" id="paper">
<img class="card-img-top img-fluid image-responsive" src="/img/paper.png" alt="Paper">
</input>
</label>
<label for="scissors" class="btn btn-primary choice col-lg-4 col-md-4">
<input type="radio" value = "scissors" name="rps" id="scissors">
<img class="card-img-top img-fluid image-responsive" src="/img/scissors.png" alt="Scissors">
</input>
</label>
</div>`
测试
feature 'Testing if we divert to /result chosing an option and play' do
scenario 'Choose option and click play' do
sign_in_and_play
click_button('Play')
choose("#paper")
# choose("paper")
expect(page).to have_content("Result displayed here")
end
end
任何帮助将不胜感激。 谢谢
【问题讨论】: