作为 Watir 测试套件的一部分,我们正在验证一个数据表。其中一个要求是特定列必须为空(除非选择了特定的单选按钮)所以在我的脚本中,我有以下代码
incidents = browser.table(:xpath, Xpath_CC).strings
其中浏览器是 watir-webdriver 浏览器对象在事件中给出我的这个二维数组
[["DateTime", "Problem", "Value", "Compared", "Number", "Causes", "Where", "Count", "Type"],
["May 07, 02:15 - 02:30", "Web", "38.46 %", "", "1", "UNKNOWN", "", "1", "J105"],
["May 07, 02:15 - 02:30", "Video", "40 %", "", "1", "UNKNOWN", "", "1", "J105"],
["May 07, 02:00 - 02:15", "Email", "30 %", "", "1", "UNKNOWN", "", "1", "J105"],
["May 07, 01:00 - 01:15", "Email", "70 %", "", "1", "UNKNOWN", "", "1", "J105"],
["May 07, 01:00 - 01:15", "Email", "70 %", "", "1", "UNKNOWN", "", "1", "J105"],
["May 07, 01:00 - 01:15", "Email", "0 %", "", "1", "UNKNOWN", "", "1", "J105"],
]]
我需要做的是检查每个子数组中的每个“比较”列并确保它是空的。我可以做类似的事情
result = true
incidents.each do |row|
if (row[3] != '')
result = false
end
end
把那是我的 Java 大脑告诉我如何去做。我认为这里必须是一种更简单的单行红宝石方法