检查黄瓜表行中的值
我正在尝试检查数据表中的值是否正确,所以我所做的就是选择所有行并检查我要检查的对象名称和值的某个 tr 是否有内容。问题是,我似乎无法在黄瓜中返回:
Then /^I should see "([^"]*)" beside "([^"]*)"$/ do |value, name|
all("tr").each do |tr|
if tr.has_content?(value) && tr.has_content?(name)
assert true and return
end
end
assert false
end
我想要类似的东西。 具有这两个值时,这意味着它是正确的,我应该停止循环并返回 true(否则它最终将继续到 assert false
)
当我找到一行同时 我去管这个?
I am trying to check if the value in a data table is correct so what I do is select all the rows and check if that certain tr has_content of the object name and value i am checking for. Problem is, I can't seem to do a return
in cucumber:
Then /^I should see "([^"]*)" beside "([^"]*)"$/ do |value, name|
all("tr").each do |tr|
if tr.has_content?(value) && tr.has_content?(name)
assert true and return
end
end
assert false
end
I want something like that. When I find a row that has both the values, then that means it is correct and I should stop the loop and just return true(otherwise it will continue on to the assert false
in the end)
How do I go about this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,这似乎是一个肮脏的黑客,但我只是使用一个变量来检查:
我不确定它是否在所有情况下都有效......但如果您有更好的解决方案,也请发布它。谢谢!
well it seems like a dirty hack but I just used a variable to check:
I'm not sure if it will work in all cases...but if you have better solutions please post it too. thanks!
好吧,如果它是用 Watir 驱动浏览器,你可以做
在你的情况下做什么
Well if it was driving the browser with Watir you could do
In your case what about doing