如何断言在ruby中检查的所有复选框

时间:2013-07-09 10:33:29

标签: ruby selenium assert

我找不到合适的答案,所以分享我的代码:

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

这是基于红宝石/硒/黄瓜。

0 个答案:

没有答案