2012-03-05 17 views

Odpowiedz

66

pomocą np checked? metoda

.:

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 
+2

'my_box.should be_checked'. – yfeldblum

+0

Edytowane, dzięki za to, dobry połów! –

+1

Jeśli chcesz używać etykiet takich jak możesz za pomocą 'check', możesz zrobić:' expect (find (: checkbox, "My Label")) be_checked' –

1

oneliner użyciu 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

tej jednej pracy dla mnie

assert page.has_checked_field?('your_checkbox_id') 
assert page.has_no_checked_field?('your_checkbox_id') 
Powiązane problemy