我想檢查一下複選框是否使用黃瓜和水豚進行檢查。我檢查了上一步中的複選框,並希望通過獲取複選框的值來驗證它。如何獲取水豚複選框的值?
41
A
回答
66
使用checked?
方法
例如爲:
my_box = find('#some_checkbox')
my_box.should be_checked # Before Rspec 2.11
# OR using new syntax
expect(my_box).to be_checked # Rspec 2.11
1
oneliner使用MINITEST
require 'test/unit'
include Test::Unit::Assertions
Then(/^the checkbox "(.*?)" is enabled$/) do |check_box|
assert_equal(has_checked_field?(check_box), true, 'checkbox not found or checked')
end
3
這一個工作我
assert page.has_checked_field?('your_checkbox_id')
assert page.has_no_checked_field?('your_checkbox_id')
相關問題
- 1. 如何獲得水豚複選框的價值?
- 2. 如何查看水豚的複選框?
- 3. Rails的:水豚,複選框和IDS
- 4. 水豚/ Poltergeist,點擊隱藏複選框?
- 5. 水豚複選框不會觸發JS?
- 6. 用水豚檢查複選框
- 7. 水豚(poltergeist)無法找到複選框
- 8. 如何獲取複製複選框值
- 9. 如何輕鬆取消選中與水豚的所有複選框
- 10. 如何獲取JQuery複選框的值?
- 11. 如何獲取複選框中的值
- 12. 如何獲取複選框的值
- 13. 如何查找水豚中的第一個複選框?
- 14. 水豚。如何檢查在循環中生成的複選框
- 15. 與水豚獲取邊框樣式
- 16. 獲取複選框的值
- 17. 獲取複選框的值?
- 18. 獲取複選框的值
- 19. 如何從複選框中獲取值
- 20. 如何從複選框獲取id值?
- 21. 如何從cgridview獲取複選框值?
- 22. 如何獲取複選框
- 23. 獲取複選框組值
- 24. 獲取複選框值
- 25. 爲「全選」複選框編寫水豚/ poltergeist測試的問題
- 26. 獲取選中的複選框的值
- 27. MVC - 如何獲取選中的複選框中的複選框
- 28. 如何檢查複選框是否被選中與否水豚Rspec的
- 29. 獲取選中的複選框值
- 30. 獲取選中複選框的href值?
'my_box.should be_checked'。 – yfeldblum 2012-04-20 17:06:24
編輯,謝謝你,好! – 2012-05-09 09:04:16
如果你想使用像'check'一樣的標籤,你可以這樣做:'expect(find(:checkbox,「My Label」))。to be_checked' – 2017-03-30 12:47:24