在 Cucumber 中,我尝试创建这样的步骤:
Then I should see "Example business name" in the "Business name" input
我希望将“公司名称”输入定义为“标签包含文本“公司名称”的输入。
这是到目前为止我所取得的进展:
Then /^I should see "([^"]*)" in the "([^"]*)" input$/ do |content, labeltext|
# Not sure what to put here
end
在 jQuery 中,我会查找包含该文本的标签,查看其“for”属性,然后查找具有该 id 的输入。但到目前为止我在 Cucumber 中见过的唯一选择器是这些:
within("input:nth-child(#{pos.to_i}")
and
page.should have_content('foo')
有人可以建议使用 Webrat / Capybara 选择器语法的解决方案吗?
弄清楚了
您可以使用标签文本找到输入find_field(labeltext)
.
# Example:
# 'I should see "Howdy" in the "Greeting" input' ("Greeting" is the label text)
Then /^I should see "([^"]*)" in the "([^"]*)" input$/ do |content, labeltext|
find_field("#{labeltext}").value.should == content
end
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)