我找不到合适的答案,所以分享我的代码:
When /^I should see all of the checkboxs "([^"]*)" is checked$/ do |name|
a= all("input[type='checkbox'][name='#{name}']")
j = 0
while j < a.length do
a[j].should be_checked
j = j+1
end
end
# @name: the checkbox name
When /^I should see all of the checkboxs "([^"]*)" is not checked$/ do |name|
a= all("input[type='checkbox'][name='#{name}']")
j = 0
while j < a.length do
a[j].should_not be_checked
j = j+1
end
end
这是基于红宝石/硒/黄瓜。