【发布时间】:2013-01-17 16:26:12
【问题描述】:
刚开始在 webrat 中使用 cucumber。我有这些功能步骤:
When /^I choose a DVD$/ do
#just click the first one we see
check("optional-dvds[]")
end
Then /^I should be able to place my order$/ do
#the place my order button should be clickable
end
有问题的按钮有这个html:
<input disabled="disabled" id="submit_button" name="commit" type="submit" value="Please send this DVD">
并且,当用户单击 DVD 时,一些 js 会运行并从按钮中删除 disabled 属性。因此,第二步需要在执行上一步之后检查它是否没有“禁用”属性。我如何测试这个?我可以想到一种方法,使用 xpath 并检查页面上是否不存在禁用的提交按钮,但我宁愿按照 (pseudocode)
$("#submit_button").attr("disabled").should be_false
或类似的东西。我知道这是 jquery 和 rspec 的可怕混搭 :)
【问题讨论】: